public class ClassEditor
extends java.lang.Object
ClassInfo,
MethodEditor| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEBUG |
| Constructor and Description |
|---|
ClassEditor(EditorContext context,
ClassInfo classInfo)
Constructor.
|
ClassEditor(EditorContext context,
int modifiers,
java.lang.String className,
Type superType,
Type[] interfaces)
Creates a new
ClassEditor for editing a class (or
interface) from scratch. |
| Modifier and Type | Method and Description |
|---|---|
void |
addInterface(java.lang.Class interfaceClass)
Adds an interface of the given class to the set of interfaces that the
class implements.
|
void |
addInterface(Type interfaceType)
Adds an interface of a given Type to the set of interfaces that the class
implements.
|
ClassInfo |
classInfo()
Get the ClassInfo object representing the class that being edited.
|
void |
commit()
Commit any changes to the class since creation time.
|
void |
commitOnly(java.util.Set methods,
java.util.Set fields)
Commits only certain methods and fields.
|
ConstantPool |
constants()
Returns the constant pool for the class.
|
EditorContext |
context()
Obtain the EditorContext for this ClassEditor.
|
boolean |
equals(java.lang.Object o)
Two ClassEditors are equal if they edit the same class.
|
FieldInfo[] |
fields()
Returns an array of FieldInfo structures for each field in the
class.
|
int |
hashCode()
A ClassEditor's hash code is based upon the hash code of the
name of the class it edits.
|
Type[] |
interfaces()
Returns the interfaces the class implements.
|
boolean |
isAbstract() |
boolean |
isDirty()
Returns true if the class has been modified.
|
boolean |
isFinal() |
boolean |
isInterface() |
boolean |
isPrivate() |
boolean |
isProtected() |
boolean |
isPublic() |
boolean |
isStatic() |
boolean |
isSuper() |
MethodInfo[] |
methods()
Returns an array of MethodInfo structures for each method in the class.
|
int |
modifiers()
Returns the modifiers of the class.
|
java.lang.String |
name()
Returns the name of the class represented by this ClassEditor.
|
void |
setAbstract(boolean flag) |
void |
setDirty(boolean dirty)
Sets this class's dirty flag.
|
void |
setFinal(boolean flag) |
void |
setInterface(boolean flag) |
void |
setInterfaces(Type[] interfaces)
Returns the interfaces the class implements.
|
void |
setPrivate(boolean flag) |
void |
setProtected(boolean flag) |
void |
setPublic(boolean flag) |
void |
setStatic(boolean flag) |
void |
setSuper(boolean flag) |
void |
setSuperclass(Type newSuperclass) |
void |
setType(Type type)
Sets the Type (descriptor) object for the class.
|
Type |
superclass()
Returns a Type object for the class's superclass.
|
java.lang.String |
toString() |
Type |
type()
Returns the Type (descriptor) for the class.
|
void |
visit(EditorVisitor visitor)
This class is visited by an EditorVisitor.
|
public ClassEditor(EditorContext context, ClassInfo classInfo)
context - The EditorContext used to edit fields and methods.classInfo - The ClassInfo structure of the class to edit.ClassInfo,
ConstantPool,
Typepublic ClassEditor(EditorContext context, int modifiers, java.lang.String className, Type superType, Type[] interfaces)
ClassEditor for editing a class (or
interface) from scratch. This constructor should not be invoked direcly.
Use EditorContext.newClass(int, String, Type, Type[]) instead.public boolean isDirty()
public void setDirty(boolean dirty)
public java.lang.String name()
public EditorContext context()
public ClassInfo classInfo()
public boolean isPublic()
public boolean isPrivate()
public boolean isProtected()
public boolean isStatic()
public boolean isFinal()
public boolean isSuper()
public boolean isAbstract()
public boolean isInterface()
public void setPublic(boolean flag)
public void setPrivate(boolean flag)
public void setProtected(boolean flag)
public void setStatic(boolean flag)
public void setFinal(boolean flag)
public void setSuper(boolean flag)
public void setAbstract(boolean flag)
public void setInterface(boolean flag)
public void setType(Type type)
type - A Type.public Type type()
public Type superclass()
public void addInterface(java.lang.Class interfaceClass)
java.lang.IllegalArgumentException - interfaceClass is not an
interfacepublic void addInterface(Type interfaceType)
public void setInterfaces(Type[] interfaces)
interfaces - An array of Types.public Type[] interfaces()
public int modifiers()
Modifierspublic FieldInfo[] fields()
public MethodInfo[] methods()
public ConstantPool constants()
public void commit()
public void commitOnly(java.util.Set methods,
java.util.Set fields)
methods - Methods (MethodInfos) to commit. If null,
all methods are committed.fields - Fields (FieldInfos) to commit. If null,
all fields are committed.public void visit(EditorVisitor visitor)
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic void setSuperclass(Type newSuperclass)