org.exolab.castor.xml
Class XMLMappingLoader

java.lang.Object
  extended by org.exolab.castor.mapping.loader.MappingLoader
      extended by org.exolab.castor.xml.XMLMappingLoader
All Implemented Interfaces:
MappingResolver

public class XMLMappingLoader
extends MappingLoader

An XML implementation of mapping helper. Creates XML class descriptors from the mapping file.

Version:
$Revision: 1.15 $ $Date: 2005/08/03 21:11:48 $
Author:
Keith Visco, Assaf Arkin

Nested Class Summary
(package private)  class XMLMappingLoader.ContainerElementFieldDescriptor
          An extended XMLFieldDescriptor that allows us to change the fieldType, needed for container element support
(package private)  class XMLMappingLoader.IdentityConvertor
          A special TypeConvertor that simply returns the object given.
 
Nested classes/interfaces inherited from class org.exolab.castor.mapping.loader.MappingLoader
MappingLoader.TypeInfoReference
 
Field Summary
 
Fields inherited from class org.exolab.castor.mapping.loader.MappingLoader
NoDescriptor
 
Constructor Summary
XMLMappingLoader(java.lang.ClassLoader loader, java.io.PrintWriter logWriter)
          Creates a new XMLMappingLoader
 
Method Summary
protected  ClassDescriptor createDescriptor(ClassMapping clsMap)
          Creates a new descriptor.
protected  FieldDescriptor createFieldDesc(java.lang.Class javaClass, FieldMapping fieldMap)
          Creates a single field descriptor.
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
protected  void resolveRelations(ClassDescriptor clsDesc)
           
 void setLoadPackageMappings(boolean loadPackageMappings)
          Sets whether or not to look for and load package specific mapping files (".castor.xml" files).
 
Methods inherited from class org.exolab.castor.mapping.loader.MappingLoader
addDescriptor, createFieldDescs, createFieldHandler, findAccessor, getClassLoader, getDescriptor, getDescriptor, getLogWriter, listDescriptors, listJavaClasses, loadClassDescriptor, loadMapping, resolveType, setAllowRedefinitions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLMappingLoader

public XMLMappingLoader(java.lang.ClassLoader loader,
                        java.io.PrintWriter logWriter)
                 throws MappingException
Creates a new XMLMappingLoader

Throws:
MappingException
Method Detail

resolveRelations

protected void resolveRelations(ClassDescriptor clsDesc)
                         throws MappingException
Overrides:
resolveRelations in class MappingLoader
Throws:
MappingException

createDescriptor

protected ClassDescriptor createDescriptor(ClassMapping clsMap)
                                    throws MappingException
Description copied from class: MappingLoader
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.

Overrides:
createDescriptor in class MappingLoader
Parameters:
clsMap - The class mapping information
Throws:
MappingException - An exception indicating why mapping for the class cannot be created

createFieldDesc

protected FieldDescriptor createFieldDesc(java.lang.Class javaClass,
                                          FieldMapping fieldMap)
                                   throws MappingException
Description copied from class: MappingLoader
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.

Overrides:
createFieldDesc in class MappingLoader
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(java.lang.Class fieldType,
                               CollectionHandler colHandler,
                               FieldMapping fieldMap)
                        throws MappingException
Overrides:
getTypeInfo in class MappingLoader
Throws:
MappingException

isPrimitive

protected static boolean isPrimitive(java.lang.Class type)
Returns true if the given class should be treated as a primitive type

Returns:
true if the given class should be treated as a primitive type


Intalio Inc. (C) 1999-2004. All rights reserved http://www.intalio.com