Package org.apache.openjpa.enhance
Class DynamicStorageGenerator
- java.lang.Object
-
- org.apache.openjpa.enhance.DynamicStorageGenerator
-
- Direct Known Subclasses:
PCDataGenerator
public class DynamicStorageGenerator extends Object
Factory for creating newDynamicStorageclasses. Can be extended to decorate/modify the generated instances behavior.- Since:
- 0.3.2.0
- Author:
- Steve Kim, Mark Struberg rework to ASM
-
-
Field Summary
Fields Modifier and Type Field Description protected static intPOLICY_EMPTYConstant to not generate type set/get methods.protected static intPOLICY_EXCEPTIONConstant to throw an exception on invalid index passed to type set/get methodsprotected static intPOLICY_SILENTConstant to be as silent as possible during invalid index passed to set/get type methods.
-
Constructor Summary
Constructors Constructor Description DynamicStorageGenerator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.apache.xbean.asm9.tree.FieldNodeaddBeanField(ClassNodeTracker bc, String name, Class type)Add a bean field of the given name and type.protected DynamicStoragecreateFactory(ClassNodeTracker bc)Create a stub factory instance for the given class.protected voiddeclareClasses(ClassNodeTracker bc)Add interface or superclass declarations to the generated class.protected voiddecorate(Object obj, ClassNodeTracker cls, int[] types)Decorate the generated class.protected ClassforType(int type)Return the proper type for the givenJavaTypesconstant.DynamicStoragegenerateStorage(int[] types, Object obj)Generate a genericDynamicStorageinstance with the given array ofJavaTypesconstants and the given object as the user key for generation.protected StringgetClassName(Object obj)Return a class name to use for the given user key.protected intgetCreateFieldMethods(int type)Return the policy constant for how to create type methods.protected intgetFieldAccess()Return the default field ACCESS constant for generated fields fromOpcodes.protected StringgetFieldName(int index)Return the name for the generated field at the given index.protected ClassgetWrapper(int type)get the wrapper for the givenJavaTypesconstant.protected ClassgetWrapper(Class c)Get the wrapper for the given type.protected booleanisCompatible(int fieldType, int storageType)Return true if the given field type and storage type are compatible.
-
-
-
Field Detail
-
POLICY_EXCEPTION
protected static final int POLICY_EXCEPTION
Constant to throw an exception on invalid index passed to type set/get methods- See Also:
- Constant Field Values
-
POLICY_EMPTY
protected static final int POLICY_EMPTY
Constant to not generate type set/get methods.- See Also:
- Constant Field Values
-
POLICY_SILENT
protected static final int POLICY_SILENT
Constant to be as silent as possible during invalid index passed to set/get type methods. On getting an Object, for example, null will be returned. However, on primitive gets, an exception will be thrown.- See Also:
- Constant Field Values
-
-
Method Detail
-
generateStorage
public DynamicStorage generateStorage(int[] types, Object obj)
Generate a genericDynamicStorageinstance with the given array ofJavaTypesconstants and the given object as the user key for generation.
-
getClassName
protected String getClassName(Object obj)
Return a class name to use for the given user key. By default, returns the stringified key prefixed by PREFIX.
-
getFieldAccess
protected int getFieldAccess()
Return the default field ACCESS constant for generated fields fromOpcodes.
-
getFieldName
protected String getFieldName(int index)
Return the name for the generated field at the given index. Returns"field" + iby default.
-
getCreateFieldMethods
protected int getCreateFieldMethods(int type)
Return the policy constant for how to create type methods.
-
decorate
protected void decorate(Object obj, ClassNodeTracker cls, int[] types)
Decorate the generated class.
-
createFactory
protected DynamicStorage createFactory(ClassNodeTracker bc)
Create a stub factory instance for the given class.
-
declareClasses
protected void declareClasses(ClassNodeTracker bc)
Add interface or superclass declarations to the generated class.
-
addBeanField
protected org.apache.xbean.asm9.tree.FieldNode addBeanField(ClassNodeTracker bc, String name, Class type)
Add a bean field of the given name and type.
-
isCompatible
protected boolean isCompatible(int fieldType, int storageType)Return true if the given field type and storage type are compatible.
-
-