Class ClassGen

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

public class ClassGen extends Modifiers implements Cloneable
Template class for building up a java class. May be initialized with an existing java class.
Version:
$Id: ClassGen.java,v 1.15 2009/09/15 19:40:14 aclement Exp $
Author:
M. Dahm Upgraded, Andy Clement 9th Mar 06 - calculates SUID
See Also:
JavaClass
  • Constructor Details

  • Method Details

    • getJavaClass

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

      public void addInterface​(String name)
    • removeInterface

      public void removeInterface​(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)
    • findsField

      public Field findsField​(String name)
      Returns:
      field object with given name, or null if not found
    • containsMethod

      public Method containsMethod​(String name, 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 String getClassName()
    • getSuperclassName

      public String getSuperclassName()
    • getFileName

      public String getFileName()
    • setClassName

      public void setClassName​(String name)
    • setSuperclassName

      public void setSuperclassName​(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 String[] getInterfaceNames()
    • getInterfaces

      public int[] getInterfaces()
    • getFields

      public Field[] getFields()
    • getAttributes

      public 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 Object clone()
      Overrides:
      clone in class 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​(String attributeName)
    • getAttribute

      public Attribute getAttribute​(String attributeName)