Package org.apache.openjpa.enhance
Class DynamicStorageGenerator
java.lang.Object
org.apache.openjpa.enhance.DynamicStorageGenerator
- Direct Known Subclasses:
PCDataGenerator
Factory for creating new
DynamicStorage
classes. 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
Modifier and TypeFieldDescriptionprotected static final int
Constant to not generate type set/get methods.protected static final int
Constant to throw an exception on invalid index passed to type set/get methodsprotected static final int
Constant to be as silent as possible during invalid index passed to set/get type methods. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.xbean.asm9.tree.FieldNode
addBeanField
(ClassNodeTracker bc, String name, Class type) Add a bean field of the given name and type.protected DynamicStorage
Create a stub factory instance for the given class.protected void
Add interface or superclass declarations to the generated class.protected void
decorate
(Object obj, ClassNodeTracker cls, int[] types) Decorate the generated class.protected Class
forType
(int type) Return the proper type for the givenJavaTypes
constant.generateStorage
(int[] types, Object obj) Generate a genericDynamicStorage
instance with the given array ofJavaTypes
constants and the given object as the user key for generation.protected String
getClassName
(Object obj) Return a class name to use for the given user key.protected int
getCreateFieldMethods
(int type) Return the policy constant for how to create type methods.protected int
Return the default field ACCESS constant for generated fields fromOpcodes
.protected String
getFieldName
(int index) Return the name for the generated field at the given index.protected Class
getWrapper
(int type) get the wrapper for the givenJavaTypes
constant.protected Class
getWrapper
(Class c) Get the wrapper for the given type.protected boolean
isCompatible
(int fieldType, int storageType) Return true if the given field type and storage type are compatible.
-
Field Details
-
POLICY_EXCEPTION
protected static final int POLICY_EXCEPTIONConstant to throw an exception on invalid index passed to type set/get methods- See Also:
-
POLICY_EMPTY
protected static final int POLICY_EMPTYConstant to not generate type set/get methods.- See Also:
-
POLICY_SILENT
protected static final int POLICY_SILENTConstant 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:
-
-
Constructor Details
-
DynamicStorageGenerator
public DynamicStorageGenerator()
-
-
Method Details
-
generateStorage
Generate a genericDynamicStorage
instance with the given array ofJavaTypes
constants and the given object as the user key for generation. -
getClassName
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
Return the name for the generated field at the given index. Returns"field" + i
by default. -
getCreateFieldMethods
protected int getCreateFieldMethods(int type) Return the policy constant for how to create type methods. -
decorate
Decorate the generated class. -
createFactory
Create a stub factory instance for the given class. -
declareClasses
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. -
forType
Return the proper type for the givenJavaTypes
constant. -
getWrapper
get the wrapper for the givenJavaTypes
constant. -
getWrapper
Get the wrapper for the given type.
-