Package serp.bytecode
Class Attribute
- java.lang.Object
-
- serp.bytecode.Attributes
-
- serp.bytecode.Attribute
-
- All Implemented Interfaces:
BCEntity,VisitAcceptor
- Direct Known Subclasses:
Annotations,BootstrapMethods,Code,ConstantValue,Deprecated,Exceptions,InnerClasses,LineNumberTable,LocalTable,SourceFile,Synthetic,UnknownAttribute
public abstract class Attribute extends Attributes implements VisitAcceptor
In bytecode attributes are used to represent anything that is not part of the class structure. This includes the source file name, code of methods, the line number table, etc. All attributes contain at a minimum an immutable name that also determines the attribute's type.
-
-
Field Summary
Fields Modifier and Type Field Description private int_nameIndexprivate Attributes_owner
-
Constructor Summary
Constructors Constructor Description Attribute(int nameIndex, Attributes owner)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static Attributecreate(java.lang.String name, Attributes owner)Create an attribute of the appropriate type based on the the attribute name.(package private) java.util.CollectiongetAttributesHolder()Return the collection used to hold the attributes of this entity.java.lang.ClassLoadergetClassLoader()Return the class loader to use when loading related classes.(package private) intgetLength()Return the length of the bytecode representation of this attribute in bytes, excluding the name index.java.lang.StringgetName()Return the name of this attribute.intgetNameIndex()Return the index in theConstantPoolof theUTF8Entryholding the name of this attribute.AttributesgetOwner()Return theAttributesthat owns this attribute.ConstantPoolgetPool()Return the constant pool of the current class.ProjectgetProject()Return the project of the current class.(package private) voidinvalidate()Invalidate this attribute.booleanisValid()Return false if this entity has been removed from its parent; in this case the results of any operations on the entity are undefined.(package private) voidread(java.io.DataInput in, int length)Read the attribute bytecode from the given stream, up to length bytes, excluding the name index.(package private) voidread(Attribute other)Copy the information from the given attribute to this one.(package private) voidwrite(java.io.DataOutput out, int length)Write the attribute bytecode to the given stream, up to length bytes, excluding the name index.-
Methods inherited from class serp.bytecode.Attributes
addAttribute, addAttribute, clearAttributes, getAttribute, getAttributes, getAttributes, readAttributes, removeAttribute, removeAttribute, setAttributes, visitAttributes, writeAttributes
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface serp.bytecode.visitor.VisitAcceptor
acceptVisit
-
-
-
-
Field Detail
-
_nameIndex
private int _nameIndex
-
_owner
private Attributes _owner
-
-
Constructor Detail
-
Attribute
Attribute(int nameIndex, Attributes owner)
-
-
Method Detail
-
create
static Attribute create(java.lang.String name, Attributes owner)
Create an attribute of the appropriate type based on the the attribute name.
-
getOwner
public Attributes getOwner()
Return theAttributesthat owns this attribute. The entity might be aBCClass,BCField,BCMethod, or other attribute.
-
getNameIndex
public int getNameIndex()
Return the index in theConstantPoolof theUTF8Entryholding the name of this attribute.
-
getName
public java.lang.String getName()
Return the name of this attribute.
-
getProject
public Project getProject()
Description copied from interface:BCEntityReturn the project of the current class.- Specified by:
getProjectin interfaceBCEntity
-
getPool
public ConstantPool getPool()
Description copied from interface:BCEntityReturn the constant pool of the current class.
-
getClassLoader
public java.lang.ClassLoader getClassLoader()
Description copied from interface:BCEntityReturn the class loader to use when loading related classes.- Specified by:
getClassLoaderin interfaceBCEntity
-
isValid
public boolean isValid()
Description copied from interface:BCEntityReturn false if this entity has been removed from its parent; in this case the results of any operations on the entity are undefined.
-
getAttributesHolder
java.util.Collection getAttributesHolder()
Description copied from class:AttributesReturn the collection used to hold the attributes of this entity.- Specified by:
getAttributesHolderin classAttributes
-
invalidate
void invalidate()
Invalidate this attribute.
-
getLength
int getLength()
Return the length of the bytecode representation of this attribute in bytes, excluding the name index.
-
read
void read(Attribute other)
Copy the information from the given attribute to this one. Does nothing by default.
-
read
void read(java.io.DataInput in, int length) throws java.io.IOExceptionRead the attribute bytecode from the given stream, up to length bytes, excluding the name index. Does nothing by default.- Throws:
java.io.IOException
-
write
void write(java.io.DataOutput out, int length) throws java.io.IOExceptionWrite the attribute bytecode to the given stream, up to length bytes, excluding the name index. Does nothing by default.- Throws:
java.io.IOException
-
-