Package gnu.bytecode
Class Attribute
java.lang.Object
gnu.bytecode.Attribute
- Direct Known Subclasses:
AnnotationDefaultAttr,CodeAttr,ConstantValueAttr,EnclosingMethodAttr,ExceptionsAttr,InnerClassesAttr,LineNumbersAttr,LocalVarsAttr,MiscAttr,RuntimeAnnotationsAttr,SignatureAttr,SourceDebugExtAttr,SourceFileAttr
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToFrontOf(AttrContainer container) Add this to (the front of) of the specified attribute container.static voidassignConstants(AttrContainer container, ClassType cl) Add any needed constant pool entries for all attributes in a container.voidAdd any needed constant pool entries for this Attribute.static intcount(AttrContainer container) static Attributeget(AttrContainer container, String name) Find an Attribute by name, in an attribute cointainer.final AttrContainerReturn the Attribute container that contains this Attribute.abstract intReturn the length of the attribute in bytes.static intgetLengthAll(AttrContainer container) Return the length of all the attributes (with headers) in bytes.final StringgetName()final intfinal AttributegetNext()Get the next Attribute belonging to getContainer().final booleanReturns true if this attribute should be skipped on output.voidprint(ClassTypeWriter dst) final voidsetContainer(AttrContainer container) final voidfinal voidsetNameIndex(int index) final voidSet the next Attribute in the chain belonging to getContainer().final voidCause this attributed to be skipped on output.final voidsetSkipped(boolean skip) Iff skip, 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 Details
-
Attribute
Create a new Attribute.- Parameters:
name- - an interned String that names the Attribute.
-
-
Method Details
-
getContainer
Return the Attribute container that contains this Attribute. -
setContainer
-
getNext
Get the next Attribute belonging to getContainer(). -
setNext
Set the next Attribute in the chain belonging to getContainer(). -
getConstants
-
addToFrontOf
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
-
setName
-
getNameIndex
public final int getNameIndex() -
setNameIndex
public final void setNameIndex(int index) -
get
Find an Attribute by name, in an attribute cointainer.- Parameters:
container- the attribute container to searchname- the (interned) name of the attribute we are seeking- Returns:
- the matching Attribute, or null if the search failed.
-
assignConstants
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
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
Return the length of all the attributes (with headers) in bytes. -
write
Write out the contents of the Attribute. Does not write the 6-byte attribute header.- Throws:
IOException
-
count
-
writeAll
- Throws:
IOException
-
print
-