Class XMLMappingLoader
java.lang.Object
org.exolab.castor.mapping.loader.AbstractMappingLoader2
org.exolab.castor.mapping.loader.AbstractMappingLoader
org.exolab.castor.xml.XMLMappingLoader
- All Implemented Interfaces:
MappingLoader
An XML implementation of mapping helper. Creates XML class
descriptors from the mapping file.
- Version:
- $Revision: 9176 $ $Date: 2006-02-23 01:37:50 -0700 (Thu, 23 Feb 2006) $
- Author:
- Keith Visco, Assaf Arkin
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractMappingLoader
AbstractMappingLoader.TypeInfoReferenceModifier and TypeClassDescriptionclassA class used to by the createFieldHandler method in order to save the reference of the TypeInfo that was used. -
Field Summary
Fields inherited from class AbstractMappingLoader
NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ClassDescriptorcreateClassDescriptor(ClassMapping classMapping) To create the class descriptor for the given class mapping.protected FieldDescriptorImplcreateFieldDesc(Class javaClass, FieldMapping fieldMap) Creates a single field descriptor.protected final FieldDescriptorfindIdentityByName(List fldList, String idName, Class javaClass) protected TypeInfogetTypeInfo(Class fieldType, CollectionHandler colHandler, FieldMapping fieldMap) voidloadMapping(MappingRoot mapping, Object param) Loads the mapping from the specified mapping object if not loaded previously.protected final voidresolveRelations(ClassDescriptor clsDesc) voidsetLoadPackageMappings(boolean loadPackageMappings) Sets whether or not to look for and load package specific mapping files (".castor.xml" files).Methods inherited from class AbstractMappingLoader
checkFieldNameDuplicates, createClassDescriptors, createFieldDescriptors, createFieldHandler, createFieldHandlers, divideFieldDescriptors, findAccessor, getDepended, getExtended, getIdColumnIndex, getIdentityColumnNames, getInternalContext, getOrigin, getSourceType, isPrimitive, resolveType, setInternalContextModifier and TypeMethodDescriptionprotected final voidcheckFieldNameDuplicates(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 final voidcreateClassDescriptors(MappingRoot mapping) protected final FieldDescriptorImpl[]createFieldDescriptors(ClassMapping clsMap, Class<?> javaClass) Create field descriptors.protected final FieldHandlercreateFieldHandler(Class<?> javaClass, Class<?> fldType, FieldMapping fldMap, AbstractMappingLoader.TypeInfoReference typeInfoRef) Creates the FieldHandler for the given FieldMapping.protected voidcreateFieldHandlers(MappingRoot mapping) Load field handler definitions, check for duplicate definitions and instantiate the appropriate FieldHandler implementations.protected final FieldDescriptor[]divideFieldDescriptors(FieldDescriptor[] fields, String[] ids, FieldDescriptor[] identities) static final MethodfindAccessor(Class<?> javaClass, String methodName, Class<?> fieldType, boolean getMethod) Returns the named accessor.protected final ClassDescriptorgetDepended(ClassMapping clsMap, Class<?> javaClass) Gets the ClassDescriptor the givenclassMappingdepends on.protected final ClassDescriptorgetExtended(ClassMapping clsMap, Class<?> javaClass) Gets the ClassDescriptor the givenclassMappingextends.protected intgetIdColumnIndex(FieldDescriptor field, String[] ids) Finds the index in the givenidColumnNamesthat has the same name as the givenfield.static final String[]getIdentityColumnNames(String[] ids, ClassMapping clsMap) Returns a list of column names that are part of the identity.protected final ClassMappinggetOrigin(ClassMapping clsMap) Gets the top-most (i.e.final Stringprotected static final booleanisPrimitive(Class<?> type) Returns true if the given class should be treated as a primitive typeprotected final Class<?> resolveType(String typeName) Returns the Java class for the named type.voidsetInternalContext(InternalContext internalContext) Methods inherited from class AbstractMappingLoader2
addDescriptor, clear, getClassLoader, getDescriptor, getDescriptors, isAllowRedefinition, loadMapping, setAllowRedefinitions, setClassLoaderModifier and TypeMethodDescriptionprotected final voidaddDescriptor(ClassDescriptor descriptor) Adds a class descriptor.final voidclear()final ClassLoaderReturns the class loader associated with this mapping loader if one was specified.final ClassDescriptorgetDescriptor(String classname) Returns the ClassDescriptor for the class with the given name.final List<ClassDescriptor> Returns a List ofClassDescriptors of all known descriptors.final booleanIs the ability to allow redefinitions enabled or disabled?protected final booleanReturn if mapping should be loaded with this MappingLoader instance or if another mapping have been loaded previously.final voidsetAllowRedefinitions(boolean allow) Enables or disables the ability to allow the redefinition of class mappings.final voidsetClassLoader(ClassLoader loader)
-
Constructor Details
-
XMLMappingLoader
Creates a new XMLMappingLoader. Joachim 2007-08-19: called via ClassLoader from XMLMappingLoaderFactory.getMappingLoader() must not be modified!!!- Parameters:
loader- the class loader to use
-
-
Method Details
-
getBindingType
-
loadMapping
Loads the mapping from the specified mapping object if not loaded previously.- Specified by:
loadMappingin classAbstractMappingLoader- Parameters:
mapping- The mapping information.param- Arbitrary parameter that can be used by subclasses.- Throws:
MappingException- The mapping file is invalid.
-
createClassDescriptor
To create the class descriptor for the given class mapping. Throws IllegalStateException if the class has no valid internal context.- Specified by:
createClassDescriptorin classAbstractMappingLoader- Parameters:
classMapping- the class mapping information to process- Returns:
- the
ClassDescriptorcreated for the class mapping - Throws:
MappingException- ...
-
findIdentityByName
-
resolveRelations
- Specified by:
resolveRelationsin classAbstractMappingLoader
-
createFieldDesc
protected FieldDescriptorImpl createFieldDesc(Class javaClass, FieldMapping fieldMap) throws MappingException Description copied from class:AbstractMappingLoaderCreates a single field descriptor. The field mapping is used to create a new stockFieldDescriptor. Implementations may extend this class to create a more suitable descriptor.- Overrides:
createFieldDescin classAbstractMappingLoader- Parameters:
javaClass- The class to which the field belongs.fieldMap- The field mapping information.- Returns:
- The field descriptor.
- Throws:
MappingException- The field or its accessor methods are not found, not accessible, not of the specified type, etc.
-
setLoadPackageMappings
public void setLoadPackageMappings(boolean loadPackageMappings) Sets whether or not to look for and load package specific mapping files (".castor.xml" files).- Parameters:
loadPackageMappings- a boolean that enables or disables the loading of package specific mapping files
-
getTypeInfo
protected TypeInfo getTypeInfo(Class fieldType, CollectionHandler colHandler, FieldMapping fieldMap) throws MappingException - Overrides:
getTypeInfoin classAbstractMappingLoader- Throws:
MappingException
-