1 11 package org.eclipse.jdt.internal.debug.core.model; 12 13 14 import com.ibm.icu.text.MessageFormat; 15 import java.util.ArrayList ; 16 import java.util.Iterator ; 17 import java.util.List ; 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 29 public class JDIInterfaceType extends JDIReferenceType implements IJavaInterfaceType { 30 31 35 public JDIInterfaceType(JDIDebugTarget target, InterfaceType type) { 36 super(target, type); 37 } 38 39 42 public IJavaClassType[] getImplementors() throws DebugException { 43 try { 44 List implementorList = ((InterfaceType)getUnderlyingType()).implementors(); 45 List javaClassTypeList = new ArrayList (implementorList.size()); 46 Iterator 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 re) { 57 targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIClassType_exception_while_retrieving_superclass, new String [] {re.toString()}), re); 58 } 59 return new IJavaClassType[0]; 60 } 61 62 65 public IJavaInterfaceType[] getSubInterfaces() throws DebugException { 66 try { 67 List subList = ((InterfaceType)getUnderlyingType()).subinterfaces(); 68 List javaInterfaceTypeList = new ArrayList (subList.size()); 69 Iterator 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 re) { 80 targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIClassType_exception_while_retrieving_superclass, new String [] {re.toString()}), re); 81 } 82 return new IJavaInterfaceType[0]; 83 } 84 85 88 public IJavaInterfaceType[] getSuperInterfaces() throws DebugException { 89 try { 90 List superList = ((InterfaceType)getUnderlyingType()).superinterfaces(); 91 List javaInterfaceTypeList = new ArrayList (superList.size()); 92 Iterator 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 re) { 103 targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIClassType_exception_while_retrieving_superclass, new String [] {re.toString()}), re); 104 } 105 return new IJavaInterfaceType[0]; 106 } 107 108 } 109 110 | Popular Tags |