gnu.bytecode
Class Attribute

java.lang.Object
  extended by gnu.bytecode.Attribute
Direct Known Subclasses:
CodeAttr, ConstantValueAttr, ExceptionsAttr, InnerClassesAttr, LineNumbersAttr, LocalVarsAttr, MiscAttr, SourceDebugExtAttr, SourceFileAttr

public abstract class Attribute
extends java.lang.Object

Represents an Attribute of an AttrContainer.

Various sub-classses are used for standard attributes, or you can use MiscAttr for a generic attribute.


Constructor Summary
Attribute(java.lang.String name)
          Create a new Attribute.
 
Method Summary
 void addToFrontOf(AttrContainer container)
          Add this to (the front of) of the specified attribute container.
static void assignConstants(AttrContainer container, ClassType cl)
          Add any needed constant pool entries for all attributes in a container.
 void assignConstants(ClassType cl)
          Add any needed constant pool entries for this Attribute.
static int count(AttrContainer container)
           
static Attribute get(AttrContainer container, java.lang.String name)
          Find an Attribute by name, in an attribute cointainer.
 AttrContainer getContainer()
          Return the Attribute container that contains this Attribute.
abstract  int getLength()
          Return the length of the attribute in bytes.
static int getLengthAll(AttrContainer container)
          Return the length of all the attributes (with headers) in bytes.
 java.lang.String getName()
           
 int getNameIndex()
           
 Attribute getNext()
          Get the next Attribute belonging to getContainer().
 boolean isSkipped()
          Returns true if this attribute should be skipped on output.
 void print(ClassTypeWriter dst)
           
 void setContainer(AttrContainer container)
           
 void setName(java.lang.String name)
           
 void setNameIndex(int index)
           
 void setNext(Attribute next)
          Set the next Attribute in the chain belonging to getContainer().
 void setSkipped()
          Cause this attributed to be skipped on output.
 void setSkipped(boolean skip)
          Iff skip, cause this attributed to be skipped on output.
abstract  void write(java.io.DataOutputStream dstr)
          Write out the contents of the Attribute.
static void writeAll(AttrContainer container, java.io.DataOutputStream dstr)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Attribute

public Attribute(java.lang.String name)
Create a new Attribute.

Parameters:
name - - an interned String that names the Attribute.
Method Detail

getContainer

public final AttrContainer getContainer()
Return the Attribute container that contains this Attribute.


setContainer

public final void setContainer(AttrContainer container)

getNext

public final Attribute getNext()
Get the next Attribute belonging to getContainer().


setNext

public final void setNext(Attribute next)
Set the next Attribute in the chain belonging to getContainer().


addToFrontOf

public void addToFrontOf(AttrContainer container)
Add this to (the front of) of the specified attribute container.


isSkipped

public final boolean isSkipped()
Returns true if this attribute should be skipped on output.


setSkipped

public final void setSkipped(boolean skip)
Iff skip, cause this attributed to be skipped on output.


setSkipped

public final void setSkipped()
Cause this attributed to be skipped on output.


getName

public final java.lang.String getName()

setName

public final void setName(java.lang.String name)

getNameIndex

public final int getNameIndex()

setNameIndex

public final void setNameIndex(int index)

get

public static Attribute get(AttrContainer container,
                            java.lang.String name)
Find an Attribute by name, in an attribute cointainer.

Parameters:
container - the attribute container to search
name - the (interned) name of the attribute we are seeking
Returns:
the matching Attribute, or null if the search failed.

assignConstants

public void assignConstants(ClassType cl)
Add any needed constant pool entries for this Attribute. Overridden by sub-classes. Do any other cleanup needed before writing out a .class file.


assignConstants

public static void assignConstants(AttrContainer container,
                                   ClassType cl)
Add any needed constant pool entries for all attributes in a container. Do any other cleanup needed before writing out a .class file.


getLength

public abstract int getLength()
Return the length of the attribute in bytes. Does not include the 6-byte header (for the name_index and the length).


getLengthAll

public static int getLengthAll(AttrContainer container)
Return the length of all the attributes (with headers) in bytes.


write

public abstract void write(java.io.DataOutputStream dstr)
                    throws java.io.IOException
Write out the contents of the Attribute. Does not write the 6-byte attribute header.

Throws:
java.io.IOException

count

public static int count(AttrContainer container)

writeAll

public static void writeAll(AttrContainer container,
                            java.io.DataOutputStream dstr)
                     throws java.io.IOException
Throws:
java.io.IOException

print

public void print(ClassTypeWriter dst)