|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.exolab.castor.mapping.loader.MappingLoader
public abstract class MappingLoader
Assists in the construction of descriptors. Can be used as a mapping resolver to the engine. Engines will implement their own mapping scheme typically by extending this class.
Nested Class Summary | |
---|---|
class |
MappingLoader.TypeInfoReference
A class used to by the createFieldHandler method in order to save the reference of the TypeInfo that was used. |
Field Summary | |
---|---|
protected static java.lang.Class[] |
EMPTY_ARGS
Empty array of class types used for reflection |
static ClassDescriptor |
NoDescriptor
|
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. |
Constructor Summary | |
---|---|
protected |
MappingLoader(java.lang.ClassLoader loader,
java.io.PrintWriter logWriter)
Constructs a new mapping helper. |
Method Summary | |
---|---|
protected void |
addDescriptor(ClassDescriptor clsDesc)
Adds a class descriptor. |
protected ClassDescriptor |
createDescriptor(ClassMapping clsMap)
Creates a new descriptor. |
protected FieldDescriptor |
createFieldDesc(java.lang.Class javaClass,
FieldMapping fieldMap)
Creates a single field descriptor. |
protected FieldDescriptor[] |
createFieldDescs(java.lang.Class javaClass,
FieldMapping[] fieldMaps)
Create field descriptors. |
protected FieldHandler |
createFieldHandler(java.lang.Class javaClass,
java.lang.Class fieldType,
FieldMapping fieldMap,
MappingLoader.TypeInfoReference typeInfoRef)
Creates the FieldHandler for the given FieldMapping |
protected static java.lang.reflect.Method |
findAccessor(java.lang.Class javaClass,
java.lang.String methodName,
java.lang.Class fieldType,
boolean getMethod)
Returns the named accessor. |
java.lang.ClassLoader |
getClassLoader()
Returns the class loader associated with this mapping resolver if one was specified. |
ClassDescriptor |
getDescriptor(java.lang.Class type)
Returns the class descriptor for the specified Java class. |
ClassDescriptor |
getDescriptor(java.lang.String className)
Returns the ClassDescriptor for the class with the given name. |
protected java.io.PrintWriter |
getLogWriter()
Returns the log writer. |
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 |
java.util.Enumeration |
listDescriptors()
Returns an enumeration of all the known descriptors. |
java.util.Enumeration |
listJavaClasses()
Returns an enumeration of all the supported Java classes. |
protected ClassDescriptor |
loadClassDescriptor(java.lang.String clsName)
Loads a class descriptor from a compiled class. |
void |
loadMapping(MappingRoot mapping,
java.lang.Object param)
Loads the mapping from the specified mapping object. |
protected void |
resolveRelations(ClassDescriptor clsDesc)
|
protected java.lang.Class |
resolveType(java.lang.String typeName)
Returns the Java class for the named type. |
void |
setAllowRedefinitions(boolean allow)
Enables or disables the ability to allow the redefinition of class mappings. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.Class[] EMPTY_ARGS
protected static final java.lang.Class[] STRING_ARG
protected static final java.lang.String VALUE_OF
public static final ClassDescriptor NoDescriptor
Constructor Detail |
---|
protected MappingLoader(java.lang.ClassLoader loader, java.io.PrintWriter logWriter)
loader
- The class loader to use, null for the defaultMethod Detail |
---|
public ClassDescriptor getDescriptor(java.lang.String className)
className
- the className for which to return
the associated ClassDescriptor.
public ClassDescriptor getDescriptor(java.lang.Class type)
MappingResolver
getDescriptor
in interface MappingResolver
type
- The Java class
public java.util.Enumeration listDescriptors()
MappingResolver
ClassDescriptor
.
listDescriptors
in interface MappingResolver
public java.util.Enumeration listJavaClasses()
MappingResolver
listJavaClasses
in interface MappingResolver
public java.lang.ClassLoader getClassLoader()
MappingResolver
getClassLoader
in interface MappingResolver
protected java.io.PrintWriter getLogWriter()
protected java.lang.Class resolveType(java.lang.String typeName) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
public void loadMapping(MappingRoot mapping, java.lang.Object param) throws MappingException
createDescriptor(org.exolab.castor.mapping.xml.ClassMapping)
to create each descriptor and addDescriptor(org.exolab.castor.mapping.ClassDescriptor)
to store it. Also loads all the included mapping
files.
mapping
- The mapping informationparam
- Arbitrary parameter that can be used by subclasses
MappingException
- The mapping file is invalidpublic void setAllowRedefinitions(boolean allow)
allow
- a boolean that when true enables redefinitions.protected void addDescriptor(ClassDescriptor clsDesc) throws MappingException
clsDesc
- The descriptor to add
MappingException
- A descriptor for this class already
existsprotected void resolveRelations(ClassDescriptor clsDesc) throws MappingException
MappingException
protected ClassDescriptor createDescriptor(ClassMapping clsMap) throws MappingException
ClassDescriptor
. Implementations may
extend this class to create a more suitable descriptor.
clsMap
- The class mapping information
MappingException
- An exception indicating why mapping for
the class cannot be createdprotected FieldDescriptor[] createFieldDescs(java.lang.Class javaClass, FieldMapping[] fieldMaps) throws MappingException
javaClass
- The class to which the fields belongfieldMaps
- The field mappings
MappingException
- An exception indicating why mapping for
the class cannot be createdprotected FieldDescriptor 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 belongsfieldMap
- The field mapping information
MappingException
- The field or its accessor methods are not
found, not accessible, not of the specified type, etcprotected FieldHandler createFieldHandler(java.lang.Class javaClass, java.lang.Class fieldType, FieldMapping fieldMap, MappingLoader.TypeInfoReference typeInfoRef) throws MappingException
javaClass
- the class type of the parent of the fieldfieldType
- the Java class type for the field.fieldMap
- the field mapping
MappingException
protected TypeInfo getTypeInfo(java.lang.Class fieldType, CollectionHandler colHandler, FieldMapping fieldMap) throws MappingException
MappingException
protected 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 belongsmethodName
- The name of the accessor methodfieldType
- The type of the field if known, or nullgetMethod
- True if get method, false if set method
MappingException
- The method is not accessible or is not of the
specified typeprotected ClassDescriptor loadClassDescriptor(java.lang.String clsName)
clsName
- The class for which the descriptor is loaded
protected static boolean isPrimitive(java.lang.Class type)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |