|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.exolab.castor.xml.MarshalFramework
org.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 | |
|---|---|
(package private) class |
UnmarshalHandler.Arguments
Internal class used for passing constructor argument information. |
static class |
UnmarshalHandler.ArrayHandler
A class for handling Arrays during unmarshalling. |
| Nested classes/interfaces inherited from class org.exolab.castor.xml.MarshalFramework |
|---|
MarshalFramework.InheritanceMatch, MarshalFramework.InternalXMLClassDescriptor |
| Field Summary | |
|---|---|
(package private) static org.apache.commons.logging.Log |
LOG
Logger from commons-logging. |
(package private) static java.lang.String |
PRESERVE
|
protected static java.util.ResourceBundle |
resourceBundle
resource bundle |
(package private) static java.lang.String |
XML_SPACE
|
(package private) static java.lang.String |
XML_SPACE_WITH_PREFIX
|
| Fields inherited from class org.exolab.castor.xml.MarshalFramework |
|---|
INTERNAL_XML_NAME, JAVA_PREFIX, LANG_ATTR, NIL_ATTR, NO_FIELD_DESCRIPTORS, QNAME_NAME, SPACE_ATTR, TRUE_VALUE, TYPE_ATTR, XML_LANG_ATTR, XML_SPACE_ATTR, XSI_NAMESPACE, XSI_NIL_ATTR, XSI_NO_NAMESPACE_SCHEMA_LOCATION, XSI_SCHEMA_LOCATION |
| 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(java.lang.Class<?> topClass)
Creates a new UnmarshalHandler. |
protected |
UnmarshalHandler(InternalContext internalContext,
java.lang.Class<?> topClass)
Creates a new UnmarshalHandler. |
| Method Summary | |
|---|---|
void |
addNamespaceToPackageMapping(java.lang.String nsURI,
java.lang.String packageName)
Adds a mapping from the given namespace URI to the given package name |
(package private) void |
addReference(java.lang.String idRef,
java.lang.Object parent,
XMLFieldDescriptor descriptor)
Adds the given reference to the "queue" until the referenced object has been unmarshalled. |
void |
characters(char[] ch,
int start,
int length)
|
(package private) java.lang.String |
className(java.lang.Class<?> type)
Returns the name of a class, handles array types |
(package private) java.lang.Object |
createInstance(java.lang.Class<?> type,
UnmarshalHandler.Arguments args)
Creates an instance of the given class /type, using the arguments provided (if there are any). |
(package private) byte[] |
decodeBinaryData(XMLFieldDescriptor descriptor,
java.lang.String binaryData)
Decode binary data and return decoded value. |
void |
endDocument()
|
void |
endElement(java.lang.String name)
|
void |
endElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qName)
ContentHandler#endElement |
void |
endPrefixMapping(java.lang.String prefix)
Signals to end the namespace prefix mapping |
void |
error(org.xml.sax.SAXParseException exception)
|
void |
fatalError(org.xml.sax.SAXParseException exception)
|
AnyNode |
getAnyNode()
returns the AnyNode (if any). |
AnyNodeUnmarshalHandler |
getAnyNodeHandler()
Returns the currently used AnyNodeUnmarshalHandler instance. |
(package private) XMLClassDescriptor |
getClassDescriptor(java.lang.Class<?> cls)
Finds and returns an XMLClassDescriptor for the given class. |
(package private) XMLClassDescriptor |
getClassDescriptor(java.lang.String className,
java.lang.ClassLoader loader)
Finds and returns a ClassDescriptor for the given class. |
java.lang.ClassLoader |
getClassLoader()
Returns the current ClassLoader in use. |
java.lang.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 |
org.xml.sax.Locator |
getDocumentLocator()
|
(package private) java.lang.String |
getInstanceType(AttributeSet atts,
java.lang.String currentPackage)
Returns the resolved instance type attribute (xsi:type). |
(package private) java.lang.String |
getJavaPackage(java.lang.Class<?> type)
Returns the package for the given Class |
NamespaceHandling |
getNamespaceHandling()
Returns the NamespaceHandling in use. |
java.lang.Object |
getObject()
Returns the "root" Object (ie. |
ObjectFactory |
getObjectFactory()
Returns the ObjectFactory instance in use. |
java.util.Hashtable<java.lang.String,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. |
boolean |
isReuseObjects()
Indicats whether Object instances should be re-used. |
(package private) boolean |
isValidating()
Indicates whether validation is enabled or not. |
(package private) static boolean |
isWhitespace(java.lang.StringBuffer sb)
Checks the given StringBuffer to determine if it only contains whitespace. |
(package private) java.lang.Class<?> |
loadClass(java.lang.String className,
java.lang.ClassLoader loader)
Loads and returns the class with the given class name using the given loader. |
(package private) void |
processAttributes(AttributeSet atts,
XMLClassDescriptor classDesc)
Processes the given attribute list, and attempts to add each Attributes to the current Object on the stack. |
(package private) UnmarshalHandler.Arguments |
processConstructorArgs(AttributeSet atts,
XMLClassDescriptor classDesc)
Processes the given attribute set, and creates the constructor arguments. |
(package private) void |
processFirstElement(java.lang.String name,
java.lang.String namespace,
AttributeSet atts,
java.lang.String xmlSpace)
|
(package private) boolean |
processIDREF(java.lang.String idRef,
XMLFieldDescriptor descriptor,
java.lang.Object parent)
Processes the given IDREF. |
void |
processingInstruction(java.lang.String target,
java.lang.String data)
|
(package private) void |
processWrapperAttributes(AttributeSet atts)
Processes the given AttributeSet for wrapper elements. |
(package private) XMLClassDescriptor |
resolveByXMLName(java.lang.String name,
java.lang.String namespace,
java.lang.ClassLoader loader)
Returns the XMLClassLoader |
void |
setAnyNode(AnyNode node)
sets the AnyNode |
void |
setClassLoader(java.lang.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(org.xml.sax.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 |
setLogWriter(java.io.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(java.lang.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(java.lang.String name)
Signals that an entity was skipped by the parser |
void |
startDocument()
Signals the start of a new document |
void |
startElement(java.lang.String name,
org.xml.sax.AttributeList attList)
Deprecated. |
void |
startElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes atts)
ContentHandler#startElement |
(package private) void |
startElementProcessing(java.lang.String name,
java.lang.String namespace,
AttributeSet atts)
Signals the start of an element with the given name. |
void |
startPrefixMapping(java.lang.String prefix,
java.lang.String uri)
Signals to start the namespace - prefix mapping |
static java.lang.Object |
toPrimitiveObject(java.lang.Class<?> type,
java.lang.String value)
Converts a String to the given primitive object type. |
(package private) java.lang.Object |
toPrimitiveObject(java.lang.Class<?> type,
java.lang.String value,
XMLFieldDescriptor fieldDesc)
Converts a String to the given primitive object type. |
void |
warning(org.xml.sax.SAXParseException exception)
|
| Methods inherited from class org.exolab.castor.xml.MarshalFramework |
|---|
getCollectionHandler, getInternalContext, getJavaNaming, hasFieldsAtLocation, isCollection, isEnum, isPrimitive, namespaceEquals, primitiveOrWrapperEquals, searchInheritance, setInternalContext |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
static final org.apache.commons.logging.Log LOG
protected static java.util.ResourceBundle resourceBundle
static final java.lang.String XML_SPACE
static final java.lang.String XML_SPACE_WITH_PREFIX
static final java.lang.String PRESERVE
| Constructor Detail |
|---|
protected UnmarshalHandler()
protected UnmarshalHandler(java.lang.Class<?> topClass)
topClass - the Class to create the UnmarshalHandler for
protected UnmarshalHandler(InternalContext internalContext,
java.lang.Class<?> topClass)
internalContext - the InternalContext to usetopClass - the Class to work for| Method Detail |
|---|
public void addNamespaceToPackageMapping(java.lang.String nsURI,
java.lang.String packageName)
nsURI - the namespace URI to map frompackageName - the package name to map topublic java.lang.Object getCurrentObject()
public java.lang.Object getObject()
public void setClassLoader(java.lang.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(java.io.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(java.lang.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 org.xml.sax.SAXException
characters in interface org.xml.sax.ContentHandlercharacters in interface org.xml.sax.DocumentHandlerorg.xml.sax.SAXException
public void endDocument()
throws org.xml.sax.SAXException
endDocument in interface org.xml.sax.ContentHandlerendDocument in interface org.xml.sax.DocumentHandlerorg.xml.sax.SAXException
public void endElement(java.lang.String name)
throws org.xml.sax.SAXException
endElement in interface org.xml.sax.DocumentHandlerorg.xml.sax.SAXException
byte[] decodeBinaryData(XMLFieldDescriptor descriptor,
java.lang.String binaryData)
descriptor - XMLFieldDescriptor instance for the field whose value requires decoding.binaryData - The binary data value to be decoded
public void endElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qName)
throws org.xml.sax.SAXException
ContentHandler#endElement
Signals the end of an element
endElement in interface org.xml.sax.ContentHandlerlocalName - The name of the element.
org.xml.sax.SAXException
public void endPrefixMapping(java.lang.String prefix)
throws org.xml.sax.SAXException
endPrefixMapping in interface org.xml.sax.ContentHandlerprefix - the namespace prefix
org.xml.sax.SAXException
public void ignorableWhitespace(char[] ch,
int start,
int length)
throws org.xml.sax.SAXException
ignorableWhitespace in interface org.xml.sax.ContentHandlerignorableWhitespace in interface org.xml.sax.DocumentHandlerorg.xml.sax.SAXException
public void processingInstruction(java.lang.String target,
java.lang.String data)
throws org.xml.sax.SAXException
processingInstruction in interface org.xml.sax.ContentHandlerprocessingInstruction in interface org.xml.sax.DocumentHandlerorg.xml.sax.SAXExceptionpublic void setDocumentLocator(org.xml.sax.Locator locator)
setDocumentLocator in interface org.xml.sax.ContentHandlersetDocumentLocator in interface org.xml.sax.DocumentHandlerpublic org.xml.sax.Locator getDocumentLocator()
public void skippedEntity(java.lang.String name)
throws org.xml.sax.SAXException
skippedEntity in interface org.xml.sax.ContentHandlername - the skipped entity's name
org.xml.sax.SAXException
public void startDocument()
throws org.xml.sax.SAXException
startDocument in interface org.xml.sax.ContentHandlerstartDocument in interface org.xml.sax.DocumentHandlerorg.xml.sax.SAXException
public void startElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes atts)
throws org.xml.sax.SAXException
ContentHandler#startElement
Signals the start of element.
startElement in interface org.xml.sax.ContentHandlerlocalName - The name of the element.atts - The AttributeList containing the associated attributes for the element.
org.xml.sax.SAXException
public void startElement(java.lang.String name,
org.xml.sax.AttributeList attList)
throws org.xml.sax.SAXException
DocumentHandler#startElement
Signals the start of element.
startElement in interface org.xml.sax.DocumentHandlername - The name of the element.attList - The AttributeList containing the associated attributes for the
element.
org.xml.sax.SAXException
void startElementProcessing(java.lang.String name,
java.lang.String namespace,
AttributeSet atts)
throws org.xml.sax.SAXException
name - the NCName of the element. It is an error
if the name is a QName (ie. contains a prefix).namespace - the namespace of the element. This may be null.
Note: A null namespace is not the same as the default namespace unless
the default namespace is also null.atts - the AttributeSet containing the attributes associated
with the element.
org.xml.sax.SAXException
void processFirstElement(java.lang.String name,
java.lang.String namespace,
AttributeSet atts,
java.lang.String xmlSpace)
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionboolean isValidating()
public void startPrefixMapping(java.lang.String prefix,
java.lang.String uri)
throws org.xml.sax.SAXException
startPrefixMapping in interface org.xml.sax.ContentHandlerprefix - the namespace prefix to mapuri - the namespace URI
org.xml.sax.SAXException
public void error(org.xml.sax.SAXParseException exception)
throws org.xml.sax.SAXException
error in interface org.xml.sax.ErrorHandlerorg.xml.sax.SAXException
public void fatalError(org.xml.sax.SAXParseException exception)
throws org.xml.sax.SAXException
fatalError in interface org.xml.sax.ErrorHandlerorg.xml.sax.SAXException
public void warning(org.xml.sax.SAXParseException exception)
throws org.xml.sax.SAXException
warning in interface org.xml.sax.ErrorHandlerorg.xml.sax.SAXException
void addReference(java.lang.String idRef,
java.lang.Object parent,
XMLFieldDescriptor descriptor)
idRef - the ID being referencedparent - the target/parent object for the fielddescriptor - the XMLFieldDescriptor for the field
java.lang.Object createInstance(java.lang.Class<?> type,
UnmarshalHandler.Arguments args)
throws org.xml.sax.SAXException
type - The class type to be used during instantiationargs - (Optional) arguments to be used during instantiation
org.xml.sax.SAXException
java.lang.String getInstanceType(AttributeSet atts,
java.lang.String currentPackage)
throws org.xml.sax.SAXException
atts - the AttributeList to search for the instance type
attribute.
org.xml.sax.SAXException
void processAttributes(AttributeSet atts,
XMLClassDescriptor classDesc)
throws org.xml.sax.SAXException
Attributes to the current Object on the stack.
atts - the AttributeSet to processclassDesc - the classDesc to use during processing
org.xml.sax.SAXException
void processWrapperAttributes(AttributeSet atts)
throws org.xml.sax.SAXException
atts - the AttributeSet to process
org.xml.sax.SAXException - If the AttributeSet cannot be processed
UnmarshalHandler.Arguments processConstructorArgs(AttributeSet atts,
XMLClassDescriptor classDesc)
throws org.xml.sax.SAXException
atts - the AttributeSet to processclassDesc - the XMLClassDescriptor of the objec
org.xml.sax.SAXException - If there's a problem creating the constructor argument set.
boolean processIDREF(java.lang.String idRef,
XMLFieldDescriptor descriptor,
java.lang.Object parent)
idRef - the ID of the object in which to referencedescriptor - the current FieldDescriptorparent - the current parent object
XMLClassDescriptor getClassDescriptor(java.lang.Class<?> cls)
throws org.xml.sax.SAXException
cls - the Class to get the ClassDescriptor for
org.xml.sax.SAXException
XMLClassDescriptor getClassDescriptor(java.lang.String className,
java.lang.ClassLoader loader)
throws org.xml.sax.SAXException
className - the name of the class to get the Descriptor for
org.xml.sax.SAXException
XMLClassDescriptor resolveByXMLName(java.lang.String name,
java.lang.String namespace,
java.lang.ClassLoader loader)
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionjava.lang.String getJavaPackage(java.lang.Class<?> type)
type - the Class to return the package of
java.lang.String className(java.lang.Class<?> type)
static boolean isWhitespace(java.lang.StringBuffer sb)
sb - the StringBuffer to check
java.lang.Class<?> loadClass(java.lang.String className,
java.lang.ClassLoader loader)
throws java.lang.ClassNotFoundException
className - the name of the class to loadloader - the ClassLoader to use, this may be null.
java.lang.ClassNotFoundException
java.lang.Object toPrimitiveObject(java.lang.Class<?> type,
java.lang.String value,
XMLFieldDescriptor fieldDesc)
throws org.xml.sax.SAXException
type - the class type of the primitive in which
to convert the String tovalue - the String to convert to a primitivefieldDesc - Descriptor for the given field (value)
org.xml.sax.SAXException - If the String cannot be converted to a primitive object type
public static java.lang.Object toPrimitiveObject(java.lang.Class<?> type,
java.lang.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 java.lang.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 java.util.Hashtable<java.lang.String,ReferenceInfo> getResolveTable()
public AnyNode getAnyNode()
public void setAnyNode(AnyNode node)
node - AnyNodepublic boolean isClearCollections()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||