org.aspectj.apache.bcel.generic
Class ClassGen

java.lang.Object
  extended by org.aspectj.apache.bcel.classfile.Modifiers
      extended by org.aspectj.apache.bcel.generic.ClassGen
All Implemented Interfaces:
java.lang.Cloneable

public class ClassGen
extends Modifiers
implements java.lang.Cloneable

Template class for building up a java class. May be initialized with an existing java class.

See Also:
JavaClass

Field Summary
 
Fields inherited from class org.aspectj.apache.bcel.classfile.Modifiers
modifiers
 
Constructor Summary
ClassGen(JavaClass clazz)
           
ClassGen(java.lang.String classname, java.lang.String superclassname, java.lang.String filename, int modifiers, java.lang.String[] interfacenames)
           
ClassGen(java.lang.String classname, java.lang.String superclassname, java.lang.String filename, int modifiers, java.lang.String[] interfacenames, ConstantPool cpool)
           
 
Method Summary
 void addAnnotation(AnnotationGen a)
           
 void addAttribute(Attribute a)
           
 void addEmptyConstructor(int access_flags)
          Convenience method.
 void addField(Field f)
          Add a field to this class.
 void addInterface(java.lang.String name)
           
 void addMethod(Method m)
           
 java.lang.Object clone()
           
 boolean containsField(Field f)
           
 Field containsField(java.lang.String name)
           
 Method containsMethod(java.lang.String name, java.lang.String signature)
           
 AnnotationGen[] getAnnotations()
           
 Attribute getAttribute(java.lang.String attributeName)
           
 java.util.Collection<Attribute> getAttributes()
           
 java.lang.String getClassName()
           
 int getClassNameIndex()
           
 ConstantPool 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()
           
 long getSUID()
          Calculate the SerialVersionUID for a class.
 java.lang.String getSuperclassName()
           
 int getSuperclassNameIndex()
           
 boolean hasAttribute(java.lang.String attributeName)
           
 boolean isAnnotation()
           
 boolean isEnum()
           
 void removeAnnotation(AnnotationGen a)
           
 void removeAttribute(Attribute a)
           
 void removeField(Field f)
           
 void removeInterface(java.lang.String name)
           
 void removeMethod(Method m)
           
 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)
           
 void setConstantPool(ConstantPool constant_pool)
           
 void setFields(Field[] fs)
           
 void setMajor(int major)
           
 void setMethodAt(Method method, int pos)
           
 void setMethods(Method[] methods)
           
 void setMinor(int minor)
           
 void setSuperclassName(java.lang.String name)
           
 void setSuperclassNameIndex(int superclass_name_index)
           
 
Methods inherited from class org.aspectj.apache.bcel.classfile.Modifiers
getModifiers, isAbstract, isBridge, isFinal, isInterface, isNative, isPrivate, isProtected, isPublic, isStatic, isStrictfp, isSynchronized, isTransient, isVarargs, isVolatile, setModifiers
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassGen

public ClassGen(java.lang.String classname,
                java.lang.String superclassname,
                java.lang.String filename,
                int modifiers,
                java.lang.String[] interfacenames,
                ConstantPool cpool)

ClassGen

public ClassGen(java.lang.String classname,
                java.lang.String superclassname,
                java.lang.String filename,
                int modifiers,
                java.lang.String[] interfacenames)

ClassGen

public ClassGen(JavaClass clazz)
Method Detail

getJavaClass

public JavaClass getJavaClass()
Returns:
build and return a JavaClass

addInterface

public void addInterface(java.lang.String name)

removeInterface

public void removeInterface(java.lang.String name)

getMajor

public int getMajor()

setMajor

public void setMajor(int major)

setMinor

public void setMinor(int minor)

getMinor

public int getMinor()

addAttribute

public void addAttribute(Attribute a)

addAnnotation

public void addAnnotation(AnnotationGen a)

addMethod

public void addMethod(Method m)

addEmptyConstructor

public void addEmptyConstructor(int access_flags)
Convenience method. Add an empty constructor to this class that does nothing but calling super().

Parameters:
access - rights for constructor

addField

public void addField(Field f)
Add a field to this class.

Parameters:
f - field to add

containsField

public boolean containsField(Field f)

containsField

public Field containsField(java.lang.String name)
Returns:
field object with given name, or null if not found

containsMethod

public Method containsMethod(java.lang.String name,
                             java.lang.String signature)
Returns:
method object with given name and signature, or null if not found

removeAttribute

public void removeAttribute(Attribute a)

removeAnnotation

public void removeAnnotation(AnnotationGen a)

removeMethod

public void removeMethod(Method m)

replaceMethod

public void replaceMethod(Method old,
                          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(Field old,
                         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(Field f)

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 Method[] getMethods()

setMethods

public void setMethods(Method[] methods)

setFields

public void setFields(Field[] fs)

setMethodAt

public void setMethodAt(Method method,
                        int pos)

getMethodAt

public Method getMethodAt(int pos)

getInterfaceNames

public java.lang.String[] getInterfaceNames()

getInterfaces

public int[] getInterfaces()

getFields

public Field[] getFields()

getAttributes

public java.util.Collection<Attribute> getAttributes()

getAnnotations

public AnnotationGen[] getAnnotations()

getConstantPool

public ConstantPool getConstantPool()

setConstantPool

public void setConstantPool(ConstantPool 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()

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

isAnnotation

public final boolean isAnnotation()

isEnum

public final boolean isEnum()

getSUID

public long getSUID()
Calculate the SerialVersionUID for a class.


hasAttribute

public boolean hasAttribute(java.lang.String attributeName)

getAttribute

public Attribute getAttribute(java.lang.String attributeName)