| java.lang.Object org.ow2.easybeans.enhancer.CommonClassGenerator
All known Subclasses: org.ow2.easybeans.enhancer.interceptors.EasyBeansInvocationContextGenerator, org.ow2.easybeans.enhancer.interceptors.InterceptorManagerGenerator,
CommonClassGenerator | abstract public class CommonClassGenerator implements Opcodes(Code) | | Class with useful routines for writing a class.
author: Florent Benoit |
Constructor Summary | |
public | CommonClassGenerator(ClassWriter cw) Creates a default class with useful routines for writing a class. |
Method Summary | |
protected void | addAttribute(int access, String name, String desc) Adds an attribute in the current classwriter.
Parameters: access - the field's access flags (see Opcodes). | protected void | addAttribute(int access, String name, String desc, Object value) Adds an attribute in the current classwriter.
Parameters: access - the field's access flags (see Opcodes). | public static void | addFieldGettersSetters(ClassVisitor cv, String beanClassName, String fieldName, Class clazz) Adds a field with its getters/setters. | public static void | addFieldGettersSetters(ClassVisitor cv, String beanClassName, String fieldName, String className) Adds a field with its getters/setters. | public static void | addNullGetter(ClassVisitor cv, String getterName, Class clazz) Adds a getter for a given fieldName. | public static void | addReturnType(Type type, MethodVisitor mv) Adds a return entry depending of the type value. | public static String | encodeArrayClassDesc(String className) Encodes an internal classname into an array descriptor. | public static String | encodeClassDesc(String className) Encodes an internal classname into a descriptor. | public ClassWriter | getCW() | public static int | putFieldLoadOpCode(int sortCode) Sends the OpCode used in an constructor to set the field. | public static void | returnsObject(Type returnType, MethodVisitor mv) Returns the object by casting it or return null if method is of void type. | public static void | transformObjectIntoPrimitive(Type type, MethodVisitor mv) If a type is one of the object type with something which could be linked to a primitive type, cast object into primitive. | public static void | transformPrimitiveIntoObject(Type type, MethodVisitor mv) If a type is one of the primitive object : boolean, int, long, etc, adds an instruction to transform type into an object. | public static void | visitClassType(Type type, MethodVisitor mv) Allow to access to a class.
ie, for int.class it will access to Integer.TYPE.
For objects, it only calls the Object. |
ARRAY_OBJECTS | final public static String ARRAY_OBJECTS(Code) | | Define an array of objects.
|
EASYBEANS_FACTORY | final public static String EASYBEANS_FACTORY(Code) | | Factory class (used to make the bean factory available).
|
GENERATED_CLASS_VERSION | final public static int GENERATED_CLASS_VERSION(Code) | | Version used for generated class.
|
JAVA_LANG_EXCEPTION | final public static String JAVA_LANG_EXCEPTION(Code) | | Defines java.lang.Exception class.
|
JAVA_LANG_OBJECT | final public static String JAVA_LANG_OBJECT(Code) | | Defines java.lang.Object class.
|
JAVA_LANG_REFLECT_METHOD | final public static String JAVA_LANG_REFLECT_METHOD(Code) | | Define java.lang.reflect.Method.
|
VOID_METHOD_JAVA_LANG_OBJECT | final public static String VOID_METHOD_JAVA_LANG_OBJECT(Code) | | Defines a void method with JAVA_LANG_OBJECT as parameter.
|
CommonClassGenerator | public CommonClassGenerator(ClassWriter cw)(Code) | | Creates a default class with useful routines for writing a class.
Parameters: cw - the class writer which will generate the class |
addAttribute | protected void addAttribute(int access, String name, String desc)(Code) | | Adds an attribute in the current classwriter.
Parameters: access - the field's access flags (see Opcodes). Thisparameter also indicates if the field is synthetic and/ordeprecated. Parameters: name - the field's name. Parameters: desc - the field's descriptor (see Type Type). |
addAttribute | protected void addAttribute(int access, String name, String desc, Object value)(Code) | | Adds an attribute in the current classwriter.
Parameters: access - the field's access flags (see Opcodes). Thisparameter also indicates if the field is synthetic and/ordeprecated. Parameters: name - the field's name. Parameters: desc - the field's descriptor (see Type Type). Parameters: value - the field's initial value. This parameter, which may benull if the field does not have an initial value, mustbe an Integer, a Float, a Long, aDouble or a String (for int,float, long or String fieldsrespectively). This parameter is only used for static fields.Its value is ignored for non static fields, which must beinitialized through bytecode instructions in constructors ormethods. |
addFieldGettersSetters | public static void addFieldGettersSetters(ClassVisitor cv, String beanClassName, String fieldName, Class clazz)(Code) | | Adds a field with its getters/setters.
Parameters: cv - the classvisitor to add field/methods Parameters: beanClassName - the name of the bean's class Parameters: fieldName - the name of the attribute Parameters: clazz - the class of the attribute. |
addFieldGettersSetters | public static void addFieldGettersSetters(ClassVisitor cv, String beanClassName, String fieldName, String className)(Code) | | Adds a field with its getters/setters.
Parameters: cv - the classvisitor to add field/methods Parameters: beanClassName - the name of the bean's class Parameters: fieldName - the name of the attribute Parameters: className - the className of the attribute. |
addNullGetter | public static void addNullGetter(ClassVisitor cv, String getterName, Class clazz)(Code) | | Adds a getter for a given fieldName. If the fieldName is null, it's return null.
Parameters: cv - the classvisitor to add the method Parameters: getterName - the name of the method Parameters: clazz - the class of the returned object. |
addReturnType | public static void addReturnType(Type type, MethodVisitor mv)(Code) | | Adds a return entry depending of the type value.
ie, for int : mv.visitInsn(IRETURN);
for void : mv.visitInsn(RETURN);
Parameters: type - the object that need to be processed Parameters: mv - the method visitor on which there is a need to adds an instruction |
encodeArrayClassDesc | public static String encodeArrayClassDesc(String className)(Code) | | Encodes an internal classname into an array descriptor.
Parameters: className - internal class name desc for the given className (array mode) |
encodeClassDesc | public static String encodeClassDesc(String className)(Code) | | Encodes an internal classname into a descriptor.
Parameters: className - internal class name desc for the given className |
getCW | public ClassWriter getCW()(Code) | | the class writer used by this generator |
putFieldLoadOpCode | public static int putFieldLoadOpCode(int sortCode)(Code) | | Sends the OpCode used in an constructor to set the field.
Parameters: sortCode - type of attribute to set op code |
returnsObject | public static void returnsObject(Type returnType, MethodVisitor mv)(Code) | | Returns the object by casting it or return null if method is of void type.
Parameters: returnType - the kind of return for this method. Parameters: mv - object on which we add the instruction. |
transformObjectIntoPrimitive | public static void transformObjectIntoPrimitive(Type type, MethodVisitor mv)(Code) | | If a type is one of the object type with something which could be linked to a primitive type, cast object into primitive.
ie : from Integer to int by calling ((Integer) object).intValue();
Parameters: type - the object that need to be processed Parameters: mv - the method visitor on which there is a need to adds an instruction |
transformPrimitiveIntoObject | public static void transformPrimitiveIntoObject(Type type, MethodVisitor mv)(Code) | | If a type is one of the primitive object : boolean, int, long, etc, adds an instruction to transform type into an object.
ie : from int to Integer by calling Integer.valueOf(i);
Parameters: type - the object that need to be processed Parameters: mv - the method visitor on which there is a need to adds an instruction |
visitClassType | public static void visitClassType(Type type, MethodVisitor mv)(Code) | | Allow to access to a class.
ie, for int.class it will access to Integer.TYPE.
For objects, it only calls the Object.
Parameters: type - the type of the object from which we want the class Parameters: mv - object on which we add the instruction |
|
|