public abstract class AbstractMappingLoader extends AbstractMappingLoader2
| Modifier and Type | Class and 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 and Description |
|---|---|
protected static Class<?>[] |
EMPTY_ARGS
Empty array of class types used for reflection.
|
protected static String |
NAME
Method name to get string value of a type-safe enumerations.
|
protected static Class<?>[] |
STRING_ARG
The string argument for the valueOf method, used for introspection when searching for type-safe
enumeration style classes.
|
protected static String |
VALUE_OF
Factory method name for type-safe enumerations.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractMappingLoader(ClassLoader loader)
Constructs a new mapping helper.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkFieldNameDuplicates(FieldDescriptor[] fields,
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(Class<?> javaClass,
FieldMapping fieldMap)
Creates a single field descriptor.
|
protected FieldDescriptorImpl[] |
createFieldDescriptors(ClassMapping clsMap,
Class<?> javaClass)
Create field descriptors.
|
protected FieldHandler |
createFieldHandler(Class<?> javaClass,
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,
String[] ids,
FieldDescriptor[] identities) |
static Method |
findAccessor(Class<?> javaClass,
String methodName,
Class<?> fieldType,
boolean getMethod)
Returns the named accessor.
|
protected ClassDescriptor |
getDepended(ClassMapping clsMap,
Class<?> javaClass)
Gets the ClassDescriptor the given
classMapping depends on. |
protected ClassDescriptor |
getExtended(ClassMapping clsMap,
Class<?> javaClass)
Gets the ClassDescriptor the given
classMapping extends. |
protected int |
getIdColumnIndex(FieldDescriptor field,
String[] ids)
Finds the index in the given
idColumnNames that has the same name as the given
field. |
static String[] |
getIdentityColumnNames(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.
|
String |
getSourceType() |
protected TypeInfo |
getTypeInfo(Class fieldType,
CollectionHandler colHandler,
FieldMapping fieldMap) |
protected static boolean |
isPrimitive(Class<?> type)
Returns true if the given class should be treated as a primitive type
|
abstract void |
loadMapping(MappingRoot mapping,
Object param)
Loads the mapping from the specified mapping object if not loaded previously.
|
protected abstract void |
resolveRelations(ClassDescriptor clsDesc) |
protected Class<?> |
resolveType(String typeName)
Returns the Java class for the named type.
|
void |
setInternalContext(InternalContext internalContext) |
addDescriptor, clear, getClassLoader, getDescriptor, getDescriptors, isAllowRedefinition, loadMapping, setAllowRedefinitions, setClassLoaderclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetBindingTypeprotected static final Class<?>[] EMPTY_ARGS
protected static final Class<?>[] STRING_ARG
protected static final String VALUE_OF
protected static final String NAME
protected AbstractMappingLoader(ClassLoader loader)
loader - The class loader to use, null for the defaultpublic final String getSourceType()
public abstract void loadMapping(MappingRoot mapping, 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
MappingExceptionprotected abstract ClassDescriptor createClassDescriptor(ClassMapping clsMap) throws MappingException
MappingExceptionprotected final ClassDescriptor getExtended(ClassMapping clsMap, 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, 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, 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 Class<?> resolveType(String typeName) throws MappingException
MappingExceptionprotected final FieldDescriptorImpl[] createFieldDescriptors(ClassMapping clsMap, 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, String[] ids, FieldDescriptor[] identities)
protected int getIdColumnIndex(FieldDescriptor field, 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(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(Class<?> javaClass, 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.MappingExceptionprotected TypeInfo getTypeInfo(Class fieldType, CollectionHandler colHandler, FieldMapping fieldMap) throws MappingException
MappingExceptionpublic static final Method findAccessor(Class<?> javaClass, String methodName, 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 String[] getIdentityColumnNames(String[] ids, ClassMapping clsMap)
ids - Known identity names.clsMap - The class mapping.protected static final boolean isPrimitive(Class<?> type)
public void setInternalContext(InternalContext internalContext)
public InternalContext getInternalContext()
Copyright © 2016. All rights reserved.