org.apache.bcel.classfile
Class Attribute
java.lang.Object
org.apache.bcel.classfile.Attribute
- Cloneable, Node, Serializable
public abstract class Attribute
extends java.lang.Object
implements Cloneable, Node, Serializable
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.
$Id: Attribute.java,v 1.8 2002/07/11 19:39:04 mdahm Exp $ConstantValue
, SourceFile
, Code
, Unknown
, ExceptionTable
, LineNumberTable
, LocalVariableTable
, InnerClasses
, Synthetic
, Deprecated
, Signature
length
protected int length
name_index
protected int name_index
Attribute
protected Attribute(byte tag,
int name_index,
int length,
ConstantPool constant_pool)
accept
public abstract void accept(Visitor v)
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.
- accept in interface Node
addAttributeReader
public static void addAttributeReader(String name,
AttributeReader r)
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.
name
- the name of the attribute as stored in the class filer
- the reader object
clone
public Object clone()
Use copy() if you want to have a deep copy(), i.e., with all references
copied correctly.
- shallow copy of this attribute
dump
public void dump(DataOutputStream file)
throws IOException
Dump attribute to file stream in binary format.
file
- Output file stream
getConstantPool
public final ConstantPool getConstantPool()
- Constant pool used by this object.
getLength
public final int getLength()
- Length of attribute field in bytes.
getNameIndex
public final int getNameIndex()
- Name index in constant pool of attribute name.
getTag
public final byte getTag()
- Tag of attribute, i.e., its type. Value may not be altered, thus
there is no setTag() method.
removeAttributeReader
public static void removeAttributeReader(String name)
Remove attribute reader
name
- the name of the attribute as stored in the class file
setConstantPool
public final void setConstantPool(ConstantPool constant_pool)
constant_pool
- Constant pool to be used for this object.
setLength
public final void setLength(int length)
setNameIndex
public final void setNameIndex(int name_index)
name_index
- of attribute.
toString
public String toString()