gnu.bytecode

Class Attribute

public abstract class Attribute extends 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(String name)
Create a new Attribute.
Method Summary
voidaddToFrontOf(AttrContainer container)
Add this to (the front of) of the specified attribute container.
voidassignConstants(ClassType cl)
Add any needed constant pool entries for this Attribute.
static voidassignConstants(AttrContainer container, ClassType cl)
Add any needed constant pool entries for all attributes in a container.
static intcount(AttrContainer container)
static Attributeget(AttrContainer container, String name)
Find an Attribute by name, in an attribute cointainer.
AttrContainergetContainer()
Return the Attribute container that contains this Attribute.
abstract intgetLength()
Return the length of the attribute in bytes.
static intgetLengthAll(AttrContainer container)
Return the length of all the attributes (with headers) in bytes.
StringgetName()
intgetNameIndex()
AttributegetNext()
Get the next Attribute belonging to getContainer().
booleanisSkipped()
Returns true if this attribute should be skipped on output.
voidprint(ClassTypeWriter dst)
voidsetContainer(AttrContainer container)
voidsetName(String name)
voidsetNameIndex(int index)
voidsetNext(Attribute next)
Set the next Attribute in the chain belonging to getContainer().
voidsetSkipped(boolean skip)
Iff skip, cause this attributed to be skipped on output.
voidsetSkipped()
Cause this attributed to be skipped on output.
abstract voidwrite(DataOutputStream dstr)
Write out the contents of the Attribute.
static voidwriteAll(AttrContainer container, DataOutputStream dstr)

Constructor Detail

Attribute

public Attribute(String name)
Create a new Attribute.

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

Method Detail

addToFrontOf

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

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.

count

public static int count(AttrContainer container)

get

public static Attribute get(AttrContainer container, 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.

getContainer

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

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.

getName

public final String getName()

getNameIndex

public final int getNameIndex()

getNext

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

isSkipped

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

print

public void print(ClassTypeWriter dst)

setContainer

public final void setContainer(AttrContainer container)

setName

public final void setName(String name)

setNameIndex

public final void setNameIndex(int index)

setNext

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

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.

write

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

writeAll

public static void writeAll(AttrContainer container, DataOutputStream dstr)