org.apache.tapestry.enhance.javassist
Class ClassFabricator

java.lang.Object
  extended by org.apache.tapestry.enhance.javassist.ClassFabricator

public class ClassFabricator
extends Object

Since:
3.0
Version:
$Id: ClassFabricator.java 243791 2004-02-19 17:38:13Z hlship $
Author:
Mindbridge

Constructor Summary
ClassFabricator(String className, javassist.CtClass parentClass, javassist.ClassPool classPool)
           
 
Method Summary
 void addMethod(javassist.CtMethod method)
           
 String buildMethodName(String prefix, String propertyName)
          Constructs an accessor method name.
 void commit()
           
 javassist.CtMethod createAccessor(javassist.CtClass fieldType, String propertyName, String readMethodName)
           
 void createField(javassist.CtClass fieldType, String fieldName)
           
 void createField(javassist.CtClass fieldType, String fieldName, String init)
           
 javassist.CtMethod createMethod(javassist.CtClass returnType, String methodName, javassist.CtClass[] arguments)
           
 javassist.CtMethod createMutator(javassist.CtClass fieldType, String propertyName)
           
 void createPropertyAccessor(javassist.CtClass fieldType, String fieldName, String propertyName, String readMethodName)
          Creates an accessor (getter) method for the property.
 void createPropertyMutator(javassist.CtClass fieldType, String fieldName, String propertyName, boolean isPersistent)
          Creates a mutator (aka "setter") method.
 byte[] getByteCode()
           
 javassist.CtField getField(String fieldName)
           
 javassist.CtMethod getMethod(String name, String signature)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassFabricator

public ClassFabricator(String className,
                       javassist.CtClass parentClass,
                       javassist.ClassPool classPool)
Method Detail

getField

public javassist.CtField getField(String fieldName)

createField

public void createField(javassist.CtClass fieldType,
                        String fieldName)

createField

public void createField(javassist.CtClass fieldType,
                        String fieldName,
                        String init)

getMethod

public javassist.CtMethod getMethod(String name,
                                    String signature)

addMethod

public void addMethod(javassist.CtMethod method)
               throws javassist.CannotCompileException
Throws:
javassist.CannotCompileException

buildMethodName

public String buildMethodName(String prefix,
                              String propertyName)
Constructs an accessor method name.


createMethod

public javassist.CtMethod createMethod(javassist.CtClass returnType,
                                       String methodName,
                                       javassist.CtClass[] arguments)

createAccessor

public javassist.CtMethod createAccessor(javassist.CtClass fieldType,
                                         String propertyName,
                                         String readMethodName)

createPropertyAccessor

public void createPropertyAccessor(javassist.CtClass fieldType,
                                   String fieldName,
                                   String propertyName,
                                   String readMethodName)
Creates an accessor (getter) method for the property.

Parameters:
fieldType - the return type for the method
fieldName - the name of the field (not the name of the property)
propertyName - the name of the property (used to build the name of the method)
readMethodName - if not null, the name of the method to use

createMutator

public javassist.CtMethod createMutator(javassist.CtClass fieldType,
                                        String propertyName)

createPropertyMutator

public void createPropertyMutator(javassist.CtClass fieldType,
                                  String fieldName,
                                  String propertyName,
                                  boolean isPersistent)
Creates a mutator (aka "setter") method.

Parameters:
fieldType - type of field value (and type of parameter value)
fieldName - name of field (not property!)
propertyName - name of property (used to construct method name)
isPersistent - if true, adds a call to fireObservedChange()

commit

public void commit()

getByteCode

public byte[] getByteCode()