Package serp.bytecode
Class Attributes
- java.lang.Object
-
- serp.bytecode.Attributes
-
-
Constructor Summary
Constructors Constructor Description Attributes()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Attribute
addAttribute(java.lang.String name)
Add an attribute of the given type.Attribute
addAttribute(Attribute attr)
Import an attribute from another entity, or make a copy of one on this entity.void
clearAttributes()
Clear all attributes from this entity.Attribute
getAttribute(java.lang.String name)
Return the attribute with the given name.Attribute[]
getAttributes()
Return all the attributes owned by this entity.Attribute[]
getAttributes(java.lang.String name)
Return all attributes with the given name.(package private) abstract java.util.Collection
getAttributesHolder()
Return the collection used to hold the attributes of this entity.(package private) void
readAttributes(java.io.DataInput in)
Build the attribute list from the given stream.boolean
removeAttribute(java.lang.String name)
Remove all attributes with the given name from this entity.boolean
removeAttribute(Attribute attribute)
Remove the given attribute.void
setAttributes(Attribute[] attrs)
Set the attributes for this entity; this method is useful for importing all attributes from another entity.(package private) void
visitAttributes(BCVisitor visit)
Convenience method to be called by BCEntities when being visited by aBCVisitor
; this method will allow the visitor to visit all attributes of this entity.(package private) void
writeAttributes(java.io.DataOutput out)
Writes all the owned attributes to the given stream.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface serp.bytecode.BCEntity
getClassLoader, getPool, getProject, isValid
-
-
-
-
Method Detail
-
getAttributes
public Attribute[] getAttributes()
Return all the attributes owned by this entity.- Returns:
- all owned attributes, or empty array if none
-
getAttribute
public Attribute getAttribute(java.lang.String name)
Return the attribute with the given name. If multiple attributes share the name, which is returned is undefined.
-
getAttributes
public Attribute[] getAttributes(java.lang.String name)
Return all attributes with the given name.- Returns:
- the matching attributes, or empty array if none
-
setAttributes
public void setAttributes(Attribute[] attrs)
Set the attributes for this entity; this method is useful for importing all attributes from another entity. Set to null or empty array if none.
-
addAttribute
public Attribute addAttribute(Attribute attr)
Import an attribute from another entity, or make a copy of one on this entity.
-
addAttribute
public Attribute addAttribute(java.lang.String name)
Add an attribute of the given type.
-
clearAttributes
public void clearAttributes()
Clear all attributes from this entity.
-
removeAttribute
public boolean removeAttribute(java.lang.String name)
Remove all attributes with the given name from this entity.- Returns:
- true if an attribute was removed, false otherwise
-
removeAttribute
public boolean removeAttribute(Attribute attribute)
Remove the given attribute. After being removed, the attribute is invalid, and the result of any operations on it are undefined.- Returns:
- true if the attribute was removed, false otherwise
-
visitAttributes
void visitAttributes(BCVisitor visit)
Convenience method to be called by BCEntities when being visited by aBCVisitor
; this method will allow the visitor to visit all attributes of this entity.
-
readAttributes
void readAttributes(java.io.DataInput in) throws java.io.IOException
Build the attribute list from the given stream. Relies on the ability of attributes to read themselves, and requires access to the constant pool, which must already by read.- Throws:
java.io.IOException
-
writeAttributes
void writeAttributes(java.io.DataOutput out) throws java.io.IOException
Writes all the owned attributes to the given stream. Relies on the ability of attributes to write themselves.- Throws:
java.io.IOException
-
getAttributesHolder
abstract java.util.Collection getAttributesHolder()
Return the collection used to hold the attributes of this entity.
-
-