APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.org.apache.bcel.internal.classfile

public abstract Class Attribute

extends Object
implements Cloneable, Node
Class Inheritance
All Implemented Interfaces
com.sun.org.apache.bcel.internal.classfile.Node, java.lang.Cloneable
Known Direct Subclasses
com.sun.org.apache.bcel.internal.classfile.BootstrapMethods, com.sun.org.apache.bcel.internal.classfile.Code, com.sun.org.apache.bcel.internal.classfile.ConstantValue, com.sun.org.apache.bcel.internal.classfile.Deprecated, com.sun.org.apache.bcel.internal.classfile.EnclosingMethod, com.sun.org.apache.bcel.internal.classfile.ExceptionTable, com.sun.org.apache.bcel.internal.classfile.InnerClasses, com.sun.org.apache.bcel.internal.classfile.LineNumberTable, com.sun.org.apache.bcel.internal.classfile.LocalVariableTable, com.sun.org.apache.bcel.internal.classfile.LocalVariableTypeTable, com.sun.org.apache.bcel.internal.classfile.MethodParameters, com.sun.org.apache.bcel.internal.classfile.Module, com.sun.org.apache.bcel.internal.classfile.ModuleMainClass, com.sun.org.apache.bcel.internal.classfile.ModulePackages, com.sun.org.apache.bcel.internal.classfile.NestHost, com.sun.org.apache.bcel.internal.classfile.NestMembers, com.sun.org.apache.bcel.internal.classfile.ParameterAnnotations, com.sun.org.apache.bcel.internal.classfile.PMGClass, com.sun.org.apache.bcel.internal.classfile.Record, com.sun.org.apache.bcel.internal.classfile.Signature, com.sun.org.apache.bcel.internal.classfile.SourceFile, com.sun.org.apache.bcel.internal.classfile.StackMap, com.sun.org.apache.bcel.internal.classfile.Synthetic, com.sun.org.apache.bcel.internal.classfile.Unknown, com.sun.org.apache.bcel.internal.classfile.AnnotationDefault, com.sun.org.apache.bcel.internal.classfile.Annotations
Imports
java.io.DataInput, .DataInputStream, .DataOutputStream, .IOException, java.util.HashMap, .Map, com.sun.org.apache.bcel.internal.Const, com.sun.org.apache.bcel.internal.util.Args

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.
attribute_info {
  u2 attribute_name_index;
  u4 attribute_length;
  u1 info[attribute_length];
}
See Also
ConstantValue, SourceFile, Code, Unknown, ExceptionTable, LineNumberTable, LocalVariableTable, InnerClasses, Synthetic, Deprecated, Signature

Field Summary

Modifier and TypeField and Description
protected ConstantPool
constant_pool

Deprecated (since 6.0) will be made private; do not access directly, use getter/setter
private static final boolean
public static final 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
private static final Map<String, Object>
protected byte
tag

Deprecated (since 6.0) will be made private; do not access directly, use getter/setter

Constructor Summary

AccessConstructor and Description
protected
Attribute(final byte
tag.
tag
,
final int
u2 name index.
nameIndex
,
final int
u4 length.
length
,
final ConstantPool
constant pool.
constantPool
)

Constructs an instance.

Method Summary

Modifier and TypeMethod and Description
public abstract void
accept(Visitor
Visitor object
v
)

Redeclares com.sun.org.apache.bcel.internal.classfile.Node.accept.

Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.

public static void
addAttributeReader(final String
the name of the attribute as stored in the class file
name
,
final UnknownAttributeReader
the reader object
unknownAttributeReader
)

Add an Attribute reader capable of parsing (user-defined) attributes named "name".

public Object

Returns:

shallow copy of this attribute
clone
()

Overrides java.lang.Object.clone.

Use copy() if you want to have a deep copy(), i.e., with all references copied correctly.

public abstract Attribute
copy(ConstantPool
constant pool to save.
constantPool
)

Returns: deep copy of this attribute.

public void
dump(final DataOutputStream
Output file stream
file
)

Dumps attribute to file stream in binary format.

public final ConstantPool
getConstantPool()

Returns: Constant pool used by this object.

public final int
getLength()

Returns: Length of attribute field in bytes.

public String
getName()

Returns: Name of attribute

public final int
getNameIndex()

Returns: Name index in constant pool of attribute name.

public final byte
getTag()

Returns: Tag of attribute, i.e., its type.

protected static void
println(final String msg)

public static Attribute

Returns:

Attribute
readAttribute
(final DataInput
Input stream
dataInput
,
final ConstantPool
Array of constants
constantPool
)

Class method reads one attribute from the input data stream.

public static Attribute

Returns:

Attribute
readAttribute
(final DataInputStream
Input stream
dataInputStream
,
final ConstantPool
Array of constants
constantPool
)

Class method reads one attribute from the input data stream.

public static void
removeAttributeReader(final String
the name of the attribute as stored in the class file
name
)

Remove attribute reader

public final void
setConstantPool(final ConstantPool
Constant pool to be used for this object.
constantPool
)

public final void
setLength(final int
length in bytes.
length
)

public final void
setNameIndex(final int
of attribute.
nameIndex
)

public String

Returns:

attribute name.
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

constant_poolback to summary
protected ConstantPool constant_pool

Deprecated

(since 6.0) will be made private; do not access directly, use getter/setter

Annotations
@Deprecated
debugback to summary
private static final boolean debug
EMPTY_ARRAYback to summary
public static final Attribute[] EMPTY_ARRAY

Empty array.

Since
6.6.0
lengthback to summary
protected int length

Deprecated

(since 6.0) (since 6.0) will be made private; do not access directly, use getter/setter

Annotations
@Deprecated
name_indexback to summary
protected int name_index

Deprecated

(since 6.0) will be made private; do not access directly, use getter/setter

Annotations
@Deprecated
READERSback to summary
private static final Map<String, Object> READERS
tagback to summary
protected byte tag

Deprecated

(since 6.0) will be made private; do not access directly, use getter/setter

Annotations
@Deprecated

Constructor Detail

Attributeback to summary
protected Attribute(final byte tag, final int nameIndex, final int length, final ConstantPool constantPool)

Constructs an instance.

attribute_info {
  u2 attribute_name_index;
  u4 attribute_length;
  u1 info[attribute_length];
}
Parameters
tag:byte

tag.

nameIndex:int

u2 name index.

length:int

u4 length.

constantPool:ConstantPool

constant pool.

Method Detail

acceptback to summary
public abstract void accept(Visitor v)

Redeclares com.sun.org.apache.bcel.internal.classfile.Node.accept.

Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.

Parameters
v:Visitor

Visitor object

Annotations
@Override
addAttributeReaderback to summary
public static void addAttributeReader(final String name, final UnknownAttributeReader unknownAttributeReader)

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:String

the name of the attribute as stored in the class file

unknownAttributeReader:UnknownAttributeReader

the reader object

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Use copy() if you want to have a deep copy(), i.e., with all references copied correctly.

Returns:Object

shallow copy of this attribute

Annotations
@Override
copyback to summary
public abstract Attribute copy(ConstantPool constantPool)
Parameters
constantPool:ConstantPool

constant pool to save.

Returns:Attribute

deep copy of this attribute.

dumpback to summary
public void dump(final DataOutputStream file) throws IOException

Dumps attribute to file stream in binary format.

Parameters
file:DataOutputStream

Output file stream

Exceptions
IOException:
if an I/O error occurs.
getConstantPoolback to summary
public final ConstantPool getConstantPool()
Returns:ConstantPool

Constant pool used by this object.

See Also
ConstantPool
getLengthback to summary
public final int getLength()
Returns:int

Length of attribute field in bytes.

getNameback to summary
public String getName()
Returns:String

Name of attribute

Since
6.0
getNameIndexback to summary
public final int getNameIndex()
Returns:int

Name index in constant pool of attribute name.

getTagback to summary
public final byte getTag()
Returns:byte

Tag of attribute, i.e., its type. Value may not be altered, thus there is no setTag() method.

printlnback to summary
protected static void println(final String msg)
readAttributeback to summary
public static Attribute readAttribute(final DataInput dataInput, final ConstantPool constantPool) throws IOException

Class method reads one attribute from the input data stream. This method must not be accessible from the outside. It is called by the Field and Method constructor methods.

Parameters
dataInput:DataInput

Input stream

constantPool:ConstantPool

Array of constants

Returns:Attribute

Attribute

Exceptions
IOException:
if an I/O error occurs.
Since
6.0
See Also
Field, Method
readAttributeback to summary
public static Attribute readAttribute(final DataInputStream dataInputStream, final ConstantPool constantPool) throws IOException

Class method reads one attribute from the input data stream. This method must not be accessible from the outside. It is called by the Field and Method constructor methods.

Parameters
dataInputStream:DataInputStream

Input stream

constantPool:ConstantPool

Array of constants

Returns:Attribute

Attribute

Exceptions
IOException:
if an I/O error occurs.
See Also
Field, Method
removeAttributeReaderback to summary
public static void removeAttributeReader(final String name)

Remove attribute reader

Parameters
name:String

the name of the attribute as stored in the class file

setConstantPoolback to summary
public final void setConstantPool(final ConstantPool constantPool)
Parameters
constantPool:ConstantPool

Constant pool to be used for this object.

See Also
ConstantPool
setLengthback to summary
public final void setLength(final int length)
Parameters
length:int

length in bytes.

setNameIndexback to summary
public final void setNameIndex(final int nameIndex)
Parameters
nameIndex:int

of attribute.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

attribute name.

Annotations
@Override