KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > core > model > JDIInterfaceType


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.debug.core.model;
12
13  
14 import com.ibm.icu.text.MessageFormat;
15 import java.util.ArrayList JavaDoc;
16 import java.util.Iterator JavaDoc;
17 import java.util.List JavaDoc;
18
19 import org.eclipse.debug.core.DebugException;
20 import org.eclipse.jdt.debug.core.IJavaClassType;
21 import org.eclipse.jdt.debug.core.IJavaInterfaceType;
22
23 import com.sun.jdi.ClassType;
24 import com.sun.jdi.InterfaceType;
25
26 /**
27  * The interface of an object in a debug target.
28  */

29 public class JDIInterfaceType extends JDIReferenceType implements IJavaInterfaceType {
30     
31     /**
32      * Cosntructs a new interface type on the given target referencing
33      * the specified interface type.
34      */

35     public JDIInterfaceType(JDIDebugTarget target, InterfaceType type) {
36         super(target, type);
37     }
38     
39     /* (non-Javadoc)
40      * @see org.eclipse.jdt.debug.core.IJavaInterfaceType#getImplementors()
41      */

42     public IJavaClassType[] getImplementors() throws DebugException {
43         try {
44             List JavaDoc implementorList = ((InterfaceType)getUnderlyingType()).implementors();
45             List JavaDoc javaClassTypeList = new ArrayList JavaDoc(implementorList.size());
46             Iterator JavaDoc iterator = implementorList.iterator();
47             while (iterator.hasNext()) {
48                 ClassType classType = (ClassType) iterator.next();
49                 if (classType != null) {
50                     javaClassTypeList.add(JDIType.createType(getJavaDebugTarget(), classType));
51                 }
52             }
53             IJavaClassType[] javaClassTypeArray = new IJavaClassType[javaClassTypeList.size()];
54             javaClassTypeArray = (IJavaClassType[]) javaClassTypeList.toArray(javaClassTypeArray);
55             return javaClassTypeArray;
56         } catch (RuntimeException JavaDoc re) {
57             targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIClassType_exception_while_retrieving_superclass, new String JavaDoc[] {re.toString()}), re);
58         }
59         return new IJavaClassType[0];
60     }
61
62     /* (non-Javadoc)
63      * @see org.eclipse.jdt.debug.core.IJavaInterfaceType#getSubInterfaces()
64      */

65     public IJavaInterfaceType[] getSubInterfaces() throws DebugException {
66         try {
67             List JavaDoc subList = ((InterfaceType)getUnderlyingType()).subinterfaces();
68             List JavaDoc javaInterfaceTypeList = new ArrayList JavaDoc(subList.size());
69             Iterator JavaDoc iterator = subList.iterator();
70             while (iterator.hasNext()) {
71                 InterfaceType interfaceType = (InterfaceType) iterator.next();
72                 if (interfaceType != null) {
73                     javaInterfaceTypeList.add(JDIType.createType(getJavaDebugTarget(), interfaceType));
74                 }
75             }
76             IJavaInterfaceType[] javaInterfaceTypeArray = new IJavaInterfaceType[javaInterfaceTypeList.size()];
77             javaInterfaceTypeArray = (IJavaInterfaceType[]) javaInterfaceTypeList.toArray(javaInterfaceTypeArray);
78             return javaInterfaceTypeArray;
79         } catch (RuntimeException JavaDoc re) {
80             targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIClassType_exception_while_retrieving_superclass, new String JavaDoc[] {re.toString()}), re);
81         }
82         return new IJavaInterfaceType[0];
83     }
84
85     /* (non-Javadoc)
86      * @see org.eclipse.jdt.debug.core.IJavaInterfaceType#getSuperInterfaces()
87      */

88     public IJavaInterfaceType[] getSuperInterfaces() throws DebugException {
89         try {
90             List JavaDoc superList = ((InterfaceType)getUnderlyingType()).superinterfaces();
91             List JavaDoc javaInterfaceTypeList = new ArrayList JavaDoc(superList.size());
92             Iterator JavaDoc iterator = superList.iterator();
93             while (iterator.hasNext()) {
94                 InterfaceType interfaceType = (InterfaceType) iterator.next();
95                 if (interfaceType != null) {
96                     javaInterfaceTypeList.add(JDIType.createType(getJavaDebugTarget(), interfaceType));
97                 }
98             }
99             IJavaInterfaceType[] javaInterfaceTypeArray = new IJavaInterfaceType[javaInterfaceTypeList.size()];
100             javaInterfaceTypeArray = (IJavaInterfaceType[]) javaInterfaceTypeList.toArray(javaInterfaceTypeArray);
101             return javaInterfaceTypeArray;
102         } catch (RuntimeException JavaDoc re) {
103             targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIClassType_exception_while_retrieving_superclass, new String JavaDoc[] {re.toString()}), re);
104         }
105         return new IJavaInterfaceType[0];
106     }
107
108 }
109
110
Popular Tags