1 11 package org.eclipse.jdt.internal.compiler.classfmt; 12 13 import org.eclipse.jdt.internal.compiler.env.IBinaryNestedType; 14 15 19 20 public class InnerClassInfo extends ClassFileStruct implements IBinaryNestedType { 21 int innerClassNameIndex = -1; 22 int outerClassNameIndex = -1; 23 int innerNameIndex = -1; 24 private char[] innerClassName; 25 private char[] outerClassName; 26 private char[] innerName; 27 private int accessFlags = -1; 28 private boolean readInnerClassName = false; 29 private boolean readOuterClassName = false; 30 private boolean readInnerName = false; 31 32 public InnerClassInfo(byte classFileBytes[], int offsets[], int offset) { 33 super(classFileBytes, offsets, offset); 34 this.innerClassNameIndex = u2At(0); 35 this.outerClassNameIndex = u2At(2); 36 this.innerNameIndex = u2At(4); 37 } 38 45 public char[] getEnclosingTypeName() { 46 if (!readOuterClassName) { 47 readOuterClassName = true; 49 if (outerClassNameIndex != 0) { 50 int utf8Offset = 51 constantPoolOffsets[u2At( 52 constantPoolOffsets[outerClassNameIndex] - structOffset + 1)] 53 - structOffset; 54 outerClassName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1)); 55 } 56 57 } 58 return outerClassName; 59 } 60 65 public int getModifiers() { 66 if (accessFlags == -1) { 67 accessFlags = u2At(6); 69 } 70 return accessFlags; 71 } 72 79 public char[] getName() { 80 if (!readInnerClassName) { 81 readInnerClassName = true; 83 if (innerClassNameIndex != 0) { 84 int classOffset = constantPoolOffsets[innerClassNameIndex] - structOffset; 85 int utf8Offset = constantPoolOffsets[u2At(classOffset + 1)] - structOffset; 86 innerClassName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1)); 87 } 88 } 89 return innerClassName; 90 } 91 97 public char[] getSourceName() { 98 if (!this.readInnerName) { 99 this.readInnerName = true; 100 if (innerNameIndex != 0) { 101 int utf8Offset = constantPoolOffsets[innerNameIndex] - structOffset; 102 innerName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1)); 103 } 104 } 105 return innerName; 106 } 107 111 public String toString() { 112 StringBuffer buffer = new StringBuffer (); 113 if (getName() != null) { 114 buffer.append(getName()); 115 } 116 buffer.append("\n"); if (getEnclosingTypeName() != null) { 118 buffer.append(getEnclosingTypeName()); 119 } 120 buffer.append("\n"); if (getSourceName() != null) { 122 buffer.append(getSourceName()); 123 } 124 return buffer.toString(); 125 } 126 130 void initialize() { 131 getModifiers(); 132 getName(); 133 getSourceName(); 134 getEnclosingTypeName(); 135 reset(); 136 } 137 } 138 | Popular Tags |