Class Attribute
java.lang.Object
org.apache.bcel.classfile.Attribute
- All Implemented Interfaces:
Serializable, Cloneable, Node
- Direct Known Subclasses:
AnnotationDefault, Annotations, Code, ConstantValue, Deprecated, EnclosingMethod, ExceptionTable, InnerClasses, LineNumberTable, LocalVariableTable, LocalVariableTypeTable, ParameterAnnotations, PMGClass, Signature, SourceFile, StackMap, StackMapTable, Synthetic, Unknown
Abstract super class for Attribute objects. Currently the
ConstantValue, SourceFile, Code,
Exceptiontable, LineNumberTable,
LocalVariableTable, InnerClasses and
Synthetic attributes are supported. The Unknown
attribute stands for non-standard-attributes.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ConstantPoolprotected intprotected intprotected byte -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAttribute(byte tag, int name_index, int length, ConstantPool constant_pool) -
Method Summary
Modifier and TypeMethodDescriptionabstract voidCalled by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class.static voidaddAttributeReader(String name, AttributeReader r) Add an Attribute reader capable of parsing (user-defined) attributes named "name".clone()Use copy() if you want to have a deep copy(), i.e., with all references copied correctly.abstract Attributecopy(ConstantPool _constant_pool) voiddump(DataOutputStream file) Dump attribute to file stream in binary format.final ConstantPoolfinal intgetName()final intfinal bytegetTag()static final AttributereadAttribute(DataInputStream file, ConstantPool constant_pool) static voidremoveAttributeReader(String name) Remove attribute readerfinal voidsetConstantPool(ConstantPool constant_pool) final voidsetLength(int length) final voidsetNameIndex(int name_index) toString()
-
Field Details
-
name_index
protected int name_index -
length
protected int length -
tag
protected byte tag -
constant_pool
-
-
Constructor Details
-
Attribute
-
-
Method Details
-
accept
Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects. -
dump
Dump attribute to file stream in binary format.- Parameters:
file- Output file stream- Throws:
IOException
-
addAttributeReader
Add an Attribute reader capable of parsing (user-defined) attributes named "name". You should not add readers for the standard attributes such as "LineNumberTable", because those are handled internally.- Parameters:
name- the name of the attribute as stored in the class filer- the reader object
-
removeAttributeReader
Remove attribute reader- Parameters:
name- the name of the attribute as stored in the class file
-
readAttribute
public static final Attribute readAttribute(DataInputStream file, ConstantPool constant_pool) throws IOException, ClassFormatException - Throws:
IOExceptionClassFormatException
-
getName
- Returns:
- Name of attribute
-
getLength
public final int getLength()- Returns:
- Length of attribute field in bytes.
-
setLength
public final void setLength(int length) - Parameters:
length- length in bytes.
-
setNameIndex
public final void setNameIndex(int name_index) - Parameters:
name_index- of attribute.
-
getNameIndex
public final int getNameIndex()- Returns:
- Name index in constant pool of attribute name.
-
getTag
public final byte getTag()- Returns:
- Tag of attribute, i.e., its type. Value may not be altered, thus there is no setTag() method.
-
getConstantPool
- Returns:
- Constant pool used by this object.
- See Also:
-
setConstantPool
- Parameters:
constant_pool- Constant pool to be used for this object.- See Also:
-
clone
-
copy
- Returns:
- deep copy of this attribute
-
toString
-