org.exolab.castor.mapping
public class Mapping extends Object
Multiple mapping files can be loaded with the same Mapping object. When loading master mapping files that include other mapping files it might be convenient to use Mapping or Mapping.
If the desired class loader is different than the one used by Castor (e.g. if Castor is installed as a Java extension), the Mapping object can be constructed with the proper class loader.
The following example loads two mapping files:
Mapping mapping; mapping = new Mapping( getClass().getClassLoader() ); mapping.loadMapping( "mapping.xml" ); mapping.loadMapping( url );
Version: $Revision: 1.1.1.1 $ $Date: 2003/03/03 07:08:27 $
Nested Class Summary | |
---|---|
class | Mapping.ClassMappingResolver
An IDResolver to allow us to resolve ClassMappings
from included Mapping files
|
static class | Mapping.EngineMapping
Associates engine name (XML, JDO, etc) with the class of its
mapping loader. |
class | Mapping.MappingState
A class to keep track of the loaded mapping. |
Field Summary | |
---|---|
static Mapping.EngineMapping | DAX
Use this object to obtain the mapping resolver for DAX from
Mapping. |
static Mapping.EngineMapping | JDO
Use this object to obtain the mapping resolver for JDO from
Mapping. |
static Mapping.EngineMapping | XML
Use this object to obtain the mapping resolver for XML from
Mapping. |
Constructor Summary | |
---|---|
Mapping(ClassLoader loader)
Constructs a new mapping.
| |
Mapping()
Constructs a new mapping. |
Method Summary | |
---|---|
ClassLoader | getClassLoader()
Returns the class loader used by this mapping object. |
MappingResolver | getResolver(Mapping.EngineMapping engine)
Returns a mapping resolver for the suitable engine. |
MappingResolver | getResolver(Mapping.EngineMapping engine, Object param)
Returns a mapping resolver for the suitable engine. |
MappingRoot | getRoot()
Returns a MappingRoot which contains all loaded mapping classes and
key generators definition. |
void | loadMapping(String url)
Loads the mapping from the specified URL. |
void | loadMapping(URL url)
Loads the mapping from the specified URL.
|
void | loadMapping(InputSource source)
Loads the mapping from the specified input source.
|
void | setAllowRedefinitions(boolean allow)
Enables or disables the ability to allow the redefinition
of class mappings.
|
void | setBaseURL(String url)
Sets the base URL for the mapping and related files. |
void | setEntityResolver(EntityResolver resolver)
Sets the entity resolver. |
void | setLogWriter(PrintWriter logWriter)
Sets the log writer. |
Parameters: loader The class loader to use, null for the default
Returns: The class loader used by this mapping object (may be null)
Parameters: engine The mapping engine
Returns: A mapping resolver
Throws: MappingException A mapping error occured preventing descriptors from being generated from the loaded mapping
Parameters: engine The mapping engine param Arbitrary parameter that is to be passed to resolver.loadMapping()
Returns: A mapping resolver
Throws: MappingException A mapping error occured preventing descriptors from being generated from the loaded mapping
Parameters: url The URL of the mapping file
Throws: IOException An error occured when reading the mapping file MappingException The mapping file is invalid
Parameters: url The URL of the mapping file
Throws: IOException An error occured when reading the mapping file MappingException The mapping file is invalid
Parameters: source The input source
Throws: IOException An error occured when reading the mapping file MappingException The mapping file is invalid
Parameters: allow a boolean that when true enables redefinitions.
Parameters: url The base URL
Parameters: resolver The entity resolver to use
Parameters: logWriter The log writer to use