harpoon.IR.RawClass
Class Attribute

java.lang.Object
  extended by harpoon.IR.RawClass.Attribute
Direct Known Subclasses:
AttributeCode, AttributeConstantValue, AttributeExceptions, AttributeInnerClasses, AttributeLineNumberTable, AttributeLocalVariableTable, AttributeSignature, AttributeSourceFile, AttributeSynthetic, AttributeUnknown

public abstract class Attribute
extends Object

Attributes are used in the ClassFile, field_info, method_info, and Code_attribute structures of the class file format. Attribute is the superclass of the different types of attribute information classes.

Version:
$Id: Attribute.java,v 1.4 2003/09/05 21:45:15 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>
See Also:
"The Java Virtual Machine Specification, section 4.7", ClassFile, FieldInfo, MethodInfo, AttributeCode

Field Summary
 int attribute_name_index
          The attribute_name_index must be a valid unsigned 16-bit index into the constant pool of the class.
protected  ClassFile parent
          ClassFile in which this attribute information is found.
 
Constructor Summary
protected Attribute(ClassFile p, int attribute_name_index)
          Constructor.
 
Method Summary
abstract  long attribute_length()
          The value of the attribute_length item indicates the length of the attribute, excluding the initial six bytes.
 ConstantUtf8 attribute_name_index()
           
 String attribute_name()
           
 void print(PrintWriter pw, int indent)
          Pretty-print this attribute structure.
static Attribute read(ClassFile parent, ClassDataInputStream in)
          Read an Attribute from a ClassDataInputStream.
 String toString()
          Create a human-readable representation for the Attribute.
abstract  void write(ClassDataOutputStream out)
          Write Attribute to bytecode file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

protected ClassFile parent
ClassFile in which this attribute information is found.


attribute_name_index

public int attribute_name_index
The attribute_name_index must be a valid unsigned 16-bit index into the constant pool of the class. The constant_pool entry at attribute_name_index must be a CONSTANT_Utf8 string representing the name of the attribute.

Constructor Detail

Attribute

protected Attribute(ClassFile p,
                    int attribute_name_index)
Constructor. Meant for use only by subclasses.

Method Detail

attribute_length

public abstract long attribute_length()
The value of the attribute_length item indicates the length of the attribute, excluding the initial six bytes.


read

public static Attribute read(ClassFile parent,
                             ClassDataInputStream in)
                      throws IOException
Read an Attribute from a ClassDataInputStream.

Throws:
IOException

write

public abstract void write(ClassDataOutputStream out)
                    throws IOException
Write Attribute to bytecode file.

Throws:
IOException

attribute_name_index

public ConstantUtf8 attribute_name_index()

attribute_name

public String attribute_name()

toString

public String toString()
Create a human-readable representation for the Attribute.

Overrides:
toString in class Object

print

public void print(PrintWriter pw,
                  int indent)
Pretty-print this attribute structure.