org.exolab.castor.xml
Class UnmarshalHandler

java.lang.Object
  extended byorg.exolab.castor.xml.MarshalFramework
      extended byorg.exolab.castor.xml.UnmarshalHandler
All Implemented Interfaces:
org.xml.sax.DocumentHandler, org.xml.sax.ErrorHandler

public final class UnmarshalHandler
extends MarshalFramework
implements org.xml.sax.DocumentHandler, org.xml.sax.ErrorHandler

An unmarshaller to allowing unmarshalling 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 unmarshalled.

Version:
$Revision: 1.81 $ $Date: 2002/01/31 19:02:27 $
Author:
Keith Visco

Nested Class Summary
static class MarshalFramework.InheritanceMatch
          Used to store the information when we find a possible inheritance.
(package private)  class UnmarshalHandler.IDResolverImpl
          Local IDResolver
(package private)  class UnmarshalHandler.ReferenceInfo
          Internal class used to save state for reference resolving
 
Field Summary
(package private) static java.lang.String JAVA_PREFIX
          The default prefix used for specifying the xsi:type as a classname instead of a schema name.
(package private) static java.lang.String QNAME_NAME
          The name of the QName type
static java.lang.String XSI_NAMESPACE
          The XSI Namespace URI
 
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 _class)
          Creates a new UnmarshalHandler
 
Method Summary
 void characters(char[] ch, int start, int length)
           
 void endDocument()
           
 void endElement(java.lang.String name)
           
 void error(org.xml.sax.SAXParseException exception)
           
 void fatalError(org.xml.sax.SAXParseException exception)
           
 org.xml.sax.Locator getDocumentLocator()
           
 java.lang.Object getObject()
           
 void ignorableWhitespace(char[] ch, int start, int length)
           
(package private) static boolean isPrimitive(java.lang.Class type)
          Returns true if the given class should be treated as a primitive type.
 void processingInstruction(java.lang.String target, java.lang.String data)
           
static MarshalFramework.InheritanceMatch[] searchInheritance(java.lang.String name, java.lang.String namespace, XMLClassDescriptor classDesc, ClassDescriptorResolver cdResolver)
          Search there is a field descriptor which can accept one of the class descriptor which match the given name and namespace.
 void setClassLoader(java.lang.ClassLoader loader)
          Sets the ClassLoader to use when loading classes
 void setDebug(boolean debug)
          Turns debuging on or off.
 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 setLogWriter(java.io.PrintWriter printWriter)
          Sets the PrintWriter used for printing log messages
 void setResolver(ClassDescriptorResolver cdResolver)
          Sets the ClassDescriptorResolver to use for loading and resolving ClassDescriptors
 void setValidation(boolean validate)
          Sets the flag for validation
 void startDocument()
           
 void startElement(java.lang.String name, org.xml.sax.AttributeList atts)
           
static java.lang.Object toPrimitiveObject(java.lang.Class type, java.lang.String value)
          Converts a String to the given primitive object type
 void warning(org.xml.sax.SAXParseException exception)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XSI_NAMESPACE

public static final java.lang.String XSI_NAMESPACE
The XSI Namespace URI

See Also:
Constant Field Values

JAVA_PREFIX

static final java.lang.String JAVA_PREFIX
The default prefix used for specifying the xsi:type as a classname instead of a schema name. This is a Castor specific hack.

See Also:
Constant Field Values

QNAME_NAME

static final java.lang.String QNAME_NAME
The name of the QName type

See Also:
Constant Field Values
Constructor Detail

UnmarshalHandler

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.


UnmarshalHandler

protected UnmarshalHandler(java.lang.Class _class)
Creates a new UnmarshalHandler

Parameters:
_class - the Class to create the UnmarshalHandler for
Method Detail

getObject

public java.lang.Object getObject()

setClassLoader

public void setClassLoader(java.lang.ClassLoader loader)
Sets the ClassLoader to use when loading classes

Parameters:
loader - the ClassLoader to use

setResolver

public void setResolver(ClassDescriptorResolver cdResolver)
Sets the ClassDescriptorResolver to use for loading and resolving ClassDescriptors

Parameters:
cdResolver - the ClassDescriptorResolver to use

setDebug

public void setDebug(boolean debug)
Turns debuging on or off. If no Log Writer has been set, then System.out will be used to display debug information

Parameters:
debug - the flag indicating whether to generate debug information. A value of true, will turn debuggin on.
See Also:
setLogWriter(java.io.PrintWriter)

setIDResolver

public void setIDResolver(IDResolver idResolver)
Sets the IDResolver to use when resolving IDREFs for which no associated element may exist in XML document.

Parameters:
idResolver - the IDResolver to use when resolving IDREFs for which no associated element may exist in the XML document.

setLogWriter

public void setLogWriter(java.io.PrintWriter printWriter)
Sets the PrintWriter used for printing log messages

Parameters:
printWriter - the PrintWriter to use when printing log messages

setValidation

public void setValidation(boolean validate)
Sets the flag for validation


characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Specified by:
characters in interface org.xml.sax.DocumentHandler
Throws:
org.xml.sax.SAXException

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Specified by:
endDocument in interface org.xml.sax.DocumentHandler
Throws:
org.xml.sax.SAXException

endElement

public void endElement(java.lang.String name)
                throws org.xml.sax.SAXException
Specified by:
endElement in interface org.xml.sax.DocumentHandler
Throws:
org.xml.sax.SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws org.xml.sax.SAXException
Specified by:
ignorableWhitespace in interface org.xml.sax.DocumentHandler
Throws:
org.xml.sax.SAXException

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException
Specified by:
processingInstruction in interface org.xml.sax.DocumentHandler
Throws:
org.xml.sax.SAXException

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
Specified by:
setDocumentLocator in interface org.xml.sax.DocumentHandler

getDocumentLocator

public org.xml.sax.Locator getDocumentLocator()

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Specified by:
startDocument in interface org.xml.sax.DocumentHandler
Throws:
org.xml.sax.SAXException

startElement

public void startElement(java.lang.String name,
                         org.xml.sax.AttributeList atts)
                  throws org.xml.sax.SAXException
Specified by:
startElement in interface org.xml.sax.DocumentHandler
Throws:
org.xml.sax.SAXException

error

public void error(org.xml.sax.SAXParseException exception)
           throws org.xml.sax.SAXException
Specified by:
error in interface org.xml.sax.ErrorHandler
Throws:
org.xml.sax.SAXException

fatalError

public void fatalError(org.xml.sax.SAXParseException exception)
                throws org.xml.sax.SAXException
Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Throws:
org.xml.sax.SAXException

warning

public void warning(org.xml.sax.SAXParseException exception)
             throws org.xml.sax.SAXException
Specified by:
warning in interface org.xml.sax.ErrorHandler
Throws:
org.xml.sax.SAXException

toPrimitiveObject

public static java.lang.Object toPrimitiveObject(java.lang.Class type,
                                                 java.lang.String value)
Converts a String to the given primitive object type

Parameters:
type - the class type of the primitive in which to convert the String to
value - the String to convert to a primitive
Returns:
the new primitive Object

isPrimitive

static boolean isPrimitive(java.lang.Class type)
Returns true if the given class should be treated as a primitive type. This method will return true for all Java primitive types, the set of primitive object wrappers, as well as Strings.

Returns:
true if the given class should be treated as a primitive type

searchInheritance

public static MarshalFramework.InheritanceMatch[] searchInheritance(java.lang.String name,
                                                                    java.lang.String namespace,
                                                                    XMLClassDescriptor classDesc,
                                                                    ClassDescriptorResolver cdResolver)
Search there is a field descriptor which can accept one of the class descriptor which match the given name and namespace.



Intalio Inc. (C) 1999-2001. All rights reserved http://www.intalio.com