Package serp.bytecode
Class InnerClasses
- java.lang.Object
-
- serp.bytecode.Attributes
-
- serp.bytecode.Attribute
-
- serp.bytecode.InnerClasses
-
- All Implemented Interfaces:
BCEntity
,VisitAcceptor
public class InnerClasses extends Attribute
Attribute describing all referenced classes that are not package members. This includes all member interfaces and classes.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List
_innerClasses
-
Constructor Summary
Constructors Constructor Description InnerClasses(int nameIndex, Attributes owner)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acceptVisit(BCVisitor visit)
Accept a visit from aBCVisitor
, calling the appropriate methods to notify the visitor that it has entered this entity, and to provide it with the proper callbacks for each sub-entity owned by this one.InnerClass
addInnerClass()
Add an inner class.InnerClass
addInnerClass(java.lang.String name, java.lang.Class type, java.lang.Class owner)
Add an inner class.InnerClass
addInnerClass(java.lang.String name, java.lang.String type, java.lang.String owner)
Add an inner class.InnerClass
addInnerClass(java.lang.String name, BCClass type, BCClass owner)
Add an inner class.InnerClass
addInnerClass(InnerClass inner)
Import an inner class from another entity, or make a copy of one on this entity.void
clear()
Clear all inner classes from this entity.InnerClass
getInnerClass(java.lang.String name)
Return the inner class with the given name.InnerClass[]
getInnerClasses()
Return all referenced inner classes, or empty array if none.InnerClass[]
getInnerClasses(java.lang.String name)
Return all inner classes with the given name, or empty array if none.(package private) int
getLength()
Return the length of the bytecode representation of this attribute in bytes, excluding the name index.(package private) void
read(java.io.DataInput in, int length)
Read the attribute bytecode from the given stream, up to length bytes, excluding the name index.(package private) void
read(Attribute other)
Copy the information from the given attribute to this one.boolean
removeInnerClass(java.lang.String name)
Remove the inner class with the given name.boolean
removeInnerClass(InnerClass innerClass)
Remove the given inner class.void
setInnerClasses(InnerClass[] inners)
Set the inner class references for this class.(package private) void
write(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.Attribute
create, getAttributesHolder, getClassLoader, getName, getNameIndex, getOwner, getPool, getProject, invalidate, isValid
-
Methods inherited from class serp.bytecode.Attributes
addAttribute, addAttribute, clearAttributes, getAttribute, getAttributes, getAttributes, readAttributes, removeAttribute, removeAttribute, setAttributes, visitAttributes, writeAttributes
-
-
-
-
Constructor Detail
-
InnerClasses
InnerClasses(int nameIndex, Attributes owner)
-
-
Method Detail
-
getInnerClasses
public InnerClass[] getInnerClasses()
Return all referenced inner classes, or empty array if none.
-
getInnerClass
public InnerClass getInnerClass(java.lang.String name)
Return the inner class with the given name. If multiple inner classes share the name, which is returned is undefined. Use null to retrieve anonymous classes.
-
getInnerClasses
public InnerClass[] getInnerClasses(java.lang.String name)
Return all inner classes with the given name, or empty array if none. Use null to retrieve anonymous classes.
-
setInnerClasses
public void setInnerClasses(InnerClass[] inners)
Set the inner class references for this class. This method is useful when importing inner class references from another class.
-
addInnerClass
public InnerClass addInnerClass(InnerClass inner)
Import an inner class from another entity, or make a copy of one on this entity.- Returns:
- the newly added inner class
-
addInnerClass
public InnerClass addInnerClass()
Add an inner class.
-
addInnerClass
public InnerClass addInnerClass(java.lang.String name, java.lang.String type, java.lang.String owner)
Add an inner class.- Parameters:
name
- the simple name of the class, or null if anonymoustype
- the full class name of the inner classowner
- the declaring class, or null if not a member class
-
addInnerClass
public InnerClass addInnerClass(java.lang.String name, java.lang.Class type, java.lang.Class owner)
Add an inner class.- Parameters:
name
- the simple name of the class, or null if anonymoustype
- the class of the inner classowner
- the declaring class, or null if not a member class
-
addInnerClass
public InnerClass addInnerClass(java.lang.String name, BCClass type, BCClass owner)
Add an inner class.- Parameters:
name
- the simple name of the class, or null if anonymoustype
- the class of the inner classowner
- the declaring class, or null if not a member class
-
clear
public void clear()
Clear all inner classes from this entity.
-
removeInnerClass
public boolean removeInnerClass(java.lang.String name)
Remove the inner class with the given name. Use null for anonymous classes.- Returns:
- true if an inner class was removed, false otherwise
-
removeInnerClass
public boolean removeInnerClass(InnerClass innerClass)
Remove the given inner class. After being removed, the given inner class is invalid, and the result of any operations on it are undefined.- Returns:
- true if the inner class was removed, false otherwise
-
acceptVisit
public void acceptVisit(BCVisitor visit)
Description copied from interface:VisitAcceptor
Accept a visit from aBCVisitor
, calling the appropriate methods to notify the visitor that it has entered this entity, and to provide it with the proper callbacks for each sub-entity owned by this one.
-
getLength
int getLength()
Description copied from class:Attribute
Return the length of the bytecode representation of this attribute in bytes, excluding the name index.
-
read
void read(Attribute other)
Description copied from class:Attribute
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.IOException
Description copied from class:Attribute
Read the attribute bytecode from the given stream, up to length bytes, excluding the name index. Does nothing by default.
-
write
void write(java.io.DataOutput out, int length) throws java.io.IOException
Description copied from class:Attribute
Write the attribute bytecode to the given stream, up to length bytes, excluding the name index. Does nothing by default.
-
-