java.lang.Object
org.apache.bcel.classfile.AccessFlags
org.apache.bcel.generic.ClassGen
- All Implemented Interfaces:
- java.lang.Cloneable, java.io.Serializable
- public class ClassGen
- extends org.apache.bcel.classfile.AccessFlags
- implements java.lang.Cloneable
Template class for building up a java class. May be initialized with an
existing java class (file).
- Version:
- $Id: ClassGen.java 386056 2006-03-15 11:31:56Z tcurdt $
| Methods inherited from class org.apache.bcel.classfile.AccessFlags |
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 |
class_name
private java.lang.String class_name
super_class_name
private java.lang.String super_class_name
file_name
private java.lang.String file_name
class_name_index
private int class_name_index
superclass_name_index
private int superclass_name_index
major
private int major
minor
private int minor
cp
private ConstantPoolGen cp
field_vec
private java.util.List field_vec
method_vec
private java.util.List method_vec
attribute_vec
private java.util.List attribute_vec
interface_vec
private java.util.List interface_vec
_cmp
private static org.apache.bcel.util.BCELComparator _cmp
observers
private java.util.ArrayList observers
ClassGen
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)
- Convenience constructor to set up some important values initially.
ClassGen
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)
- Convenience constructor to set up some important values initially.
ClassGen
public ClassGen(org.apache.bcel.classfile.JavaClass clazz)
- Initialize with existing class.
getJavaClass
public org.apache.bcel.classfile.JavaClass getJavaClass()
addInterface
public void addInterface(java.lang.String name)
- Add an interface to this class, i.e., this class has to implement it.
removeInterface
public void removeInterface(java.lang.String name)
- Remove an interface from this class.
getMajor
public int getMajor()
setMajor
public void setMajor(int major)
- Set major version number of class file, default value is 45 (JDK 1.1)
setMinor
public void setMinor(int minor)
- Set minor version number of class file, default value is 3 (JDK 1.1)
getMinor
public int getMinor()
addAttribute
public void addAttribute(org.apache.bcel.classfile.Attribute a)
- Add an attribute to this class.
addMethod
public void addMethod(org.apache.bcel.classfile.Method m)
- Add a method to this class.
addEmptyConstructor
public void addEmptyConstructor(int access_flags)
- Convenience method.
Add an empty constructor to this class that does nothing but calling super().
addField
public void addField(org.apache.bcel.classfile.Field f)
- Add a field to this class.
containsField
public boolean containsField(org.apache.bcel.classfile.Field f)
containsField
public org.apache.bcel.classfile.Field containsField(java.lang.String name)
containsMethod
public org.apache.bcel.classfile.Method containsMethod(java.lang.String name,
java.lang.String signature)
removeAttribute
public void removeAttribute(org.apache.bcel.classfile.Attribute a)
- Remove an attribute from this class.
removeMethod
public void removeMethod(org.apache.bcel.classfile.Method m)
- Remove a method from this class.
replaceMethod
public void replaceMethod(org.apache.bcel.classfile.Method old,
org.apache.bcel.classfile.Method new_)
- Replace given method with new one. If the old one does not exist
add the new_ method to the class anyway.
replaceField
public void replaceField(org.apache.bcel.classfile.Field old,
org.apache.bcel.classfile.Field new_)
- Replace given field with new one. If the old one does not exist
add the new_ field to the class anyway.
removeField
public void removeField(org.apache.bcel.classfile.Field f)
- Remove a field to this class.
getClassName
public java.lang.String getClassName()
getSuperclassName
public java.lang.String getSuperclassName()
getFileName
public java.lang.String getFileName()
setClassName
public void setClassName(java.lang.String name)
setSuperclassName
public void setSuperclassName(java.lang.String name)
getMethods
public org.apache.bcel.classfile.Method[] getMethods()
setMethods
public void setMethods(org.apache.bcel.classfile.Method[] methods)
setMethodAt
public void setMethodAt(org.apache.bcel.classfile.Method method,
int pos)
getMethodAt
public org.apache.bcel.classfile.Method getMethodAt(int pos)
getInterfaceNames
public java.lang.String[] getInterfaceNames()
getInterfaces
public int[] getInterfaces()
getFields
public org.apache.bcel.classfile.Field[] getFields()
getAttributes
public org.apache.bcel.classfile.Attribute[] getAttributes()
getConstantPool
public ConstantPoolGen getConstantPool()
setConstantPool
public void setConstantPool(ConstantPoolGen constant_pool)
setClassNameIndex
public void setClassNameIndex(int class_name_index)
setSuperclassNameIndex
public void setSuperclassNameIndex(int superclass_name_index)
getSuperclassNameIndex
public int getSuperclassNameIndex()
getClassNameIndex
public int getClassNameIndex()
addObserver
public void addObserver(ClassObserver o)
- Add observer for this object.
removeObserver
public void removeObserver(ClassObserver o)
- Remove observer for this object.
update
public void update()
- Call notify() method on all observers. This method is not called
automatically whenever the state has changed, but has to be
called by the user after he has finished editing the object.
clone
public java.lang.Object clone()
- Description copied from class:
java.lang.Object
- This method may be called to create a new copy of the
Object. The typical behavior is as follows:
o == o.clone() is false
o.getClass() == o.clone().getClass()
is true
o.equals(o) is true
However, these are not strict requirements, and may
be violated if necessary. Of the three requirements, the
last is the most commonly violated, particularly if the
subclass does not override Object.equals(Object)>Object.equals(Object) 55 .
If the Object you call clone() on does not implement
java.lang.Cloneable (which is a placeholder interface), then
a CloneNotSupportedException is thrown. Notice that
Object does not implement Cloneable; this method exists
as a convenience for subclasses that do.
Object's implementation of clone allocates space for the
new Object using the correct class, without calling any
constructors, and then fills in all of the new field values
with the old field values. Thus, it is a shallow copy.
However, subclasses are permitted to make a deep copy.
All array types implement Cloneable, and override
this method as follows (it should never fail):
public Object clone()
{
try
{
super.clone();
}
catch (CloneNotSupportedException e)
{
throw new InternalError(e.getMessage());
}
}
getComparator
public static org.apache.bcel.util.BCELComparator getComparator()
setComparator
public static void setComparator(org.apache.bcel.util.BCELComparator comparator)
equals
public boolean equals(java.lang.Object obj)
- Return value as defined by given BCELComparator strategy.
By default two ClassGen objects are said to be equal when
their class names are equal.
hashCode
public int hashCode()
- Return value as defined by given BCELComparator strategy.
By default return the hashcode of the class name.