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.IClassFileAttribute; 15 import org.eclipse.jdt.core.util.IConstantPool; 16 import org.eclipse.jdt.core.util.IConstantPoolConstant; 17 import org.eclipse.jdt.core.util.IConstantPoolEntry; 18 19 22 public class ClassFileAttribute extends ClassFileStruct implements IClassFileAttribute { 23 public static final IClassFileAttribute[] NO_ATTRIBUTES = new IClassFileAttribute[0]; 24 private long attributeLength; 25 private int attributeNameIndex; 26 private char[] attributeName; 27 28 public ClassFileAttribute(byte[] classFileBytes, IConstantPool constantPool, int offset) throws ClassFormatException { 29 this.attributeNameIndex = u2At(classFileBytes, 0, offset); 30 this.attributeLength = u4At(classFileBytes, 2, offset); 31 IConstantPoolEntry constantPoolEntry = constantPool.decodeEntry(this.attributeNameIndex); 32 if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) { 33 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); 34 } 35 this.attributeName = constantPoolEntry.getUtf8Value(); 36 } 37 38 public int getAttributeNameIndex() { 39 return this.attributeNameIndex; 40 } 41 42 45 public char[] getAttributeName() { 46 return this.attributeName; 47 } 48 49 52 public long getAttributeLength() { 53 return this.attributeLength; 54 } 55 56 } 57 | Popular Tags |