Classes | Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions

org.exolab.castor.mapping.loader.MappingLoader Class Reference

Inheritance diagram for org.exolab.castor.mapping.loader.MappingLoader:
org.exolab.castor.mapping.MappingResolver org.exolab.castor.tools.MappingTool.InternalLoader org.exolab.castor.xml.XMLMappingLoader

List of all members.

Classes

class  TypeInfoReference

Public Member Functions

ClassDescriptor getDescriptor (String className)
ClassDescriptor getDescriptor (Class type)
Enumeration listDescriptors ()
Enumeration listJavaClasses ()
ClassLoader getClassLoader ()
void loadMapping (MappingRoot mapping, Object param) throws MappingException
void setAllowRedefinitions (boolean allow)

Static Public Attributes

static final ClassDescriptor NoDescriptor = new ClassDescriptorImpl( Class.class )

Protected Member Functions

 MappingLoader (ClassLoader loader, PrintWriter logWriter)
PrintWriter getLogWriter ()
Class resolveType (String typeName) throws ClassNotFoundException
void addDescriptor (ClassDescriptor clsDesc) throws MappingException
void resolveRelations (ClassDescriptor clsDesc) throws MappingException
ClassDescriptor createDescriptor (ClassMapping clsMap) throws MappingException
FieldDescriptor[] createFieldDescs (Class javaClass, FieldMapping[] fieldMaps) throws MappingException
FieldDescriptor createFieldDesc (Class javaClass, FieldMapping fieldMap) throws MappingException
FieldHandler createFieldHandler (Class javaClass, Class fieldType, FieldMapping fieldMap, TypeInfoReference typeInfoRef) throws MappingException
TypeInfo getTypeInfo (Class fieldType, CollectionHandler colHandler, FieldMapping fieldMap) throws MappingException
ClassDescriptor loadClassDescriptor (String clsName)

Static Protected Member Functions

static final Method findAccessor (Class javaClass, String methodName, Class fieldType, boolean getMethod) throws MappingException

Detailed Description

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.

Author:
Assaf Arkin
Keith Visco
Version:
Revision:
1.8
Date:
2004/10/01 13:25:05

Constructor & Destructor Documentation

org.exolab.castor.mapping.loader.MappingLoader.MappingLoader ( ClassLoader  loader,
PrintWriter  logWriter 
) [protected]

Constructs a new mapping helper. This constructor is used by a derived class.

Parameters:
loader The class loader to use, null for the default

Member Function Documentation

void org.exolab.castor.mapping.loader.MappingLoader.addDescriptor ( ClassDescriptor  clsDesc  )  throws MappingException [protected]

Adds a class descriptor. Will throw a mapping exception if a descriptor for this class already exists.

Parameters:
clsDesc The descriptor to add
Exceptions:
MappingException A descriptor for this class already exists

Referenced by org.exolab.castor.mapping.loader.MappingLoader.loadMapping().

FieldDescriptor org.exolab.castor.mapping.loader.MappingLoader.createFieldDesc ( Class  javaClass,
FieldMapping  fieldMap 
) throws MappingException [protected]

Create container field descriptor. The contained mapping is used to create a single field descriptor which includes several field descriptors for all contained fields.

Parameters:
javaClass The class to which the field belongs
fieldMap The field mapping
Exceptions:
MappingException An exception indicating why mapping for the class cannot be created 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.
Parameters:
javaClass The class to which the field belongs
fieldMap The field mapping information
Returns:
The field descriptor
Exceptions:
MappingException The field or its accessor methods are not found, not accessible, not of the specified type, etc

Reimplemented in org.exolab.castor.xml.XMLMappingLoader.

References org.exolab.castor.mapping.loader.MappingLoader.createFieldHandler(), org.exolab.castor.mapping.loader.TypeInfo.getCollectionHandler(), org.exolab.castor.mapping.loader.MappingLoader.getTypeInfo(), org.exolab.castor.mapping.FieldHandler.newInstance(), org.exolab.castor.mapping.loader.MappingLoader.resolveType(), org.exolab.castor.mapping.loader.TypeInfo.setCollectionHandler(), org.exolab.castor.mapping.loader.FieldDescriptorImpl.setRequired(), and org.exolab.castor.mapping.loader.MappingLoader.TypeInfoReference.typeInfo.

Referenced by org.exolab.castor.mapping.loader.MappingLoader.createFieldDescs().

FieldDescriptor [] org.exolab.castor.mapping.loader.MappingLoader.createFieldDescs ( Class  javaClass,
FieldMapping[]  fieldMaps 
) throws MappingException [protected]

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.

Parameters:
javaClass The class to which the fields belong
fieldMaps The field mappings
Exceptions:
MappingException An exception indicating why mapping for the class cannot be created

References org.exolab.castor.mapping.loader.MappingLoader.createFieldDesc().

Referenced by org.exolab.castor.mapping.loader.MappingLoader.createDescriptor().

static final Method org.exolab.castor.mapping.loader.MappingLoader.findAccessor ( Class  javaClass,
String  methodName,
Class  fieldType,
boolean  getMethod 
) throws MappingException [static, protected]

Returns the named accessor. Uses reflection to return the named accessor and check the return value or parameter type, if specified.

Parameters:
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
Returns:
The method, null if not found
Exceptions:
MappingException The method is not accessible or is not of the specified type

Referenced by org.exolab.castor.tools.MappingTool.InternalLoader.canFindAccessors(), org.exolab.castor.mapping.loader.MappingLoader.createFieldHandler(), and org.exolab.castor.tools.MappingTool.InternalLoader.returnsArray().

ClassLoader org.exolab.castor.mapping.loader.MappingLoader.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.

Implements org.exolab.castor.mapping.MappingResolver.

ClassDescriptor org.exolab.castor.mapping.loader.MappingLoader.getDescriptor ( String  className  ) 

Returns the ClassDescriptor for the class with the given name. If no such ClassDescriptor exists, within the set of mappings for this MappingLoader, null will be returned.

Parameters:
className the className for which to return the associated ClassDescriptor.
Returns:
the ClassDescriptor or null if not found.

Referenced by org.exolab.castor.mapping.loader.MappingLoader.createDescriptor(), org.exolab.castor.xml.util.ClassDescriptorResolverImpl.resolve(), org.exolab.castor.xml.XMLMappingLoader.resolveRelations(), and org.exolab.castor.mapping.loader.MappingLoader.resolveRelations().

ClassDescriptor org.exolab.castor.mapping.loader.MappingLoader.getDescriptor ( Class  javaClass  ) 

Returns the class descriptor for the specified Java class. In no such descriptor exists, returns null.

Parameters:
javaClass The Java class
Returns:
A suitable class descriptor or null

Implements org.exolab.castor.mapping.MappingResolver.

PrintWriter org.exolab.castor.mapping.loader.MappingLoader.getLogWriter (  )  [protected]

Returns the log writer. If not null, errors and other messages should be directed to the log writer.

TypeInfo org.exolab.castor.mapping.loader.MappingLoader.getTypeInfo ( Class  fieldType,
CollectionHandler  colHandler,
FieldMapping  fieldMap 
) throws MappingException [protected]
Enumeration org.exolab.castor.mapping.loader.MappingLoader.listDescriptors (  ) 
Enumeration org.exolab.castor.mapping.loader.MappingLoader.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.

Implements org.exolab.castor.mapping.MappingResolver.

ClassDescriptor org.exolab.castor.mapping.loader.MappingLoader.loadClassDescriptor ( String  clsName  )  [protected]

Loads a class descriptor from a compiled class.

Parameters:
clsName The class for which the descriptor is loaded
Returns:
An instance of the class descriptor or null if not found

Temporarily disabled clsName = clsName + CompiledSuffix; try { Object obj;

obj = resolveType( clsName ).newInstance(); if ( obj instanceof ClassDescriptor ) return (ClassDescriptor) obj; return null; } catch ( Exception except ) { return null; }

Referenced by org.exolab.castor.xml.XMLMappingLoader.createDescriptor(), and org.exolab.castor.mapping.loader.MappingLoader.createDescriptor().

void org.exolab.castor.mapping.loader.MappingLoader.loadMapping ( MappingRoot  mapping,
Object  param 
) throws MappingException

Loads the mapping from the specified mapping object. Calls createDescriptor to create each descriptor and addDescriptor to store it. Also loads all the included mapping files.

Parameters:
mapping The mapping information
param Arbitrary parameter that can be used by subclasses
Exceptions:
MappingException The mapping file is invalid

References org.exolab.castor.mapping.loader.MappingLoader.addDescriptor(), org.exolab.castor.mapping.loader.MappingLoader.createDescriptor(), org.exolab.castor.mapping.xml.ClassMapping.getName(), org.exolab.castor.mapping.loader.MappingLoader.NoDescriptor, and org.exolab.castor.mapping.loader.MappingLoader.resolveRelations().

Referenced by org.exolab.castor.mapping.Mapping.getResolver().

Class org.exolab.castor.mapping.loader.MappingLoader.resolveType ( String  typeName  )  throws ClassNotFoundException [protected]

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.

Referenced by org.exolab.castor.mapping.loader.MappingLoader.createDescriptor(), and org.exolab.castor.mapping.loader.MappingLoader.createFieldDesc().

void org.exolab.castor.mapping.loader.MappingLoader.setAllowRedefinitions ( boolean  allow  ) 

Enables or disables the ability to allow the redefinition of class mappings.

Parameters:
allow a boolean that when true enables redefinitions.

Referenced by org.exolab.castor.mapping.Mapping.getResolver().


Member Data Documentation


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties