1 25 26 package org.netbeans.modules.classfile; 27 28 import java.io.DataInputStream ; 29 import java.io.IOException ; 30 31 36 public final class InnerClass { 37 38 ClassName name; 39 ClassName outerClassName; 40 String simpleName; 41 int access; 42 43 static InnerClass[] loadInnerClasses(DataInputStream in, ConstantPool pool) 44 throws IOException { 45 int n = in.readUnsignedShort(); 46 InnerClass[] innerClasses = new InnerClass[n]; 47 for (int i = 0; i < n; i++) 48 innerClasses[i] = new InnerClass(in, pool); 49 return innerClasses; 50 } 51 52 InnerClass(DataInputStream in, ConstantPool pool) 53 throws IOException { 54 loadInnerClass(in, pool); 55 } 56 57 private void loadInnerClass(DataInputStream in, ConstantPool pool) 58 throws IOException { 59 int index = in.readUnsignedShort(); 60 name = (index > 0) ? pool.getClass(index).getClassName() : null; 61 index = in.readUnsignedShort(); 62 outerClassName = (index > 0) ? pool.getClass(index).getClassName() : null; 63 index = in.readUnsignedShort(); 64 if (index > 0) { 65 CPUTF8Info entry = (CPUTF8Info)pool.get(index); 66 simpleName = entry.getName(); 67 } 68 access = in.readUnsignedShort(); 69 } 70 71 76 public final ClassName getName() { 77 return name; 78 } 79 80 84 public final ClassName getOuterClassName() { 85 return outerClassName; 86 } 87 88 93 public final String getSimpleName() { 94 return simpleName; 95 } 96 97 100 public final int getAccess() { 101 return access; 102 } 103 104 public String toString() { 105 StringBuffer sb = new StringBuffer (); 106 sb.append("innerclass="); 107 sb.append(name); 108 if (simpleName != null) { 109 sb.append(" ("); 110 sb.append(simpleName); 111 sb.append(')'); 112 } 113 sb.append(", outerclass="); 114 sb.append(outerClassName); 115 return sb.toString(); 116 } 117 } 118 | Popular Tags |