com.go.trove.classfile
Class Attribute

java.lang.Object
  |
  +--com.go.trove.classfile.Attribute
Direct Known Subclasses:
CodeAttr

public abstract class Attribute
extends java.lang.Object

This class corresponds to the attribute_info structure defined in section 4.7 of The Java Virtual Machine Specification.

Version:
25 , 00/11/27
Author:
Brian S O'Neill
See Also:
ClassFile

Field Summary
protected  ConstantPool mCp
          The ConstantPool that this attribute is defined against.
 
Constructor Summary
protected Attribute(ConstantPool cp, java.lang.String name)
           
 
Method Summary
 Attribute[] getAttributes()
          Some attributes have sub-attributes.
 ConstantPool getConstantPool()
          Returns the ConstantPool that this attribute is defined against.
abstract  int getLength()
          Returns the length (in bytes) of this attribute in the class file.
 java.lang.String getName()
          Returns the name of this attribute.
 ConstantUTFInfo getNameConstant()
           
static Attribute readFrom(ConstantPool cp, java.io.DataInput din, AttributeFactory attrFactory)
           
 void writeDataTo(java.io.DataOutput dout)
          Write just the attribute specific data.
 void writeTo(java.io.DataOutput dout)
          This method writes the 16 bit name constant index followed by the 32 bit attribute length, followed by the attribute specific data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mCp

protected final ConstantPool mCp
The ConstantPool that this attribute is defined against.
Constructor Detail

Attribute

protected Attribute(ConstantPool cp,
                    java.lang.String name)
Method Detail

getConstantPool

public ConstantPool getConstantPool()
Returns the ConstantPool that this attribute is defined against.

getName

public java.lang.String getName()
Returns the name of this attribute.

getNameConstant

public ConstantUTFInfo getNameConstant()

getAttributes

public Attribute[] getAttributes()
Some attributes have sub-attributes. Default implementation returns an empty array.

getLength

public abstract int getLength()
Returns the length (in bytes) of this attribute in the class file.

writeTo

public final void writeTo(java.io.DataOutput dout)
                   throws java.io.IOException
This method writes the 16 bit name constant index followed by the 32 bit attribute length, followed by the attribute specific data.

writeDataTo

public void writeDataTo(java.io.DataOutput dout)
                 throws java.io.IOException
Write just the attribute specific data. The default implementation writes nothing.

readFrom

public static Attribute readFrom(ConstantPool cp,
                                 java.io.DataInput din,
                                 AttributeFactory attrFactory)
                          throws java.io.IOException
Parameters:
attrFactory - optional factory for reading custom attributes