public final class UnmarshalHandler extends Object implements ContentHandler, DocumentHandler, ErrorHandler
Modifier and Type | Class and Description |
---|---|
static class |
MarshalFramework.InheritanceMatch
Used to store the information when we find a possible inheritance.
|
static class |
UnmarshalHandler.ArrayHandler
A class for handling Arrays during unmarshalling.
|
Modifier and Type | Field and Description |
---|---|
static String |
LANG_ATTR
The xml:lang attribute, without the "xml:" prefix.
|
static String |
NIL_ATTR
The xsi:nil attribute, without the "xsi:" prefix.
|
protected static ResourceBundle |
resourceBundle
resource bundle
|
static String |
SPACE_ATTR
The xml:space attribute name, without the "xml:" prefix.
|
static String |
TRUE_VALUE
The value of 'true'.
|
static String |
TYPE_ATTR
The xsi:type attribute name, without the "xsi:" prefix.
|
static String |
XML_LANG_ATTR
The xml:lang attribute name.
|
static String |
XML_SPACE_ATTR
The xml:space attribute name.
|
static String |
XSI_NAMESPACE
The XSI Namespace URI.
|
static String |
XSI_NIL_ATTR
The xsi:nil attribute.
|
static String |
XSI_NO_NAMESPACE_SCHEMA_LOCATION
The name of the no namespace schema location attribute.
|
static String |
XSI_SCHEMA_LOCATION
The name of the Schema location attribute.
|
Modifier | Constructor and Description |
---|---|
protected |
UnmarshalHandler()
Creates a new UnmarshalHandler
The "root" class will be obtained by looking into the mapping
for a descriptor that matches the root element.
|
protected |
UnmarshalHandler(Class<?> topClass)
Creates a new UnmarshalHandler.
|
protected |
UnmarshalHandler(InternalContext internalContext,
Class<?> topClass)
Creates a new UnmarshalHandler.
|
Modifier and Type | Method and Description |
---|---|
void |
addNamespaceToPackageMapping(String nsURI,
String packageName)
Adds a mapping from the given namespace URI to the given
package name
|
void |
characters(char[] ch,
int start,
int length) |
void |
endDocument() |
void |
endElement(String name) |
void |
endElement(String namespaceURI,
String localName,
String qName)
ContentHandler#endElement
|
void |
endPrefixMapping(String prefix)
Signals to end the namespace prefix mapping
|
void |
error(SAXParseException exception) |
void |
fatalError(SAXParseException exception) |
AnyNode |
getAnyNode()
returns the AnyNode (if any).
|
AnyNodeUnmarshalHandler |
getAnyNodeHandler()
Returns the currently used
AnyNodeUnmarshalHandler instance. |
ClassLoader |
getClassLoader()
Returns the current
ClassLoader in use. |
CollectionHandler |
getCollectionHandler(Class clazz)
Returns the CollectionHandler associated with the
given collection, or null if no such handler exists.
|
Object |
getCurrentObject()
Returns the Object that the UnmarshalHandler is currently
handling (within the object model), or null if the current
element is a simpleType.
|
UnmarshalListenerDelegate |
getDelegateUnmarshalListener()
Returns the currently active
UnmarshalListenerDelegate instance |
Locator |
getDocumentLocator() |
InternalContext |
getInternalContext()
To get the
AbstractInternalContext to use. |
JavaNaming |
getJavaNaming()
To get the
JavaNaming instance to be used. |
NamespaceHandling |
getNamespaceHandling()
Returns the
NamespaceHandling in use. |
Object |
getObject()
Returns the "root" Object (ie.
|
ObjectFactory |
getObjectFactory()
Returns the ObjectFactory instance in use.
|
Hashtable<String,org.exolab.castor.xml.ReferenceInfo> |
getResolveTable()
Hashtable to store idReference and ReferenceInfo
|
UnmarshalStateStack |
getStateStack()
Returnss a refrence to the
UnmarshalStateStack instance currently in use. |
StrictElementHandler |
getStrictElementHandler()
Returns the
StrictElementHandler in use. |
UnmarshalState |
getTopState()
Returns the top
UnmarshalState instance from the UnmarshalStateStack . |
void |
ignorableWhitespace(char[] ch,
int start,
int length) |
boolean |
isClearCollections()
Indicates whether it's necessary to clear any collection or not.
|
static boolean |
isCollection(Class clazz)
Returns true if the given Class is a considered a
collection by the marshalling framework.
|
boolean |
isReuseObjects()
Indicats whether Object instances should be re-used.
|
static boolean |
namespaceEquals(String ns1,
String ns2)
Compares the given namespaces (as strings) for equality.
|
void |
processingInstruction(String target,
String data) |
protected MarshalFramework.InheritanceMatch[] |
searchInheritance(String name,
String namespace,
XMLClassDescriptor classDesc)
Search there is a field descriptor which can accept one of the class
descriptor which match the given name and namespace.
|
void |
setAnyNode(AnyNode node)
sets the AnyNode
|
void |
setClassLoader(ClassLoader loader)
Sets the ClassLoader to use when loading classes
|
void |
setClearCollections(boolean clear)
Sets whether or not to clear collections (including arrays)
upon first use to remove default values.
|
void |
setDebug(boolean debug)
Deprecated.
|
void |
setDocumentLocator(Locator locator) |
void |
setIDResolver(IDResolver idResolver)
Sets the IDResolver to use when resolving IDREFs for
which no associated element may exist in XML document.
|
void |
setIgnoreExtraAttributes(boolean ignoreExtraAtts)
Sets whether or not attributes that do not match
a specific field should simply be ignored or
reported as an error.
|
void |
setIgnoreExtraElements(boolean ignoreExtraElems)
Sets whether or not elements that do not match
a specific field should simply be ignored or
reported as an error.
|
void |
setInternalContext(InternalContext internalContext)
To set the
AbstractInternalContext to use. |
void |
setLogWriter(PrintWriter printWriter)
Deprecated.
|
void |
setObjectFactory(ObjectFactory objectFactory)
Sets a (custom) ObjectFactory instance.
|
void |
setReuseObjects(boolean reuse)
Sets a boolean that when true indicates that objects
contained within the object model should be re-used
where appropriate.
|
void |
setRootObject(Object root)
Sets the root (top-level) object to use for unmarshalling into.
|
void |
setUnmarshalListener(UnmarshalListener listener)
Deprecated.
please move to the new
UnmarshalListener interface |
void |
setUnmarshalListener(UnmarshalListener listener)
Sets an
UnmarshalListener . |
void |
setValidation(boolean validate)
Sets the flag for validation.
|
void |
setWhitespacePreserve(boolean preserve)
Sets the top-level whitespace (xml:space) to either
preserving or non preserving.
|
void |
skippedEntity(String name)
Signals that an entity was skipped by the parser
|
void |
startDocument()
Signals the start of a new document
|
void |
startElement(String name,
AttributeList attList)
Deprecated.
|
void |
startElement(String namespaceURI,
String localName,
String qName,
Attributes atts)
ContentHandler#startElement
|
void |
startPrefixMapping(String prefix,
String uri)
Signals to start the namespace - prefix mapping
|
static Object |
toPrimitiveObject(Class<?> type,
String value)
Converts a
String to the given primitive object type. |
void |
warning(SAXParseException exception) |
protected static ResourceBundle resourceBundle
public static final String XSI_NAMESPACE
public static final String XSI_SCHEMA_LOCATION
public static final String XSI_NO_NAMESPACE_SCHEMA_LOCATION
public static final String XML_LANG_ATTR
public static final String LANG_ATTR
public static final String NIL_ATTR
public static final String XSI_NIL_ATTR
public static final String XML_SPACE_ATTR
public static final String SPACE_ATTR
public static final String TYPE_ATTR
public static final String TRUE_VALUE
protected UnmarshalHandler()
protected UnmarshalHandler(Class<?> topClass)
topClass
- the Class to create the UnmarshalHandler forprotected UnmarshalHandler(InternalContext internalContext, Class<?> topClass)
internalContext
- the InternalContext
to usetopClass
- the Class to work forpublic void addNamespaceToPackageMapping(String nsURI, String packageName)
nsURI
- the namespace URI to map frompackageName
- the package name to map topublic Object getCurrentObject()
public Object getObject()
public void setClassLoader(ClassLoader loader)
loader
- the ClassLoader to usepublic void setClearCollections(boolean clear)
clear
- the boolean value that when true indicates
collections should be cleared upon first use.public void setDebug(boolean debug)
public void setIDResolver(IDResolver idResolver)
idResolver
- the IDResolver to use when resolving
IDREFs for which no associated element may exist in the
XML document.public void setIgnoreExtraAttributes(boolean ignoreExtraAtts)
ignoreExtraAtts
- a boolean that when true will
allow non-matched attributes to simply be ignored.public void setIgnoreExtraElements(boolean ignoreExtraElems)
ignoreExtraElems
- a boolean that when true will
allow non-matched attributes to simply be ignored.public void setLogWriter(PrintWriter printWriter)
public void setReuseObjects(boolean reuse)
reuse
- the boolean indicating whether or not
to re-use existing objects in the object model.public void setRootObject(Object root)
root
- the instance to unmarshal into.public void setUnmarshalListener(UnmarshalListener listener)
UnmarshalListener
interfaceUnmarshalListener
.listener
- the UnmarshalListener
to use with this instance
of the UnmarshalHandler.public void setUnmarshalListener(UnmarshalListener listener)
UnmarshalListener
.listener
- the UnmarshalListener
to use with this instance
of the UnmarshalHandler.public void setValidation(boolean validate)
validate
- A boolean to indicate whether or not validation should be done
during umarshalling.
public void setWhitespacePreserve(boolean preserve)
preserve
- a boolean that when true enables
whitespace preserving by default.public void characters(char[] ch, int start, int length) throws SAXException
characters
in interface ContentHandler
characters
in interface DocumentHandler
SAXException
public void endDocument() throws SAXException
endDocument
in interface ContentHandler
endDocument
in interface DocumentHandler
SAXException
public void endElement(String name) throws SAXException
endElement
in interface DocumentHandler
SAXException
public void endElement(String namespaceURI, String localName, String qName) throws SAXException
ContentHandler#endElement
Signals the end of an elementendElement
in interface ContentHandler
localName
- The name of the element.SAXException
public void endPrefixMapping(String prefix) throws SAXException
endPrefixMapping
in interface ContentHandler
prefix
- the namespace prefixSAXException
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
ignorableWhitespace
in interface ContentHandler
ignorableWhitespace
in interface DocumentHandler
SAXException
public void processingInstruction(String target, String data) throws SAXException
processingInstruction
in interface ContentHandler
processingInstruction
in interface DocumentHandler
SAXException
public void setDocumentLocator(Locator locator)
setDocumentLocator
in interface ContentHandler
setDocumentLocator
in interface DocumentHandler
public Locator getDocumentLocator()
public void skippedEntity(String name) throws SAXException
skippedEntity
in interface ContentHandler
name
- the skipped entity's nameSAXException
public void startDocument() throws SAXException
startDocument
in interface ContentHandler
startDocument
in interface DocumentHandler
SAXException
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException
ContentHandler#startElement
Signals the start of element.startElement
in interface ContentHandler
localName
- The name of the element.atts
- The AttributeList containing the associated attributes for the element.SAXException
public void startElement(String name, AttributeList attList) throws SAXException
DocumentHandler#startElement
Signals the start of element.startElement
in interface DocumentHandler
name
- The name of the element.attList
- The AttributeList containing the associated attributes for the
element.SAXException
public void startPrefixMapping(String prefix, String uri) throws SAXException
startPrefixMapping
in interface ContentHandler
prefix
- the namespace prefix to mapuri
- the namespace URISAXException
public void error(SAXParseException exception) throws SAXException
error
in interface ErrorHandler
SAXException
public void fatalError(SAXParseException exception) throws SAXException
fatalError
in interface ErrorHandler
SAXException
public void warning(SAXParseException exception) throws SAXException
warning
in interface ErrorHandler
SAXException
public static Object toPrimitiveObject(Class<?> type, String value)
String
to the given primitive object type.public ObjectFactory getObjectFactory()
public void setObjectFactory(ObjectFactory objectFactory)
objectFactory
- A (custom) ObjectFactory instancepublic UnmarshalStateStack getStateStack()
UnmarshalStateStack
instance currently in use.UnmarshalStateStack
in use.public UnmarshalState getTopState()
UnmarshalState
instance from the UnmarshalStateStack
.UnmarshalState
instance.public StrictElementHandler getStrictElementHandler()
StrictElementHandler
in use.StrictElementHandler
in use.public NamespaceHandling getNamespaceHandling()
NamespaceHandling
in use.NamespaceHandling
instance.public ClassLoader getClassLoader()
ClassLoader
in use.ClassLoader
in use.public AnyNodeUnmarshalHandler getAnyNodeHandler()
AnyNodeUnmarshalHandler
instance.AnyNodeUnmarshalHandler
in use.public UnmarshalListenerDelegate getDelegateUnmarshalListener()
UnmarshalListenerDelegate
instanceUnmarshalListenerDelegate
in use.public boolean isReuseObjects()
public Hashtable<String,org.exolab.castor.xml.ReferenceInfo> getResolveTable()
public AnyNode getAnyNode()
public void setAnyNode(AnyNode node)
node
- AnyNodepublic boolean isClearCollections()
public JavaNaming getJavaNaming()
JavaNaming
instance to be used.public InternalContext getInternalContext()
AbstractInternalContext
to use.AbstractInternalContext
to usepublic void setInternalContext(InternalContext internalContext)
AbstractInternalContext
to use.internalContext
- the AbstractInternalContext
to usepublic static boolean isCollection(Class clazz)
clazz
- the Class to checkpublic CollectionHandler getCollectionHandler(Class clazz)
clazz
- the Class to checkpublic static boolean namespaceEquals(String ns1, String ns2)
ns1
- the namespace to compare to argument ns2ns2
- the namespace to compare to argument ns1protected MarshalFramework.InheritanceMatch[] searchInheritance(String name, String namespace, XMLClassDescriptor classDesc) throws MarshalException
name
- XML name of the fieldnamespace
- namespace of the fieldclassDesc
- the class descriptor to match againstcdResolver
- the class descriptor resolver to useMarshalException
- if the resolver called fails fatallyCopyright © 2015. All rights reserved.