Home » Castor-1.3-src » org.exolab.castor » xml » [javadoc | source]
org.exolab.castor.xml
public class: Unmarshaller [javadoc | source]
java.lang.Object
   org.exolab.castor.xml.Unmarshaller
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.
Field Summary
 EntityResolver entityResolver    The EntityResolver used for resolving entities 
Constructor:
 public Unmarshaller() 
 public Unmarshaller(Class clazz) 
    A constructor which sets the root class. Internally calls constructor Unmarshaller(InternalContext, Class) with an instance of BackwardCompatibilityContext as context.
    Parameters:
    clazz - root class for unmarshalling
 public Unmarshaller(InternalContext internalContext) 
    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.
 public Unmarshaller(Mapping mapping) throws MappingException 
    Creates a new Unmarshaller with the given Mapping. An instance of BackwardsCompatibilityContext is used as InternalContext.
    Parameters:
    mapping - The Mapping to use.
    Throws:
    MappingException - in case that Unmarshaller fails to be instantiated
 public 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.
 public Unmarshaller(InternalContext internalContext,
    Class c) 
    Creates a new Unmarshaller with the given Class.
    Parameters:
    internalContext - the InternalContext to use
    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.
 public Unmarshaller(InternalContext internalContext,
    Mapping mapping) throws MappingException 
    Creates a new Unmarshaller with the given Mapping.
    Parameters:
    internalContext - the internal context to use
    mapping - The Mapping to use.
    Throws:
    MappingException - in case that Unmarshaller fails to be instantiated
 public Unmarshaller(InternalContext internalContext,
    Object root) 
    Creates a new Unmarshaller with the given Object.
    Parameters:
    internalContext - the internal context to use
    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.
 public Unmarshaller(InternalContext internalContext,
    Class c,
    ClassLoader loader) 
    Parameters:
    internalContext - the InternalContext to be used, for config, and such...
    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.
Method from org.exolab.castor.xml.Unmarshaller Summary:
addNamespaceToPackageMapping,   createHandler,   getContentHandler,   getInternalContext,   getProperty,   isValidating,   setClass,   setClassLoader,   setClearCollections,   setDebug,   setEntityResolver,   setIDResolver,   setIgnoreExtraAttributes,   setIgnoreExtraElements,   setInternalContext,   setLogWriter,   setMapping,   setObject,   setObjectFactory,   setProperty,   setResolver,   setReuseObjects,   setUnmarshalListener,   setUnmarshalListener,   setValidation,   setWhitespacePreserve,   unmarshal,   unmarshal,   unmarshal,   unmarshal,   unmarshal,   unmarshal,   unmarshal,   unmarshal,   unmarshal
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.exolab.castor.xml.Unmarshaller Detail:
 public  void addNamespaceToPackageMapping(String nsURI,
    String packageName) 
    Adds a mapping from the given namespace URI to the given package name.
 public UnmarshalHandler createHandler() 
    Creates and initalizes an UnmarshalHandler
 public static ContentHandler getContentHandler(UnmarshalHandler handler) throws SAXException 
    Returns a ContentHandler for the given UnmarshalHandler
 public InternalContext getInternalContext() 
    To get the internal XML Context that is in use.
 public String getProperty(String name) 
    Returns the value of the given Castor XML-specific property.
 public boolean isValidating() 
    Indicates whether or not validation should be performed during umarshalling.
 public  void setClass(Class clazz) 
    Sets the 'expected' Class instance on the Unmarshaller.
 public  void 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.
 public  void 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.
 public  void setDebug(boolean debug) 
Deprecated!
    Custom debugging is replaced with commons-logging
 public  void setEntityResolver(EntityResolver entityResolver) 
    Sets the EntityResolver to use when resolving system and public ids with respect to entites and Document Type.
 public  void setIDResolver(IDResolver idResolver) 
    Sets the IDResolver to use when resolving IDREFs for which no associated element may exist in XML document.
 public  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. By default, extra attributes are ignored.
 public  void 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.
 public  void setInternalContext(InternalContext internalContext) 
    To set the internal XML Context to be used.
 public  void setLogWriter(PrintWriter printWriter) 
Deprecated!
    Logging is replaced with commons-logging.
 public  void setMapping(Mapping mapping) throws MappingException 
    Sets the Mapping to use during unmarshalling. If the Mapping has a ClassLoader it will be used during unmarshalling.
 public  void setObject(Object root) 
    Sets the 'expected' Object instance on the Unmarshaller, into which will be unmarshalled.
 public  void setObjectFactory(ObjectFactory objectFactory) 
    Set an object factory for the unmarshaller. This factory will be used to construct the objects being unmarshalled.
 public  void setProperty(String name,
    String value) 
    Sets a custom value of a given Castor XML-specific property.
 public  void setResolver(XMLClassDescriptorResolver xmlClassDescriptorResolver) 
    Sets the XMLClassDescriptorResolver to use during unmarshalling
 public  void 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.
 public  void setUnmarshalListener(UnmarshalListener listener) 
Deprecated! replaced - by org.castor.xml.UnmarshalListener

    Sets an optional org.exolab.castor.xml.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 application 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.
    The deprecated listener set with this method will be wrapped by an adapter.
 public  void setUnmarshalListener(UnmarshalListener listener) 
    Sets an optional org.castor.xml.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 application 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.
 public  void setValidation(boolean validate) 
    Sets the flag for validation.
 public  void 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".
 public Object unmarshal(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.
 public Object unmarshal(EventProducer eventProducer) throws MarshalException, ValidationException 
Deprecated! please - use @see #unmarshal(SAX2EventProducer) instead.

    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.
 public Object unmarshal(SAX2EventProducer 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.
 public Object unmarshal(AnyNode anyNode) throws MarshalException 
    Unmarshals objects of this Unmarshaller 's Class type from an AnyNode instance. The Class must specify the proper access methods (setters/getters) in order for instances of the Class to be properly unmarshalled.
 public Object 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.
 public Object 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.
 public static Object unmarshal(Class c,
    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.

    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.

 public static Object unmarshal(Class c,
    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.

    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.

 public static Object unmarshal(Class c,
    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.

    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.