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.
addDescriptor
protected void addDescriptor(ClassDescriptor clsDesc)
throws MappingException
Adds a class descriptor. Will throw a mapping exception if a
descriptor for this class already exists.
clsDesc
- The descriptor to add
createDescriptor
protected ClassDescriptor createDescriptor(ClassMapping clsMap)
throws MappingException
Creates a new descriptor. The class mapping information is used
to create a new stock
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 created
createFieldDesc
protected FieldDescriptor createFieldDesc(Class javaClass,
FieldMapping fieldMap)
throws MappingException
Creates a single field descriptor. The field mapping is used to
create a new stock
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, etc
createFieldDescs
protected FieldDescriptor[] createFieldDescs(Class javaClass,
FieldMapping[] fieldMaps)
throws MappingException
Create field descriptors. The class mapping information is used
to create descriptors for all the fields in the class, except
for container fields. Implementations may extend this method to
create more suitable descriptors, or create descriptors only for
a subset of the fields.
javaClass
- The class to which the fields belongfieldMaps
- The field mappings
MappingException
- An exception indicating why mapping for
the class cannot be created
createFieldHandler
protected FieldHandler createFieldHandler(Class javaClass,
Class fieldType,
FieldMapping fieldMap,
MappingLoader.TypeInfoReference typeInfoRef)
throws MappingException
Creates the FieldHandler for the given FieldMapping
javaClass
- the class type of the parent of the fieldfieldType
- the Java class type for the field.fieldMap
- the field mapping
- the newly created FieldHandler
findAccessor
protected static final Method findAccessor(Class javaClass,
String methodName,
Class fieldType,
boolean getMethod)
throws MappingException
Returns the named accessor. Uses reflection to return the named
accessor and check the return value or parameter type, if
specified.
javaClass
- The class to which the field belongsmethodName
- The name of the accessor methodfieldType
- The type of the field if known, or null
- The method, null if not found
getClassLoader
public ClassLoader getClassLoader()
Returns the class loader associated with this mapping resolver
if one was specified. This is the class loader used to load all
the classes mapped by this mapping resolver. May be null if no
class loader was specified or in certain JVMs.
- getClassLoader in interface MappingResolver
getDescriptor
public ClassDescriptor getDescriptor(Class type)
Returns the class descriptor for the specified Java class.
In no such descriptor exists, returns null.
- getDescriptor in interface MappingResolver
- A suitable class descriptor or null
getLogWriter
protected PrintWriter getLogWriter()
Returns the log writer. If not null, errors and other messages
should be directed to the log writer.
listJavaClasses
public Enumeration listJavaClasses()
Returns an enumeration of all the supported Java classes.
Each element is of type java.lang.Class, and for
each such class a suitable descriptor exists.
- listJavaClasses in interface MappingResolver
loadClassDescriptor
protected ClassDescriptor loadClassDescriptor(String clsName)
Loads a class descriptor from a compiled class.
clsName
- The class for which the descriptor is loaded
- An instance of the class descriptor or null if not found
loadMapping
public void loadMapping(MappingRoot mapping,
Object param)
throws MappingException
mapping
- The mapping informationparam
- Arbitrary parameter that can be used by subclasses
resolveType
protected Class resolveType(String typeName)
throws ClassNotFoundException
Returns the Java class for the named type. The type name can
be one of the accepted short names (e.g. integer) or
the full Java class name (e.g. java.lang.Integer).
If the short name is used, the primitive type might be returned.
setAllowRedefinitions
public void setAllowRedefinitions(boolean allow)
Enables or disables the ability to allow the redefinition
of class mappings.
allow
- a boolean that when true enables redefinitions.