org.apache.bcel.classfile
Class Attribute
- java.lang.Object
-
- org.apache.bcel.classfile.Attribute
-
- All Implemented Interfaces:
- java.lang.Cloneable, Node
- Direct Known Subclasses:
- AnnotationDefault, Annotations, BootstrapMethods, Code, ConstantValue, Deprecated, EnclosingMethod, ExceptionTable, InnerClasses, LineNumberTable, LocalVariableTable, LocalVariableTypeTable, MethodParameters, Module, ModuleMainClass, ModulePackages, NestHost, NestMembers, ParameterAnnotations, PMGClass, Signature, SourceFile, StackMap, Synthetic, Unknown
public abstract class Attribute extends java.lang.Object implements java.lang.Cloneable, Node
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.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description abstract voidaccept(Visitor v)Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class.static voidaddAttributeReader(java.lang.String name, AttributeReader r)Deprecated.(6.0) UseaddAttributeReader(String, UnknownAttributeReader)insteadstatic voidaddAttributeReader(java.lang.String name, UnknownAttributeReader r)Add an Attribute reader capable of parsing (user-defined) attributes named "name".java.lang.Objectclone()Use copy() if you want to have a deep copy(), i.e., with all references copied correctly.abstract Attributecopy(ConstantPool _constant_pool)voiddump(java.io.DataOutputStream file)Dump attribute to file stream in binary format.ConstantPoolgetConstantPool()intgetLength()java.lang.StringgetName()intgetNameIndex()bytegetTag()static AttributereadAttribute(java.io.DataInput file, ConstantPool constant_pool)Class method reads one attribute from the input data stream.static AttributereadAttribute(java.io.DataInputStream file, ConstantPool constant_pool)Class method reads one attribute from the input data stream.static voidremoveAttributeReader(java.lang.String name)Remove attribute readervoidsetConstantPool(ConstantPool constant_pool)voidsetLength(int length)voidsetNameIndex(int name_index)java.lang.StringtoString()
-
-
-
Method Detail
-
addAttributeReader
@Deprecated public static void addAttributeReader(java.lang.String name, AttributeReader r)Deprecated. (6.0) UseaddAttributeReader(String, UnknownAttributeReader)insteadAdd 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
-
addAttributeReader
public static void addAttributeReader(java.lang.String name, UnknownAttributeReader 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.- Parameters:
name- the name of the attribute as stored in the class filer- the reader object
-
readAttribute
public static Attribute readAttribute(java.io.DataInput file, ConstantPool constant_pool) throws java.io.IOException, ClassFormatException
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:
file- Input streamconstant_pool- Array of constants- Returns:
- Attribute
- Throws:
java.io.IOExceptionClassFormatException- Since:
- 6.0
- See Also:
Field,Method
-
readAttribute
public static Attribute readAttribute(java.io.DataInputStream file, ConstantPool constant_pool) throws java.io.IOException, ClassFormatException
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:
file- Input streamconstant_pool- Array of constants- Returns:
- Attribute
- Throws:
java.io.IOExceptionClassFormatException- See Also:
Field,Method
-
removeAttributeReader
public static void removeAttributeReader(java.lang.String name)
Remove attribute reader- Parameters:
name- the name of the attribute as stored in the class file
-
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.
-
clone
public java.lang.Object clone()
Use copy() if you want to have a deep copy(), i.e., with all references copied correctly.- Overrides:
clonein classjava.lang.Object- Returns:
- shallow copy of this attribute
-
copy
public abstract Attribute copy(ConstantPool _constant_pool)
- Returns:
- deep copy of this attribute
-
dump
public void dump(java.io.DataOutputStream file) throws java.io.IOExceptionDump attribute to file stream in binary format.- Parameters:
file- Output file stream- Throws:
java.io.IOException
-
getConstantPool
public final ConstantPool getConstantPool()
- Returns:
- Constant pool used by this object.
- See Also:
ConstantPool
-
getLength
public final int getLength()
- Returns:
- Length of attribute field in bytes.
-
getName
public java.lang.String getName()
- Returns:
- Name of attribute
- Since:
- 6.0
-
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.
-
setConstantPool
public final void setConstantPool(ConstantPool constant_pool)
- Parameters:
constant_pool- Constant pool to be used for this object.- See Also:
ConstantPool
-
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.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- Returns:
- attribute name.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG