ej-technologies

org.gjt.jclasslib.structures
Class AbstractStructureWithAttributes

java.lang.Object
  extended byorg.gjt.jclasslib.structures.AbstractStructure
      extended byorg.gjt.jclasslib.structures.AbstractStructureWithAttributes
Direct Known Subclasses:
AttributeInfo, ClassFile, ClassMember

public abstract class AbstractStructureWithAttributes
extends AbstractStructure

Base class for all structures with attributes.

Version:
$Revision: 1.4 $ $Date: 2003/08/18 07:52:54 $
Author:
Ingo Kegel

Field Summary
protected  AttributeInfo[] attributes
          Attributes of this structure.
 
Fields inherited from class org.gjt.jclasslib.structures.AbstractStructure
classFile, debug, SYSTEM_PROPERTY_DEBUG
 
Constructor Summary
AbstractStructureWithAttributes()
           
 
Method Summary
 AttributeInfo findAttribute(Class attributeClass)
          Find an attribute of a certain class.
 AttributeInfo[] getAttributes()
          Get the attributes of this structure.
protected  int getTotalAttributesLength()
          Get the length of all attributes as a number of bytes.
protected  void readAttributes(DataInput in)
          Read the attributes of this structure from the given DataInput.
 void setAttributes(AttributeInfo[] attributes)
          Set the attributes of this structure.
protected  void writeAttributes(DataOutput out)
          Write the attributes of this structure to the given DataOutput.
 
Methods inherited from class org.gjt.jclasslib.structures.AbstractStructure
debug, getClassFile, getDebug, getLength, printAccessFlags, printAccessFlagsVerbose, printBytes, read, setClassFile, setDebug, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

attributes

protected AttributeInfo[] attributes
Attributes of this structure.

Constructor Detail

AbstractStructureWithAttributes

public AbstractStructureWithAttributes()
Method Detail

getAttributes

public AttributeInfo[] getAttributes()
Get the attributes of this structure.

Returns:
the attributes

setAttributes

public void setAttributes(AttributeInfo[] attributes)
Set the attributes of this structure.

Parameters:
attributes - the new attributes

findAttribute

public AttributeInfo findAttribute(Class attributeClass)
Find an attribute of a certain class.

Parameters:
attributeClass - the class of the attribute
Returns:
the found attribute, null if not found

readAttributes

protected void readAttributes(DataInput in)
                       throws InvalidByteCodeException,
                              IOException
Read the attributes of this structure from the given DataInput.

Excpects DataInput to be in JVM class file format and just before an attribute length field.

Parameters:
in - the DataInput from which to read
Throws:
InvalidByteCodeException - if the byte code is invalid
IOException - if an exception occurs with the DataInput

writeAttributes

protected void writeAttributes(DataOutput out)
                        throws InvalidByteCodeException,
                               IOException
Write the attributes of this structure to the given DataOutput.

The written bytes are in JVM class file format.

Parameters:
out - the DataOutput to which to write
Throws:
InvalidByteCodeException - if the structure is internally inconsistent
IOException - if an exception occurs with the DataOutput

getTotalAttributesLength

protected int getTotalAttributesLength()
Get the length of all attributes as a number of bytes.

Returns:
the length

ej-technologies