edu.wisc.cs.java
Class AttributeInfo

java.lang.Object
  |
  +--edu.wisc.cs.java.AttributeInfo
Direct Known Subclasses:
CodeAttribute

public class AttributeInfo
extends java.lang.Object

This class represents a genaric attribute in a Java classfile and is the super class of the specific attribute classes.


Field Summary
protected  byte[] attributeData
          An array of length num_bytes containing the attribute data.
protected  int name_index
          An index into the constant pool containing the name of this attribute.
protected  int num_bytes
          The number of bytes of data for this attribute.
 
Constructor Summary
protected AttributeInfo()
          A default constructor for sub-classes.
  AttributeInfo(java.io.DataInputStream in)
          Constructs a new attribute reading data from the given stream.
  AttributeInfo(int n_index, java.io.DataInputStream in)
          Constructs a new attribute reading data from the given stream with the given name index.
 
Method Summary
 int getNameIndex()
          Returns the constant pool index of the name of this attribute.
 int getSize()
          Returns the number of bytes necessary to represent this attribute including the six header bytes.
 void writeTo(java.io.DataOutputStream out)
          Writes an attribute to the specified stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name_index

protected int name_index
An index into the constant pool containing the name of this attribute.

num_bytes

protected int num_bytes
The number of bytes of data for this attribute.

attributeData

protected byte[] attributeData
An array of length num_bytes containing the attribute data.
Constructor Detail

AttributeInfo

protected AttributeInfo()
A default constructor for sub-classes.

AttributeInfo

public AttributeInfo(java.io.DataInputStream in)
              throws java.io.IOException
Constructs a new attribute reading data from the given stream.
Parameters:
in - the stream from which to read all attribute data.

AttributeInfo

public AttributeInfo(int n_index,
                     java.io.DataInputStream in)
              throws java.io.IOException
Constructs a new attribute reading data from the given stream with the given name index.
Parameters:
n_index - the index in the constant pool of the attribute name.
in - the stream from which to read all attribute data.
Method Detail

getSize

public int getSize()
Returns the number of bytes necessary to represent this attribute including the six header bytes.

getNameIndex

public int getNameIndex()
Returns the constant pool index of the name of this attribute.
Returns:
the constant pool index of the name of this attribute.

writeTo

public void writeTo(java.io.DataOutputStream out)
             throws java.io.IOException
Writes an attribute to the specified stream.
Parameters:
out - the destination stream to write data to.
Throws:
java.io.IOException - if there is a problem writing the attribute data.