public abstract class Attribute extends Object implements Cloneable, Node
attribute_info { u2 attribute_name_index; u4 attribute_length; u1 info[attribute_length]; }
Modifier and Type | Field and Description |
---|---|
protected ConstantPool |
constant_pool
Deprecated.
(since 6.0) will be made private; do not access directly, use getter/setter
|
static Attribute[] |
EMPTY_ARRAY
Empty array.
|
protected int |
length
Deprecated.
(since 6.0) (since 6.0) will be made private; do not access directly, use getter/setter
|
protected int |
name_index
Deprecated.
(since 6.0) will be made private; do not access directly, use getter/setter
|
protected byte |
tag
Deprecated.
(since 6.0) will be made private; do not access directly, use getter/setter
|
Modifier | Constructor and Description |
---|---|
protected |
Attribute(byte tag,
int nameIndex,
int length,
ConstantPool constantPool)
Constructs an instance.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
accept(Visitor v)
Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
|
static void |
addAttributeReader(String name,
AttributeReader attributeReader)
Deprecated.
(6.0) Use
addAttributeReader(String, UnknownAttributeReader) instead |
static void |
addAttributeReader(String name,
UnknownAttributeReader unknownAttributeReader)
Add an Attribute reader capable of parsing (user-defined) attributes named "name".
|
Object |
clone()
Use copy() if you want to have a deep copy(), i.e., with all references copied correctly.
|
abstract Attribute |
copy(ConstantPool constantPool) |
void |
dump(DataOutputStream file)
Dumps attribute to file stream in binary format.
|
ConstantPool |
getConstantPool() |
int |
getLength() |
String |
getName() |
int |
getNameIndex() |
byte |
getTag() |
protected static void |
println(String msg) |
static Attribute |
readAttribute(DataInput dataInput,
ConstantPool constantPool)
Class method reads one attribute from the input data stream.
|
static Attribute |
readAttribute(DataInputStream dataInputStream,
ConstantPool constantPool)
Class method reads one attribute from the input data stream.
|
static void |
removeAttributeReader(String name)
Remove attribute reader
|
void |
setConstantPool(ConstantPool constantPool) |
void |
setLength(int length) |
void |
setNameIndex(int nameIndex) |
String |
toString() |
public static final Attribute[] EMPTY_ARRAY
@Deprecated protected int name_index
@Deprecated protected int length
@Deprecated protected byte tag
@Deprecated protected ConstantPool constant_pool
protected Attribute(byte tag, int nameIndex, int length, ConstantPool constantPool)
attribute_info { u2 attribute_name_index; u4 attribute_length; u1 info[attribute_length]; }
tag
- tag.nameIndex
- u2 name index.length
- u4 length.constantPool
- constant pool.@Deprecated public static void addAttributeReader(String name, AttributeReader attributeReader)
addAttributeReader(String, UnknownAttributeReader)
insteadname
- the name of the attribute as stored in the class fileattributeReader
- the reader objectpublic static void addAttributeReader(String name, UnknownAttributeReader unknownAttributeReader)
name
- the name of the attribute as stored in the class fileunknownAttributeReader
- the reader objectprotected static void println(String msg)
public static Attribute readAttribute(DataInput dataInput, ConstantPool constantPool) throws IOException
dataInput
- Input streamconstantPool
- Array of constantsIOException
- if an I/O error occurs.Field
,
Method
public static Attribute readAttribute(DataInputStream dataInputStream, ConstantPool constantPool) throws IOException
dataInputStream
- Input streamconstantPool
- Array of constantsIOException
- if an I/O error occurs.Field
,
Method
public static void removeAttributeReader(String name)
name
- the name of the attribute as stored in the class filepublic abstract void accept(Visitor v)
public Object clone()
public abstract Attribute copy(ConstantPool constantPool)
constantPool
- constant pool to save.public void dump(DataOutputStream file) throws IOException
file
- Output file streamIOException
- if an I/O error occurs.public final ConstantPool getConstantPool()
ConstantPool
public final int getLength()
public String getName()
public final int getNameIndex()
public final byte getTag()
public final void setConstantPool(ConstantPool constantPool)
constantPool
- Constant pool to be used for this object.ConstantPool
public final void setLength(int length)
length
- length in bytes.public final void setNameIndex(int nameIndex)
nameIndex
- of attribute.Copyright © 2004–2024 The Apache Software Foundation. All rights reserved.