MappingLoader
JDOMappingLoader
, XMLMappingLoader
public abstract class AbstractMappingLoader extends AbstractMappingLoader2
Modifier and Type | Class | Description |
---|---|---|
class |
AbstractMappingLoader.TypeInfoReference |
A class used to by the createFieldHandler method in order to
save the reference of the TypeInfo that was used.
|
Modifier and Type | Field | Description |
---|---|---|
protected static java.lang.Class<?>[] |
EMPTY_ARGS |
Empty array of class types used for reflection.
|
protected static java.lang.String |
NAME |
Method name to get string value of a type-safe enumerations.
|
protected static java.lang.Class<?>[] |
STRING_ARG |
The string argument for the valueOf method, used for introspection when searching for
type-safe enumeration style classes.
|
protected static java.lang.String |
VALUE_OF |
Factory method name for type-safe enumerations.
|
Modifier | Constructor | Description |
---|---|---|
protected |
AbstractMappingLoader(java.lang.ClassLoader loader) |
Constructs a new mapping helper.
|
Modifier and Type | Method | Description |
---|---|---|
protected void |
checkFieldNameDuplicates(FieldDescriptor[] fields,
java.lang.Class<?> cls) |
Checks all given fields for name equality and throws a MappingException if at
least two fields have the same name.
|
protected abstract ClassDescriptor |
createClassDescriptor(ClassMapping clsMap) |
|
protected void |
createClassDescriptors(MappingRoot mapping) |
|
protected FieldDescriptorImpl |
createFieldDesc(java.lang.Class<?> javaClass,
FieldMapping fieldMap) |
Creates a single field descriptor.
|
protected FieldDescriptorImpl[] |
createFieldDescriptors(ClassMapping clsMap,
java.lang.Class<?> javaClass) |
Create field descriptors.
|
protected FieldHandler |
createFieldHandler(java.lang.Class<?> javaClass,
java.lang.Class<?> fldType,
FieldMapping fldMap,
AbstractMappingLoader.TypeInfoReference typeInfoRef) |
Creates the FieldHandler for the given FieldMapping.
|
protected void |
createFieldHandlers(MappingRoot mapping) |
Load field handler definitions, check for duplicate definitions and
instantiate the appropriate FieldHandler implementations.
|
protected FieldDescriptor[] |
divideFieldDescriptors(FieldDescriptor[] fields,
java.lang.String[] ids,
FieldDescriptor[] identities) |
|
static java.lang.reflect.Method |
findAccessor(java.lang.Class<?> javaClass,
java.lang.String methodName,
java.lang.Class<?> fieldType,
boolean getMethod) |
Returns the named accessor.
|
protected ClassDescriptor |
getDepended(ClassMapping clsMap,
java.lang.Class<?> javaClass) |
Gets the ClassDescriptor the given
classMapping depends
on. |
protected ClassDescriptor |
getExtended(ClassMapping clsMap,
java.lang.Class<?> javaClass) |
Gets the ClassDescriptor the given
classMapping extends. |
protected int |
getIdColumnIndex(FieldDescriptor field,
java.lang.String[] ids) |
Finds the index in the given
idColumnNames that has the same name as
the given field . |
static java.lang.String[] |
getIdentityColumnNames(java.lang.String[] ids,
ClassMapping clsMap) |
Returns a list of column names that are part of the identity.
|
InternalContext |
getInternalContext() |
|
protected ClassMapping |
getOrigin(ClassMapping clsMap) |
Gets the top-most (i.e.
|
java.lang.String |
getSourceType() |
|
protected TypeInfo |
getTypeInfo(java.lang.Class<?> fieldType,
CollectionHandler colHandler,
FieldMapping fieldMap) |
|
protected static boolean |
isPrimitive(java.lang.Class<?> type) |
Returns true if the given class should be treated as a primitive
type
|
abstract void |
loadMapping(MappingRoot mapping,
java.lang.Object param) |
Loads the mapping from the specified mapping object if not loaded previously.
|
protected abstract void |
resolveRelations(ClassDescriptor clsDesc) |
|
protected java.lang.Class<?> |
resolveType(java.lang.String typeName) |
Returns the Java class for the named type.
|
void |
setInternalContext(InternalContext internalContext) |
addDescriptor, clear, getClassLoader, getDescriptor, getDescriptors, isAllowRedefinition, loadMapping, setAllowRedefinitions, setClassLoader
getBindingType
protected static final java.lang.Class<?>[] EMPTY_ARGS
protected static final java.lang.Class<?>[] STRING_ARG
protected static final java.lang.String VALUE_OF
protected static final java.lang.String NAME
protected AbstractMappingLoader(java.lang.ClassLoader loader)
loader
- The class loader to use, null for the defaultpublic final java.lang.String getSourceType()
public abstract void loadMapping(MappingRoot mapping, java.lang.Object param) throws MappingException
mapping
- The mapping information.param
- Arbitrary parameter that can be used by subclasses.MappingException
- The mapping file is invalid.protected void createFieldHandlers(MappingRoot mapping) throws MappingException
mapping
- Mapping to load field handler definitions from.MappingException
- If mapping contains more then one field handler
definition with same name.protected final void createClassDescriptors(MappingRoot mapping) throws MappingException
MappingException
protected abstract ClassDescriptor createClassDescriptor(ClassMapping clsMap) throws MappingException
MappingException
protected final ClassDescriptor getExtended(ClassMapping clsMap, java.lang.Class<?> javaClass) throws MappingException
classMapping
extends.clsMap
- The ClassMapping to find the required descriptor for.javaClass
- The name of the class that is checked (this is used for
generating the exception).null
if the given ClassMapping does not extend
any.MappingException
- If the given ClassMapping extends another
ClassMapping but its descriptor could not be found.protected final ClassDescriptor getDepended(ClassMapping clsMap, java.lang.Class<?> javaClass) throws MappingException
classMapping
depends
on.clsMap
- The ClassMapping to find the required ClassDescriptor for.javaClass
- The name of the class that is checked (this is used for
generating the exception).null
if the given ClassMapping does not depend on
any.MappingException
- If the given ClassMapping depends on another
ClassMapping but its descriptor could not be found.protected final void checkFieldNameDuplicates(FieldDescriptor[] fields, java.lang.Class<?> cls) throws MappingException
fields
- The fields to be checked.cls
- Class that is checked (this is used for generating the exception).MappingException
- If at least two fields have the same name.protected abstract void resolveRelations(ClassDescriptor clsDesc)
protected final java.lang.Class<?> resolveType(java.lang.String typeName) throws MappingException
MappingException
protected final FieldDescriptorImpl[] createFieldDescriptors(ClassMapping clsMap, java.lang.Class<?> javaClass) throws MappingException
clsMap
- The class to which the fields belong.javaClass
- The field mappings.MappingException
- An exception indicating why mapping for the class cannot
be created.protected final ClassMapping getOrigin(ClassMapping clsMap)
classMapping
.clsMap
- The ClassMapping to get the origin for.protected final FieldDescriptor[] divideFieldDescriptors(FieldDescriptor[] fields, java.lang.String[] ids, FieldDescriptor[] identities)
protected int getIdColumnIndex(FieldDescriptor field, java.lang.String[] ids)
idColumnNames
that has the same name as
the given field
.field
- The FieldDescriptor to find the column index for.ids
- The id columnNames available.-1
if no such id column name exists.protected FieldDescriptorImpl createFieldDesc(java.lang.Class<?> javaClass, FieldMapping fieldMap) throws MappingException
FieldDescriptor
. Implementations may extend this class to create a more
suitable descriptor.javaClass
- The class to which the field belongs.fieldMap
- The field mapping information.MappingException
- The field or its accessor methods are not
found, not accessible, not of the specified type, etc.protected final FieldHandler createFieldHandler(java.lang.Class<?> javaClass, java.lang.Class<?> fldType, FieldMapping fldMap, AbstractMappingLoader.TypeInfoReference typeInfoRef) throws MappingException
javaClass
- the class type of the parent of the field.fldType
- the Java class type for the field.fldMap
- the field mapping.MappingException
protected TypeInfo getTypeInfo(java.lang.Class<?> fieldType, CollectionHandler colHandler, FieldMapping fieldMap) throws MappingException
MappingException
public static final java.lang.reflect.Method findAccessor(java.lang.Class<?> javaClass, java.lang.String methodName, java.lang.Class<?> fieldType, boolean getMethod) throws MappingException
javaClass
- The class to which the field belongs.methodName
- The name of the accessor method.fieldType
- The type of the field if known, or null.getMethod
- True if get method, false if set method.MappingException
- The method is not accessible or is not of the
specified type.public static final java.lang.String[] getIdentityColumnNames(java.lang.String[] ids, ClassMapping clsMap)
ids
- Known identity names.clsMap
- The class mapping.protected static final boolean isPrimitive(java.lang.Class<?> type)
public void setInternalContext(InternalContext internalContext)
public InternalContext getInternalContext()
Intalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com