public final class Mapping
extends java.lang.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 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 );
Constructor | Description |
---|---|
Mapping() |
Constructs a new mapping.
|
Mapping(java.lang.ClassLoader loader) |
Constructs a new mapping.
|
Modifier and Type | Method | Description |
---|---|---|
java.lang.ClassLoader |
getClassLoader() |
Returns the class loader used by this mapping object.
|
java.util.List |
getMappingSources() |
Get list of mapping sources to resolve.
|
MappingRoot |
getRoot() |
Get the loaded mapping.
|
void |
loadMapping(java.lang.String url) |
Loads the mapping from the specified URL with type defaults to
'CastorXmlMapping'.
|
void |
loadMapping(java.lang.String url,
java.lang.String type) |
Loads the mapping from the specified URL.
|
void |
loadMapping(java.net.URL url) |
Loads the mapping from the specified URL with type defaults to
'CastorXmlMapping'.
|
void |
loadMapping(java.net.URL url,
java.lang.String type) |
Loads the mapping from the specified URL.
|
void |
loadMapping(org.xml.sax.InputSource source) |
Loads the mapping from the specified input source with type defaults to
'CastorXmlMapping'.
|
void |
loadMapping(org.xml.sax.InputSource source,
java.lang.String type) |
Loads the mapping from the specified input source.
|
void |
markAsProcessed(java.lang.Object id) |
Marks the given mapping as having been processed.
|
boolean |
processed(java.lang.Object id) |
Returns true if the given systemID or stream has been marked as processed.
|
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.
|
public Mapping(java.lang.ClassLoader loader)
loader
- The class loader to use, null for the defaultpublic Mapping()
public java.util.List getMappingSources() throws MappingException
MappingException
- If no mapping source has been loaded previously.public void markAsProcessed(java.lang.Object id)
id
- systemID or stream to identify the mapping to mark.public boolean processed(java.lang.Object id)
id
- systemID or stream to check for being marked as processed.public MappingRoot getRoot()
public java.lang.ClassLoader getClassLoader()
public void setEntityResolver(org.xml.sax.EntityResolver resolver)
resolver
- The entity resolver to usepublic void setBaseURL(java.lang.String url)
url
- The base URLpublic 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 invalid.public void loadMapping(java.lang.String url, java.lang.String type) throws java.io.IOException, MappingException
url
- The URL of the mapping file.type
- The source type.java.io.IOException
- An error occured when reading the mapping file.MappingException
- The mapping file is invalid.public 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 invalid.public void loadMapping(java.net.URL url, java.lang.String type) throws java.io.IOException, MappingException
url
- The URL of the mapping file.type
- The source type.java.io.IOException
- An error occured when reading the mapping file.MappingException
- The mapping file is invalid.public void loadMapping(org.xml.sax.InputSource source)
source
- The input source.public void loadMapping(org.xml.sax.InputSource source, java.lang.String type)
source
- The input source.type
- The source type.Intalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com