1 11 package org.eclipse.jdi.internal; 12 13 14 import java.io.DataInputStream ; 15 import java.io.IOException ; 16 import java.util.ArrayList ; 17 import java.util.Iterator ; 18 import java.util.List ; 19 20 import org.eclipse.jdi.internal.jdwp.JdwpClassObjectID; 21 import org.eclipse.jdi.internal.jdwp.JdwpID; 22 import org.eclipse.jdi.internal.jdwp.JdwpInterfaceID; 23 24 import com.sun.jdi.ClassNotPreparedException; 25 import com.sun.jdi.InterfaceType; 26 import com.sun.jdi.Value; 27 28 34 public class InterfaceTypeImpl extends ReferenceTypeImpl implements InterfaceType { 35 36 public static final byte typeTag = JdwpID.TYPE_TAG_INTERFACE; 37 38 41 public InterfaceTypeImpl(VirtualMachineImpl vmImpl, JdwpInterfaceID interfaceID) { 42 super("InterfaceType", vmImpl, interfaceID); } 44 45 48 public InterfaceTypeImpl(VirtualMachineImpl vmImpl, JdwpInterfaceID interfaceID, String signature, String genericSignature) { 49 super("InterfaceType", vmImpl, interfaceID, signature, genericSignature); } 51 52 55 public Value createNullValue() { 56 return new ClassObjectReferenceImpl(virtualMachineImpl(), new JdwpClassObjectID(virtualMachineImpl())); 57 } 58 59 62 public byte typeTag() { 63 return typeTag; 64 } 65 66 69 public void flushStoredJdwpResults() { 70 super.flushStoredJdwpResults(); 71 72 Iterator itr = virtualMachineImpl().allCachedRefTypes(); 74 while (itr.hasNext()) { 75 ReferenceTypeImpl refType = (ReferenceTypeImpl)itr.next(); 76 if (refType.fInterfaces != null && refType.fInterfaces.contains(this)) { 77 refType.flushStoredJdwpResults(); 78 } 79 } 80 81 } 82 83 86 public List implementors() { 87 List implementors = new ArrayList (); 89 Iterator itr = virtualMachineImpl().allRefTypes(); 90 while (itr.hasNext()) { 91 ReferenceTypeImpl refType = (ReferenceTypeImpl)itr.next(); 92 if (refType instanceof ClassTypeImpl) { 93 try { 94 ClassTypeImpl classType = (ClassTypeImpl)refType; 95 List interfaces = classType.interfaces(); 96 if (interfaces.contains(this)) { 97 implementors .add(classType); 98 } 99 } catch (ClassNotPreparedException e) { 100 continue; 101 } 102 } 103 } 104 return implementors; 105 } 106 107 110 public List subinterfaces() { 111 List implementors = new ArrayList (); 113 Iterator itr = virtualMachineImpl().allRefTypes(); 114 while (itr.hasNext()) { 115 try { 116 ReferenceTypeImpl refType = (ReferenceTypeImpl)itr.next(); 117 if (refType instanceof InterfaceTypeImpl) { 118 InterfaceTypeImpl interFaceType = (InterfaceTypeImpl)refType; 119 List interfaces = interFaceType.superinterfaces(); 120 if (interfaces.contains(this)) { 121 implementors.add(interFaceType); 122 } 123 } 124 } catch (ClassNotPreparedException e) { 125 continue; 126 } 127 } 128 return implementors; 129 } 130 131 134 public List superinterfaces() { 135 return interfaces(); 136 } 137 138 141 public boolean isInitialized() { 142 return isPrepared(); 143 } 144 145 148 public static InterfaceTypeImpl read(MirrorImpl target, DataInputStream in) throws IOException { 149 VirtualMachineImpl vmImpl = target.virtualMachineImpl(); 150 JdwpInterfaceID ID = new JdwpInterfaceID(vmImpl); 151 ID.read(in); 152 if (target.fVerboseWriter != null) { 153 target.fVerboseWriter.println("interfaceType", ID.value()); } 155 156 if (ID.isNull()) { 157 return null; 158 } 159 160 InterfaceTypeImpl mirror = (InterfaceTypeImpl)vmImpl.getCachedMirror(ID); 161 if (mirror == null) { 162 mirror = new InterfaceTypeImpl(vmImpl, ID); 163 vmImpl.addCachedMirror(mirror); 164 } 165 return mirror; 166 } 167 168 171 public static InterfaceTypeImpl readWithSignature(MirrorImpl target, boolean withGenericSignature, DataInputStream in) throws IOException { 172 VirtualMachineImpl vmImpl = target.virtualMachineImpl(); 173 JdwpInterfaceID ID = new JdwpInterfaceID(vmImpl); 174 ID.read(in); 175 if (target.fVerboseWriter != null) { 176 target.fVerboseWriter.println("interfaceType", ID.value()); } 178 179 String signature = target.readString("signature", in); String genericSignature= null; 181 if (withGenericSignature) { 182 genericSignature= target.readString("generic signature", in); } 184 if (ID.isNull()) { 185 return null; 186 } 187 188 InterfaceTypeImpl mirror = (InterfaceTypeImpl)vmImpl.getCachedMirror(ID); 189 if (mirror == null) { 190 mirror = new InterfaceTypeImpl(vmImpl, ID); 191 vmImpl.addCachedMirror(mirror); 192 } 193 mirror.setSignature(signature); 194 mirror.setGenericSignature(genericSignature); 195 return mirror; 196 } 197 } 198 | Popular Tags |