org.exolab.castor.xml
Class Unmarshaller

java.lang.Object
  extended byorg.exolab.castor.xml.Unmarshaller

public class Unmarshaller
extends java.lang.Object

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.31 $ $Date: 2002/01/30 20:42:31 $
Author:
Keith Visco

Field Summary
(package private)  org.xml.sax.EntityResolver entityResolver
          The EntityResolver used for resolving entities
 
Constructor Summary
Unmarshaller(java.lang.Class c)
          Creates a new Unmarshaller with the given Class
Unmarshaller(java.lang.Class c, java.lang.ClassLoader loader)
          Creates a new Unmarshaller with the given Class
Unmarshaller(Mapping mapping)
          Creates a new Unmarshaller with the given Mapping
 
Method Summary
 UnmarshalHandler createHandler()
          Creates and initalizes an UnmarshalHandler
 void setClassLoader(java.lang.ClassLoader loader)
          Sets the ClassLoader to use when loading new classes
 void setDebug(boolean debug)
          Turns debuging on or off.
 void setEntityResolver(org.xml.sax.EntityResolver entityResolver)
          Sets the EntityResolver to use when resolving system and public ids with respect to entites and Document Type.
 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 logging
 void setMapping(Mapping mapping)
          Sets the Mapping to use during unmarshalling.
 void setResolver(ClassDescriptorResolver cdr)
          Sets the ClassDescriptorResolver to use during unmarshalling
 void setValidation(boolean validate)
          Sets the flag for validation
static java.lang.Object unmarshal(java.lang.Class c, org.xml.sax.InputSource source)
          Unmarshals Objects of the given Class type.
static java.lang.Object unmarshal(java.lang.Class c, org.w3c.dom.Node node)
          Unmarshals Objects of the given Class type.
static java.lang.Object unmarshal(java.lang.Class c, java.io.Reader reader)
          Unmarshals Objects of the given Class type.
 java.lang.Object unmarshal(EventProducer eventProducer)
          Unmarshals Objects of this Unmarshaller's Class type.
 java.lang.Object unmarshal(org.xml.sax.InputSource source)
          Unmarshals Objects of this Unmarshaller's Class type.
 java.lang.Object unmarshal(org.w3c.dom.Node node)
          Unmarshals Objects of this Unmarshaller's Class type.
 java.lang.Object unmarshal(java.io.Reader reader)
          Unmarshals Objects of this Unmarshaller's Class type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entityResolver

org.xml.sax.EntityResolver entityResolver
The EntityResolver used for resolving entities

Constructor Detail

Unmarshaller

public Unmarshaller(java.lang.Class c)
Creates a new Unmarshaller with the given Class

Parameters:
c - the Class to create the Unmarshaller for, this may be null, if the Unmarshaller#setMapping is called to load a mapping for the root element of xml document.

Unmarshaller

public Unmarshaller(java.lang.Class c,
                    java.lang.ClassLoader loader)
Creates a new Unmarshaller with the given Class

Parameters:
c - the Class to create the Unmarshaller for, this may be null, if the Unmarshaller#setMapping is called to load a mapping for the root element of xml document.

Unmarshaller

public Unmarshaller(Mapping mapping)
             throws MappingException
Creates a new Unmarshaller with the given Mapping

Method Detail

setClassLoader

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

Parameters:
loader - the ClassLoader 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)

setEntityResolver

public void setEntityResolver(org.xml.sax.EntityResolver entityResolver)
Sets the EntityResolver to use when resolving system and public ids with respect to entites and Document Type.

Parameters:
entityResolver - the EntityResolver to use when resolving System and Public ids.

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 logging

Parameters:
printWriter - the PrintWriter to use for logging

setMapping

public void setMapping(Mapping mapping)
                throws MappingException
Sets the Mapping to use during unmarshalling.

Parameters:
mapping - the Mapping to use during unmarshalling.
Throws:
MappingException
See Also:
setResolver(org.exolab.castor.xml.ClassDescriptorResolver)

setResolver

public void setResolver(ClassDescriptorResolver cdr)
Sets the ClassDescriptorResolver to use during unmarshalling

Parameters:
cdr - the ClassDescriptorResolver to use
See Also:

Note: This method will nullify any Mapping currently being used by this Unmarshaller

setValidation

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


unmarshal

public java.lang.Object unmarshal(java.io.Reader reader)
                           throws MarshalException,
                                  ValidationException
Unmarshals Objects of this Unmarshaller's Class type. The Class must specify the proper access methods (setters/getters) in order for instances of the Class to be properly unmarshalled.

Parameters:
reader - the Reader to read the XML from
Throws:
MarshalException - when there is an error during the unmarshalling process
ValidationException - when there is a validation error

unmarshal

public java.lang.Object unmarshal(EventProducer eventProducer)
                           throws MarshalException,
                                  ValidationException
Unmarshals Objects of this Unmarshaller's Class type. The Class must specify the proper access methods (setters/getters) in order for instances of the Class to be properly unmarshalled.

Parameters:
eventProducer - the EventProducer which produces the SAX events
Throws:
MarshalException - when there is an error during the unmarshalling process
ValidationException - when there is a validation error

unmarshal

public java.lang.Object unmarshal(org.xml.sax.InputSource source)
                           throws MarshalException,
                                  ValidationException
Unmarshals Objects of this Unmarshaller's Class type. The Class must specify the proper access methods (setters/getters) in order for instances of the Class to be properly unmarshalled.

Parameters:
source - the InputSource to read the XML from
Throws:
MarshalException - when there is an error during the unmarshalling process
ValidationException - when there is a validation error

unmarshal

public java.lang.Object unmarshal(org.w3c.dom.Node node)
                           throws MarshalException,
                                  ValidationException
Unmarshals Objects of this Unmarshaller's Class type. The Class must specify the proper access methods (setters/getters) in order for instances of the Class to be properly unmarshalled.

Parameters:
node - the DOM node to read the XML from
Throws:
MarshalException - when there is an error during the unmarshalling process
ValidationException - when there is a validation error

unmarshal

public static java.lang.Object unmarshal(java.lang.Class c,
                                         java.io.Reader reader)
                                  throws MarshalException,
                                         ValidationException
Unmarshals Objects of the given Class type. The Class must specify the proper access methods (setters/getters) in order for instances of the Class to be properly unmarshalled.

Parameters:
c - the Class to create a new instance of
reader - the Reader to read the XML from
Throws:
MarshalException - when there is an error during the unmarshalling process
ValidationException - when there is a validation error

unmarshal

public static java.lang.Object unmarshal(java.lang.Class c,
                                         org.xml.sax.InputSource source)
                                  throws MarshalException,
                                         ValidationException
Unmarshals Objects of the given Class type. The Class must specify the proper access methods (setters/getters) in order for instances of the Class to be properly unmarshalled.

Parameters:
c - the Class to create a new instance of
source - the InputSource to read the XML from
Throws:
MarshalException - when there is an error during the unmarshalling process
ValidationException - when there is a validation error

unmarshal

public static java.lang.Object unmarshal(java.lang.Class c,
                                         org.w3c.dom.Node node)
                                  throws MarshalException,
                                         ValidationException
Unmarshals Objects of the given Class type. The Class must specify the proper access methods (setters/getters) in order for instances of the Class to be properly unmarshalled.

Parameters:
c - the Class to create a new instance of
Throws:
MarshalException - when there is an error during the unmarshalling process
ValidationException - when there is a validation error

createHandler

public UnmarshalHandler createHandler()
Creates and initalizes an UnmarshalHandler

Returns:
the new UnmarshalHandler


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