|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.exolab.castor.mapping.Mapping
public class Mapping
Utility class for loading mapping files and providing them to the XML marshaller, JDO engine etc. The mapping file can be loaded from a URL, input stream or SAX InputSource.
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 setBaseURL(java.lang.String)
or setEntityResolver(org.xml.sax.EntityResolver)
.
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 );
Nested Class Summary | |
---|---|
(package private) class |
Mapping.ClassMappingResolver
An IDResolver to allow us to resolve ClassMappings from included Mapping files |
(package private) static class |
Mapping.EngineMapping
Associates engine name (XML, JDO, etc) with the class of its mapping loader. |
(package private) class |
Mapping.IncludeListener
An UnmarshalListener to handle mapping includes |
(package private) 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 getResolver(EngineMapping) . |
static Mapping.EngineMapping |
JDO
Use this object to obtain the mapping resolver for JDO from getResolver(EngineMapping) . |
static Mapping.EngineMapping |
XML
Use this object to obtain the mapping resolver for XML from getResolver(EngineMapping) . |
Constructor Summary | |
---|---|
Mapping()
Constructs a new mapping. |
|
Mapping(java.lang.ClassLoader loader)
Constructs a new mapping. |
Method Summary | |
---|---|
java.lang.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,
java.lang.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(org.xml.sax.InputSource source)
Loads the mapping from the specified input source. |
void |
loadMapping(java.lang.String url)
Loads the mapping from the specified URL. |
void |
loadMapping(java.net.URL url)
Loads the mapping from the specified URL. |
void |
setAllowRedefinitions(boolean allow)
Enables or disables the ability to allow the redefinition of class mappings. |
void |
setBaseURL(java.lang.String url)
Sets the base URL for the mapping and related files. |
void |
setEntityResolver(org.xml.sax.EntityResolver resolver)
Sets the entity resolver. |
void |
setLogWriter(java.io.PrintWriter logWriter)
Sets the log writer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Mapping.EngineMapping JDO
getResolver(EngineMapping)
.
public static final Mapping.EngineMapping DAX
getResolver(EngineMapping)
.
public static final Mapping.EngineMapping XML
getResolver(EngineMapping)
.
Constructor Detail |
---|
public Mapping(java.lang.ClassLoader loader)
loader
- The class loader to use, null for the defaultpublic Mapping()
Method Detail |
---|
public MappingResolver getResolver(Mapping.EngineMapping engine) throws MappingException
engine
- The mapping engine
MappingException
- A mapping error occured preventing
descriptors from being generated from the loaded mappingJDO
,
XML
,
DAX
public MappingResolver getResolver(Mapping.EngineMapping engine, java.lang.Object param) throws MappingException
engine
- The mapping engineparam
- Arbitrary parameter that is to be passed to resolver.loadMapping()
MappingException
- A mapping error occured preventing
descriptors from being generated from the loaded mappingJDO
,
XML
,
DAX
public MappingRoot getRoot()
public void setAllowRedefinitions(boolean allow)
allow
- a boolean that when true enables redefinitions.public void setLogWriter(java.io.PrintWriter logWriter)
logWriter
- The log writer to usepublic void setEntityResolver(org.xml.sax.EntityResolver resolver)
resolver
- The entity resolver to usepublic void setBaseURL(java.lang.String url)
url
- The base URLpublic java.lang.ClassLoader getClassLoader()
public void loadMapping(java.lang.String url) throws java.io.IOException, MappingException
url
- The URL of the mapping file
java.io.IOException
- An error occured when reading the mapping
file
MappingException
- The mapping file is invalidpublic void loadMapping(java.net.URL url) throws java.io.IOException, MappingException
url
- The URL of the mapping file
java.io.IOException
- An error occured when reading the mapping
file
MappingException
- The mapping file is invalidpublic void loadMapping(org.xml.sax.InputSource source) throws java.io.IOException, MappingException
source
- The input source
java.io.IOException
- An error occured when reading the mapping
file
MappingException
- The mapping file is invalid
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |