public class ClassGen extends AccessFlags implements java.lang.Cloneable
JavaClass
,
Serialized Formaccess_flags
Constructor and Description |
---|
ClassGen(JavaClass clazz)
Initialize with existing class.
|
ClassGen(java.lang.String class_name,
java.lang.String super_class_name,
java.lang.String file_name,
int access_flags,
java.lang.String[] interfaces)
Convenience constructor to set up some important values initially.
|
ClassGen(java.lang.String class_name,
java.lang.String super_class_name,
java.lang.String file_name,
int access_flags,
java.lang.String[] interfaces,
ConstantPoolGen cp)
Convenience constructor to set up some important values initially.
|
Modifier and Type | Method and Description |
---|---|
void |
addAnnotationEntry(AnnotationEntryGen a) |
void |
addAttribute(Attribute a)
Add an attribute to this class.
|
void |
addEmptyConstructor(int access_flags)
Convenience method.
|
void |
addField(Field f)
Add a field to this class.
|
void |
addInterface(java.lang.String name)
Add an interface to this class, i.e., this class has to implement it.
|
void |
addMethod(Method m)
Add a method to this class.
|
void |
addObserver(ClassObserver o)
Add observer for this object.
|
ClassGen |
clone() |
boolean |
containsField(Field f) |
Field |
containsField(java.lang.String name) |
Method |
containsMethod(java.lang.String name,
java.lang.String signature) |
boolean |
equals(java.lang.Object obj)
Return value as defined by given BCELComparator strategy.
|
AnnotationEntryGen[] |
getAnnotationEntries() |
Attribute[] |
getAttributes() |
java.lang.String |
getClassName() |
int |
getClassNameIndex() |
static BCELComparator |
getComparator() |
ConstantPoolGen |
getConstantPool() |
Field[] |
getFields() |
java.lang.String |
getFileName() |
java.lang.String[] |
getInterfaceNames() |
int[] |
getInterfaces() |
JavaClass |
getJavaClass() |
int |
getMajor() |
Method |
getMethodAt(int pos) |
Method[] |
getMethods() |
int |
getMinor() |
java.lang.String |
getSuperclassName() |
int |
getSuperclassNameIndex() |
int |
hashCode()
Return value as defined by given BCELComparator strategy.
|
void |
removeAttribute(Attribute a)
Remove an attribute from this class.
|
void |
removeField(Field f)
Remove a field to this class.
|
void |
removeInterface(java.lang.String name)
Remove an interface from this class.
|
void |
removeMethod(Method m)
Remove a method from this class.
|
void |
removeObserver(ClassObserver o)
Remove observer for this object.
|
void |
replaceField(Field old,
Field new_)
Replace given field with new one.
|
void |
replaceMethod(Method old,
Method new_)
Replace given method with new one.
|
void |
setClassName(java.lang.String name) |
void |
setClassNameIndex(int class_name_index) |
static void |
setComparator(BCELComparator comparator) |
void |
setConstantPool(ConstantPoolGen constant_pool) |
void |
setMajor(int major)
Set major version number of class file, default value is 45 (JDK 1.1)
|
void |
setMethodAt(Method method,
int pos) |
void |
setMethods(Method[] methods) |
void |
setMinor(int minor)
Set minor version number of class file, default value is 3 (JDK 1.1)
|
void |
setSuperclassName(java.lang.String name) |
void |
setSuperclassNameIndex(int superclass_name_index) |
void |
update()
Call notify() method on all observers.
|
getAccessFlags, getModifiers, isAbstract, isAbstract, isAnnotation, isAnnotation, isEnum, isEnum, isFinal, isFinal, isInterface, isInterface, isNative, isNative, isPrivate, isPrivate, isProtected, isProtected, isPublic, isPublic, isStatic, isStatic, isStrictfp, isStrictfp, isSynchronized, isSynchronized, isSynthetic, isSynthetic, isTransient, isTransient, isVolatile, isVolatile, setAccessFlags, setModifiers
public ClassGen(java.lang.String class_name, java.lang.String super_class_name, java.lang.String file_name, int access_flags, java.lang.String[] interfaces, ConstantPoolGen cp)
class_name
- fully qualified class namesuper_class_name
- fully qualified superclass namefile_name
- source file nameaccess_flags
- access qualifiersinterfaces
- implemented interfacescp
- constant pool to usepublic ClassGen(java.lang.String class_name, java.lang.String super_class_name, java.lang.String file_name, int access_flags, java.lang.String[] interfaces)
class_name
- fully qualified class namesuper_class_name
- fully qualified superclass namefile_name
- source file nameaccess_flags
- access qualifiersinterfaces
- implemented interfacespublic ClassGen(JavaClass clazz)
clazz
- JavaClass object (e.g. read from file)public JavaClass getJavaClass()
public void addInterface(java.lang.String name)
name
- interface to implement (fully qualified class name)public void removeInterface(java.lang.String name)
name
- interface to remove (fully qualified name)public int getMajor()
public void setMajor(int major)
major
- major version numberpublic void setMinor(int minor)
minor
- minor version numberpublic int getMinor()
public void addAttribute(Attribute a)
a
- attribute to addpublic void addAnnotationEntry(AnnotationEntryGen a)
public void addMethod(Method m)
m
- method to addpublic void addEmptyConstructor(int access_flags)
access_flags
- rights for constructorpublic void addField(Field f)
f
- field to addpublic boolean containsField(Field f)
public Field containsField(java.lang.String name)
public Method containsMethod(java.lang.String name, java.lang.String signature)
public void removeAttribute(Attribute a)
a
- attribute to removepublic void removeMethod(Method m)
m
- method to removepublic void replaceMethod(Method old, Method new_)
public void replaceField(Field old, Field new_)
public void removeField(Field f)
f
- field to removepublic java.lang.String getClassName()
public java.lang.String getSuperclassName()
public java.lang.String getFileName()
public void setClassName(java.lang.String name)
public void setSuperclassName(java.lang.String name)
public Method[] getMethods()
public void setMethods(Method[] methods)
public void setMethodAt(Method method, int pos)
public Method getMethodAt(int pos)
public java.lang.String[] getInterfaceNames()
public int[] getInterfaces()
public Field[] getFields()
public Attribute[] getAttributes()
public AnnotationEntryGen[] getAnnotationEntries()
public ConstantPoolGen getConstantPool()
public void setConstantPool(ConstantPoolGen constant_pool)
public void setClassNameIndex(int class_name_index)
public void setSuperclassNameIndex(int superclass_name_index)
public int getSuperclassNameIndex()
public int getClassNameIndex()
public void addObserver(ClassObserver o)
public void removeObserver(ClassObserver o)
public void update()
public ClassGen clone()
clone
in class java.lang.Object
public static BCELComparator getComparator()
public static void setComparator(BCELComparator comparator)
comparator
- Comparison strategy objectpublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
Object.equals(java.lang.Object)
public int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()