1 11 package org.eclipse.jdt.internal.core.util; 12 13 import org.eclipse.jdt.core.util.ClassFormatException; 14 import org.eclipse.jdt.core.util.IConstantPool; 15 import org.eclipse.jdt.core.util.IConstantPoolConstant; 16 import org.eclipse.jdt.core.util.IConstantPoolEntry; 17 import org.eclipse.jdt.core.util.IInnerClassesAttributeEntry; 18 19 22 public class InnerClassesAttributeEntry 23 extends ClassFileStruct 24 implements IInnerClassesAttributeEntry { 25 26 private int innerClassNameIndex; 27 private int outerClassNameIndex; 28 private int innerNameIndex; 29 private char[] innerClassName; 30 private char[] outerClassName; 31 private char[] innerName; 32 private int accessFlags; 33 34 public InnerClassesAttributeEntry(byte classFileBytes[], IConstantPool constantPool, int offset) 35 throws ClassFormatException { 36 this.innerClassNameIndex = u2At(classFileBytes, 0, offset); 37 this.outerClassNameIndex = u2At(classFileBytes, 2, offset); 38 this.innerNameIndex = u2At(classFileBytes, 4, offset); 39 this.accessFlags = u2At(classFileBytes, 6, offset); 40 IConstantPoolEntry constantPoolEntry; 41 if (this.innerClassNameIndex != 0) { 42 constantPoolEntry = constantPool.decodeEntry(this.innerClassNameIndex); 43 if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) { 44 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); 45 } 46 this.innerClassName = constantPoolEntry.getClassInfoName(); 47 } 48 if (outerClassNameIndex != 0) { 49 constantPoolEntry = constantPool.decodeEntry(this.outerClassNameIndex); 50 if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) { 51 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); 52 } 53 this.outerClassName = constantPoolEntry.getClassInfoName(); 54 } 55 if (innerNameIndex != 0) { 56 constantPoolEntry = constantPool.decodeEntry(this.innerNameIndex); 57 if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) { 58 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); 59 } 60 this.innerName = constantPoolEntry.getUtf8Value(); 61 } 62 } 63 64 67 public int getAccessFlags() { 68 return this.accessFlags; 69 } 70 71 74 public char[] getInnerClassName() { 75 return this.innerClassName; 76 } 77 78 81 public int getInnerClassNameIndex() { 82 return this.innerClassNameIndex; 83 } 84 85 88 public char[] getInnerName() { 89 return this.innerName; 90 } 91 92 95 public int getInnerNameIndex() { 96 return this.innerNameIndex; 97 } 98 99 102 public char[] getOuterClassName() { 103 return this.outerClassName; 104 } 105 106 109 public int getOuterClassNameIndex() { 110 return this.outerClassNameIndex; 111 } 112 } 113 | Popular Tags |