|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.exolab.castor.xml.UnmarshalHandler
public final class UnmarshalHandler
An unmarshaller to allowing unmarshaling of XML documents to Java Objects. The Class must specify the proper access methods (setters/getters) in order for instances of the Class to be properly unmarshaled.
| Nested Class Summary | |
|---|---|
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. |
| Field Summary | |
|---|---|
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. |
| Constructor Summary | |
|---|---|
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. |
| Method Summary | |
|---|---|
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 Signals the end of an element |
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. the entire object model) being unmarshalled. |
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 Signals the start of element. |
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)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
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
| Constructor Detail |
|---|
protected UnmarshalHandler()
protected UnmarshalHandler(Class<?> topClass)
topClass - the Class to create the UnmarshalHandler for
protected UnmarshalHandler(InternalContext internalContext,
Class<?> topClass)
internalContext - the InternalContext to usetopClass - the Class to work for| Method Detail |
|---|
public 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 interface
UnmarshalListener.
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 ContentHandlercharacters in interface DocumentHandlerSAXException
public void endDocument()
throws SAXException
endDocument in interface ContentHandlerendDocument in interface DocumentHandlerSAXException
public void endElement(String name)
throws SAXException
endElement in interface DocumentHandlerSAXException
public void endElement(String namespaceURI,
String localName,
String qName)
throws SAXException
ContentHandler#endElement
Signals the end of an element
endElement in interface ContentHandlerlocalName - The name of the element.
SAXException
public void endPrefixMapping(String prefix)
throws SAXException
endPrefixMapping in interface ContentHandlerprefix - the namespace prefix
SAXException
public void ignorableWhitespace(char[] ch,
int start,
int length)
throws SAXException
ignorableWhitespace in interface ContentHandlerignorableWhitespace in interface DocumentHandlerSAXException
public void processingInstruction(String target,
String data)
throws SAXException
processingInstruction in interface ContentHandlerprocessingInstruction in interface DocumentHandlerSAXExceptionpublic void setDocumentLocator(Locator locator)
setDocumentLocator in interface ContentHandlersetDocumentLocator in interface DocumentHandlerpublic Locator getDocumentLocator()
public void skippedEntity(String name)
throws SAXException
skippedEntity in interface ContentHandlername - the skipped entity's name
SAXException
public void startDocument()
throws SAXException
startDocument in interface ContentHandlerstartDocument in interface DocumentHandlerSAXException
public void startElement(String namespaceURI,
String localName,
String qName,
Attributes atts)
throws SAXException
ContentHandler#startElement
Signals the start of element.
startElement in interface ContentHandlerlocalName - 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 DocumentHandlername - 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 ContentHandlerprefix - the namespace prefix to mapuri - the namespace URI
SAXException
public void error(SAXParseException exception)
throws SAXException
error in interface ErrorHandlerSAXException
public void fatalError(SAXParseException exception)
throws SAXException
fatalError in interface ErrorHandlerSAXException
public void warning(SAXParseException exception)
throws SAXException
warning in interface ErrorHandlerSAXException
public static Object toPrimitiveObject(Class<?> type,
String value)
String to the given primitive object type.
type - the class type of the primitive in which
to convert the String tovalue - the String to convert to a primitive
Objectpublic 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 instance
UnmarshalListenerDelegate 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 check
public CollectionHandler getCollectionHandler(Class clazz)
clazz - the Class to check
public static boolean namespaceEquals(String ns1,
String ns2)
ns1 - the namespace to compare to argument ns2ns2 - the namespace to compare to argument ns1
protected 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 use
MarshalException - if the resolver called fails fatally
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||