Public Member Functions | Static Public Member Functions | Package Attributes

org.exolab.castor.xml.Unmarshaller Class Reference

List of all members.

Public Member Functions

 Unmarshaller ()
 Unmarshaller (Class c)
 Unmarshaller (Class c, ClassLoader loader)
 Unmarshaller (Mapping mapping) throws MappingException
 Unmarshaller (Object root)
void addNamespaceToPackageMapping (String nsURI, String packageName)
UnmarshalHandler createHandler ()
void setClassLoader (ClassLoader loader)
void setClearCollections (boolean clear)
void setDebug (boolean debug)
void setEntityResolver (EntityResolver entityResolver)
void setIDResolver (IDResolver idResolver)
void setIgnoreExtraAttributes (boolean ignoreExtraAtts)
void setIgnoreExtraElements (boolean ignoreExtraElements)
void setLogWriter (PrintWriter printWriter)
void setMapping (Mapping mapping) throws MappingException
void setReuseObjects (boolean reuse)
void setResolver (ClassDescriptorResolver cdr)
void setUnmarshalListener (UnmarshalListener listener)
void setValidation (boolean validate)
void setWhitespacePreserve (boolean preserve)
Object unmarshal (Reader reader) throws MarshalException, ValidationException
Object unmarshal (EventProducer eventProducer) throws MarshalException, ValidationException
Object unmarshal (InputSource source) throws MarshalException, ValidationException
Object unmarshal (Node node) throws MarshalException, ValidationException

Static Public Member Functions

static ContentHandler getContentHandler (UnmarshalHandler handler) throws SAXException
static Object unmarshal (Class c, Reader reader) throws MarshalException, ValidationException
static Object unmarshal (Class c, InputSource source) throws MarshalException, ValidationException
static Object unmarshal (Class c, Node node) throws MarshalException, ValidationException

Package Attributes

EntityResolver entityResolver = null

Detailed Description

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.

Author:
Keith Visco
Version:
Revision:
1.9
Date:
2004/11/05 05:44:00

Constructor & Destructor Documentation

org.exolab.castor.xml.Unmarshaller.Unmarshaller (  ) 

Creates a new basic Unmarshaller

When using this constructor it will most likely be necessary to use a mapping file or ClassDescriptorResolver So that the Unmarshaller can find the classes during the unmarshalling process.

Referenced by org.exolab.castor.xml.Unmarshaller.unmarshal().

org.exolab.castor.xml.Unmarshaller.Unmarshaller ( 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.
org.exolab.castor.xml.Unmarshaller.Unmarshaller ( Class  c,
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.
loader,the ClassLoader to use.
org.exolab.castor.xml.Unmarshaller.Unmarshaller ( Mapping  mapping  )  throws MappingException

Creates a new Unmarshaller with the given Mapping

Parameters:
mapping,the Mapping to use

References org.exolab.castor.xml.Unmarshaller.setMapping().

org.exolab.castor.xml.Unmarshaller.Unmarshaller ( Object  root  ) 

Creates a new Unmarshaller with the given Object

Parameters:
root the instance to unmarshal into. This may be null, if the Unmarshaller.setMapping is called to load a mapping for the root element of xml document.

Member Function Documentation

void org.exolab.castor.xml.Unmarshaller.addNamespaceToPackageMapping ( String  nsURI,
String  packageName 
)

Adds a mapping from the given namespace URI to the given package name

Parameters:
nsURI the namespace URI to map from
packageName the package name to map to
UnmarshalHandler org.exolab.castor.xml.Unmarshaller.createHandler (  ) 
static ContentHandler org.exolab.castor.xml.Unmarshaller.getContentHandler ( UnmarshalHandler  handler  )  throws SAXException [static]

Returns a ContentHandler for the given UnmarshalHandler

Returns:
the ContentHandler
void org.exolab.castor.xml.Unmarshaller.setClassLoader ( ClassLoader  loader  ) 

Sets the ClassLoader to use when loading new classes.
Note:This ClassLoader is used for classes loaded by the unmarshaller only. If a Mapping has been set, the Mapping has it's own ClassLoader and may also need to be set propertly.

Parameters:
loader the ClassLoader to use
void org.exolab.castor.xml.Unmarshaller.setClearCollections ( boolean  clear  ) 

Sets whether or not to clear collections (including arrays) upon first use to remove default values. By default, and for backward compatibility with previous versions of Castor this value is false, indicating that collections are not cleared before initial use by Castor.

Parameters:
clear the boolean value that when true indicates collections should be cleared upon first use.
void org.exolab.castor.xml.Unmarshaller.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
void org.exolab.castor.xml.Unmarshaller.setEntityResolver ( 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.
void org.exolab.castor.xml.Unmarshaller.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.
void org.exolab.castor.xml.Unmarshaller.setIgnoreExtraAttributes ( boolean  ignoreExtraAtts  ) 

Sets whether or not attributes that do not match a specific field should simply be ignored or reported as an error. By default, extra attributes are ignored.

Parameters:
ignoreExtraAtts a boolean that when true will allow non-matched attributes to simply be ignored.
void org.exolab.castor.xml.Unmarshaller.setIgnoreExtraElements ( boolean  ignoreExtraElements  ) 

Sets whether or not elements that do not match a specific field should simply be ignored or reported as an error. By default, extra elements are flagged as an error.

Parameters:
ignoreExtraElements a boolean that when true will allow non-matched elements to simply be ignored.
void org.exolab.castor.xml.Unmarshaller.setLogWriter ( PrintWriter  printWriter  ) 

Sets the PrintWriter used for logging

Parameters:
printWriter the PrintWriter to use for logging
void org.exolab.castor.xml.Unmarshaller.setMapping ( Mapping  mapping  )  throws MappingException

Sets the Mapping to use during unmarshalling. If the Mapping has a ClassLoader it will be used during unmarshalling.

Parameters:
mapping the Mapping to use during unmarshalling.
See also:
setResolver

References org.exolab.castor.xml.ClassDescriptorResolver.setMappingLoader().

Referenced by org.exolab.castor.xml.Unmarshaller.Unmarshaller().

void org.exolab.castor.xml.Unmarshaller.setResolver ( ClassDescriptorResolver  cdr  ) 

Sets the ClassDescriptorResolver to use during unmarshalling

Parameters:
cdr the ClassDescriptorResolver to use
See also:
setMapping
Note: This method will nullify any Mapping currently being used by this Unmarshaller
void org.exolab.castor.xml.Unmarshaller.setReuseObjects ( boolean  reuse  ) 

Sets a boolean that when true indicates that objects contained within the object model should be re-used where appropriate. This is only valid when unmarshalling to an existing object.

Parameters:
reuse the boolean indicating whether or not to re-use existing objects in the object model.
void org.exolab.castor.xml.Unmarshaller.setUnmarshalListener ( UnmarshalListener  listener  ) 

Sets an optional UnmarshalListener to receive pre and post unmarshal notification for each Object in the tree. An UnmarshalListener is often used to allow objects to appropriately initialize themselves by taking appliction specific behavior as they are unloaded. Current only one (1) listener is allowed. If you need register multiple listeners, you will have to create your own master listener that will forward the event notifications and manage the multiple listeners.

Parameters:
listener the UnmarshalListener to set.
void org.exolab.castor.xml.Unmarshaller.setValidation ( boolean  validate  ) 
void org.exolab.castor.xml.Unmarshaller.setWhitespacePreserve ( boolean  preserve  ) 

Sets the top-level whitespace (xml:space) to either preserving or non preserving. The XML document can override this value using xml:space on specific elements.This sets the "default" behavior when xml:space="default".

Parameters:
preserve a boolean that when true enables whitespace preserving by default.

Referenced by com.cosylab.acs.laser.dao.ACSAlarmDAOImpl.loadAlarms(), cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl.loadAlarms(), com.cosylab.acs.laser.dao.ACSCategoryDAOImpl.loadCategories(), cl.utfsm.acs.acg.dao.ACSCategoryDAOImpl.loadCategories(), alma.acs.component.dynwrapper.CastorUnmarshalMapper.translate(), and org.exolab.castor.xml.Unmarshaller.unmarshal().

Object org.exolab.castor.xml.Unmarshaller.unmarshal ( Reader  reader  )  throws MarshalException, ValidationException
Object org.exolab.castor.xml.Unmarshaller.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
Exceptions:
MarshalException when there is an error during the unmarshalling process
ValidationException when there is a validation error

References org.exolab.castor.xml.Unmarshaller.createHandler(), org.exolab.castor.xml.UnmarshalHandler.getDocumentLocator(), org.exolab.castor.xml.UnmarshalHandler.getObject(), org.exolab.castor.xml.FileLocation.setColumnNumber(), org.exolab.castor.xml.FileLocation.setFilename(), org.exolab.castor.xml.FileLocation.setLineNumber(), and org.exolab.castor.xml.XMLException.setLocation().

static Object org.exolab.castor.xml.Unmarshaller.unmarshal ( Class  c,
Reader  reader 
) throws MarshalException, ValidationException [static]

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.

Note:This is a *static* method, any mapping files set on a particular Unmarshaller instance, and any changes made via setters will be unavailable to this method.

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

References org.exolab.castor.xml.Unmarshaller.setWhitespacePreserve(), org.exolab.castor.xml.Unmarshaller.unmarshal(), and org.exolab.castor.xml.Unmarshaller.Unmarshaller().

Object org.exolab.castor.xml.Unmarshaller.unmarshal ( 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
Exceptions:
MarshalException when there is an error during the unmarshalling process
ValidationException when there is a validation error

References org.exolab.castor.xml.Unmarshaller.createHandler(), org.exolab.castor.xml.Unmarshaller.entityResolver, org.exolab.castor.xml.UnmarshalHandler.getDocumentLocator(), org.exolab.castor.xml.UnmarshalHandler.getObject(), org.exolab.castor.util.Configuration.getParser(), org.exolab.castor.util.Configuration.getXMLReader(), org.exolab.castor.xml.FileLocation.setColumnNumber(), org.exolab.castor.xml.FileLocation.setFilename(), org.exolab.castor.xml.FileLocation.setLineNumber(), and org.exolab.castor.xml.XMLException.setLocation().

static Object org.exolab.castor.xml.Unmarshaller.unmarshal ( Class  c,
Node  node 
) throws MarshalException, ValidationException [static]

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.

Note:This is a *static* method, any mapping files set on a particular Unmarshaller instance, and any changes made via setters will be unavailable to this method.

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

References org.exolab.castor.xml.Unmarshaller.unmarshal(), and org.exolab.castor.xml.Unmarshaller.Unmarshaller().

static Object org.exolab.castor.xml.Unmarshaller.unmarshal ( Class  c,
InputSource  source 
) throws MarshalException, ValidationException [static]

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.

Note:This is a *static* method, any mapping files set on a particular Unmarshaller instance, and any changes made via setters will be unavailable to this method.

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

References org.exolab.castor.xml.Unmarshaller.setWhitespacePreserve(), org.exolab.castor.xml.Unmarshaller.unmarshal(), and org.exolab.castor.xml.Unmarshaller.Unmarshaller().

Object org.exolab.castor.xml.Unmarshaller.unmarshal ( 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
Exceptions:
MarshalException when there is an error during the unmarshalling process
ValidationException when there is a validation error

References org.exolab.castor.xml.Unmarshaller.unmarshal().


Member Data Documentation

EntityResolver org.exolab.castor.xml.Unmarshaller.entityResolver = null [package]

The EntityResolver used for resolving entities

Referenced by org.exolab.castor.xml.Unmarshaller.unmarshal().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties