Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle TopLink
11g Release 1 (11.1.1)

E28847-01


org.eclipse.persistence.oxm
Class XMLUnmarshaller

java.lang.Object
  extended by org.eclipse.persistence.oxm.XMLUnmarshaller

All Implemented Interfaces:
java.lang.Cloneable

public class XMLUnmarshaller
extends java.lang.Object
implements java.lang.Cloneable

Class used to unmarshal XML to objects.

Create an XMLUnmarshaller from an XMLContext.
Code Sample
XMLContext context = new XMLContext("mySessionName");
XMLUnmarshaller unmarshaller = context.createUnmarshaller();

XML can be unmarshalled from the following inputs:

XML that can be unmarshalled is XML which has a root tag that corresponds to a default root element on an XMLDescriptor in the TopLink project associated with the XMLContext.

See Also:
XMLContext

Field Summary
private  XMLAttachmentUnmarshaller attachmentUnmarshaller
           
static int DTD_VALIDATION
           
private static java.lang.String GET_XML_EVENT_READER_METHOD_NAME
           
private static java.lang.String GET_XML_STREAM_READER_METHOD_NAME
           
static int NONVALIDATING
           
private  org.eclipse.persistence.internal.oxm.record.PlatformUnmarshaller platformUnmarshaller
           
static int SCHEMA_VALIDATION
           
private  boolean schemasAreInitialized
           
private static java.lang.String STAX_SOURCE_CLASS_NAME
           
private static java.lang.Class staxSourceClass
           
private static java.lang.reflect.Method staxSourceGetEventReaderMethod
           
private static java.lang.reflect.Method staxSourceGetStreamReaderMethod
           
private  org.eclipse.persistence.internal.oxm.StrBuffer stringBuffer
           
private  java.lang.Class unmappedContentHandlerClass
           
private  XMLUnmarshalListener unmarshalListener
           
private  java.util.Properties unmarshalProperties
           
private static java.lang.String XML_EVENT_READER_CLASS_NAME
           
private static java.lang.String XML_EVENT_READER_INPUT_SOURCE_CLASS_NAME
           
private static java.lang.String XML_EVENT_READER_READER_CLASS_NAME
           
private static java.lang.String XML_STREAM_READER_CLASS_NAME
           
private static java.lang.String XML_STREAM_READER_INPUT_SOURCE_CLASS_NAME
           
private static java.lang.String XML_STREAM_READER_READER_CLASS_NAME
           
private  XMLContext xmlContext
           
private static java.lang.reflect.Constructor xmlEventReaderInputSourceConstructor
           
private static java.lang.reflect.Constructor xmlEventReaderReaderConstructor
           
private static java.lang.reflect.Constructor xmlStreamReaderInputSourceConstructor
           
private static java.lang.reflect.Constructor xmlStreamReaderReaderConstructor
           
private  XMLUnmarshallerHandler xmlUnmarshallerHandler
           

 

Constructor Summary
protected XMLUnmarshaller(XMLContext xmlContext)
           
protected XMLUnmarshaller(XMLContext xmlContext, java.util.Map<java.lang.String,java.lang.Boolean> parserFeatures)
           

 

Method Summary
 XMLUnmarshaller clone()
           
 XMLAttachmentUnmarshaller getAttachmentUnmarshaller()
           
 org.xml.sax.EntityResolver getEntityResolver()
          Get the EntityResolver set on this XMLUnmarshaller
 org.xml.sax.ErrorHandler getErrorHandler()
          Get the ErrorHandler set on this XMLUnmarshaller
 java.util.Properties getProperties()
          Return a properties object for a given instance of the XMLUnmarshaller.
 java.lang.Object getProperty(java.lang.Object key)
          Return the property for a given key, if one exists.
 javax.xml.validation.Schema getSchema()
           
 org.eclipse.persistence.internal.oxm.StrBuffer getStringBuffer()
          INTERNAL: This is the text handler during unmarshal operations.
 java.lang.Class getUnmappedContentHandlerClass()
          Get the class that will be instantiated to handled unmapped content Class must implement the org.eclipse.persistence.oxm.unmapped.UnmappedContentHandler interface
 XMLUnmarshallerHandler getUnmarshallerHandler()
           
 XMLUnmarshalListener getUnmarshalListener()
           
 int getValidationMode()
          Get the validation mode set on this XMLUnmarshaller By default, the unmarshaller is set to be NONVALIDATING
 XMLContext getXMLContext()
          Return the instance of XMLContext that was used to create this instance of XMLUnmarshaller.
private  void initialize(java.util.Map<java.lang.String,java.lang.Boolean> parserFeatures)
           
private  void initializeSchemas()
           
 boolean isResultAlwaysXMLRoot()
           
 void resolveReferences(org.eclipse.persistence.internal.sessions.AbstractSession unitOfWork)
          INTERNAL
 void setAttachmentUnmarshaller(XMLAttachmentUnmarshaller atu)
           
 void setEntityResolver(org.xml.sax.EntityResolver entityResolver)
          Set the EntityResolver on this XMLUnmarshaller
 void setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
          Set the ErrorHandler on this XMLUnmarshaller
 void setResultAlwaysXMLRoot(boolean alwaysReturnRoot)
           
 void setSchema(javax.xml.validation.Schema schema)
           
 void setUnmappedContentHandlerClass(java.lang.Class aClass)
          Set the class that will be instantiated to handled unmapped content Class must implement the org.eclipse.persistence.oxm.unmapped.UnmappedContentHandler interface
 void setUnmarshalListener(XMLUnmarshalListener listener)
           
 void setValidationMode(int validationMode)
          Set the validation mode.
 void setXMLContext(XMLContext value)
          Set the XMLContext used by this instance of XMLUnmarshaller.
 java.lang.Object unmarshal(java.io.File file)
          PUBLIC: Read and parse the XML document from the file and map the XML data into an object.
 java.lang.Object unmarshal(java.io.File file, java.lang.Class clazz)
          PUBLIC: Read and parse the XML document from the file and map the XML data into an object.
 java.lang.Object unmarshal(org.xml.sax.InputSource inputSource)
          PUBLIC: Read and parse the XML document from the inputSource and map the XML data into an object.
 java.lang.Object unmarshal(org.xml.sax.InputSource inputSource, java.lang.Class clazz)
          PUBLIC: Read and parse the XML document from the inputSource and map the XML data into an object.
 java.lang.Object unmarshal(java.io.InputStream inputStream)
          PUBLIC: Read and parse the XML document from the inputStream and map the XML data into an object.
 java.lang.Object unmarshal(java.io.InputStream inputStream, java.lang.Class clazz)
          PUBLIC: Read and parse the XML document from the inputStream and map the XML data into an object.
 java.lang.Object unmarshal(org.w3c.dom.Node node)
          PUBLIC: Map the XML node into an object.
 java.lang.Object unmarshal(org.w3c.dom.Node node, java.lang.Class clazz)
          PUBLIC: Map the XML node into an object.
 java.lang.Object unmarshal(java.io.Reader reader)
          PUBLIC: Read and parse the XML document from the reader and map the XML data into an object.
 java.lang.Object unmarshal(java.io.Reader reader, java.lang.Class clazz)
          PUBLIC: Read and parse the XML document from the reader and map the XML data into an object.
 java.lang.Object unmarshal(javax.xml.transform.Source source)
          PUBLIC: Read and parse the XML document from the source and map the XML data into an object.
 java.lang.Object unmarshal(javax.xml.transform.Source source, java.lang.Class clazz)
          PUBLIC: Read and parse the XML document from the source and map the XML data into an object.
 java.lang.Object unmarshal(java.net.URL url)
          PUBLIC: Read and parse the XML document from the url and map the XML data into an object.
 java.lang.Object unmarshal(java.net.URL url, java.lang.Class clazz)
          PUBLIC: Read and parse the XML document from the url and map the XML data into an object.
 java.lang.Object unmarshal(org.xml.sax.XMLReader xmlReader, org.xml.sax.InputSource inputSource)
           
 java.lang.Object unmarshal(org.xml.sax.XMLReader xmlReader, org.xml.sax.InputSource inputSource, java.lang.Class clazz)
           

 

Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

NONVALIDATING

public static final int NONVALIDATING
See Also:
Constant Field Values

SCHEMA_VALIDATION

public static final int SCHEMA_VALIDATION
See Also:
Constant Field Values

DTD_VALIDATION

public static final int DTD_VALIDATION
See Also:
Constant Field Values

STAX_SOURCE_CLASS_NAME

private static final java.lang.String STAX_SOURCE_CLASS_NAME
See Also:
Constant Field Values

XML_STREAM_READER_CLASS_NAME

private static final java.lang.String XML_STREAM_READER_CLASS_NAME
See Also:
Constant Field Values

XML_EVENT_READER_CLASS_NAME

private static final java.lang.String XML_EVENT_READER_CLASS_NAME
See Also:
Constant Field Values

GET_XML_STREAM_READER_METHOD_NAME

private static final java.lang.String GET_XML_STREAM_READER_METHOD_NAME
See Also:
Constant Field Values

GET_XML_EVENT_READER_METHOD_NAME

private static final java.lang.String GET_XML_EVENT_READER_METHOD_NAME
See Also:
Constant Field Values

XML_STREAM_READER_READER_CLASS_NAME

private static final java.lang.String XML_STREAM_READER_READER_CLASS_NAME
See Also:
Constant Field Values

XML_EVENT_READER_READER_CLASS_NAME

private static final java.lang.String XML_EVENT_READER_READER_CLASS_NAME
See Also:
Constant Field Values

XML_STREAM_READER_INPUT_SOURCE_CLASS_NAME

private static final java.lang.String XML_STREAM_READER_INPUT_SOURCE_CLASS_NAME
See Also:
Constant Field Values

XML_EVENT_READER_INPUT_SOURCE_CLASS_NAME

private static final java.lang.String XML_EVENT_READER_INPUT_SOURCE_CLASS_NAME
See Also:
Constant Field Values

staxSourceClass

private static java.lang.Class staxSourceClass

staxSourceGetStreamReaderMethod

private static java.lang.reflect.Method staxSourceGetStreamReaderMethod

staxSourceGetEventReaderMethod

private static java.lang.reflect.Method staxSourceGetEventReaderMethod

xmlStreamReaderReaderConstructor

private static java.lang.reflect.Constructor xmlStreamReaderReaderConstructor

xmlStreamReaderInputSourceConstructor

private static java.lang.reflect.Constructor xmlStreamReaderInputSourceConstructor

xmlEventReaderReaderConstructor

private static java.lang.reflect.Constructor xmlEventReaderReaderConstructor

xmlEventReaderInputSourceConstructor

private static java.lang.reflect.Constructor xmlEventReaderInputSourceConstructor

xmlContext

private XMLContext xmlContext

xmlUnmarshallerHandler

private XMLUnmarshallerHandler xmlUnmarshallerHandler

platformUnmarshaller

private org.eclipse.persistence.internal.oxm.record.PlatformUnmarshaller platformUnmarshaller

schemasAreInitialized

private boolean schemasAreInitialized

unmarshalListener

private XMLUnmarshalListener unmarshalListener

attachmentUnmarshaller

private XMLAttachmentUnmarshaller attachmentUnmarshaller

unmarshalProperties

private java.util.Properties unmarshalProperties

unmappedContentHandlerClass

private java.lang.Class unmappedContentHandlerClass

stringBuffer

private org.eclipse.persistence.internal.oxm.StrBuffer stringBuffer

Constructor Detail

XMLUnmarshaller

protected XMLUnmarshaller(XMLContext xmlContext)

XMLUnmarshaller

protected XMLUnmarshaller(XMLContext xmlContext,
                          java.util.Map<java.lang.String,java.lang.Boolean> parserFeatures)

Method Detail

initialize

private void initialize(java.util.Map<java.lang.String,java.lang.Boolean> parserFeatures)

initializeSchemas

private void initializeSchemas()

getXMLContext

public XMLContext getXMLContext()
Return the instance of XMLContext that was used to create this instance of XMLUnmarshaller.

setXMLContext

public void setXMLContext(XMLContext value)
Set the XMLContext used by this instance of XMLUnmarshaller.

getValidationMode

public int getValidationMode()
Get the validation mode set on this XMLUnmarshaller By default, the unmarshaller is set to be NONVALIDATING
Returns:
the validation mode

resolveReferences

public void resolveReferences(org.eclipse.persistence.internal.sessions.AbstractSession unitOfWork)
INTERNAL
Parameters:
unitOfWork -

setValidationMode

public void setValidationMode(int validationMode)
Set the validation mode. This method sets the validation mode of the parser to one of the 3 types: NONVALIDATING, DTD_VALIDATION and SCHEMA_VALIDATION. By default, the unmarshaller is set to be NONVALIDATING
Parameters:
validationMode - sets the type of the validation mode to be used

getEntityResolver

public org.xml.sax.EntityResolver getEntityResolver()
Get the EntityResolver set on this XMLUnmarshaller
Returns:
the EntityResolver set on this XMLUnmarshaller

setEntityResolver

public void setEntityResolver(org.xml.sax.EntityResolver entityResolver)
Set the EntityResolver on this XMLUnmarshaller
Parameters:
entityResolver - the EntityResolver to set on this XMLUnmarshaller

getErrorHandler

public org.xml.sax.ErrorHandler getErrorHandler()
Get the ErrorHandler set on this XMLUnmarshaller
Returns:
the ErrorHandler set on this XMLUnmarshaller

setErrorHandler

public void setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
Set the ErrorHandler on this XMLUnmarshaller
Parameters:
errorHandler - the ErrorHandler to set on this XMLUnmarshaller

getUnmarshalListener

public XMLUnmarshalListener getUnmarshalListener()

setUnmarshalListener

public void setUnmarshalListener(XMLUnmarshalListener listener)

getUnmappedContentHandlerClass

public java.lang.Class getUnmappedContentHandlerClass()
Get the class that will be instantiated to handled unmapped content Class must implement the org.eclipse.persistence.oxm.unmapped.UnmappedContentHandler interface

setUnmappedContentHandlerClass

public void setUnmappedContentHandlerClass(java.lang.Class aClass)
Set the class that will be instantiated to handled unmapped content Class must implement the org.eclipse.persistence.oxm.unmapped.UnmappedContentHandler interface
Parameters:
aClass -

getStringBuffer

public org.eclipse.persistence.internal.oxm.StrBuffer getStringBuffer()
INTERNAL: This is the text handler during unmarshal operations.

unmarshal

public java.lang.Object unmarshal(java.io.File file)
                           throws XMLMarshalException
PUBLIC: Read and parse the XML document from the file and map the XML data into an object. The file must contain a valid XML document, and be mapped by a project used to create the XMLContext. The type of object returned will be based on the root element of the XML document.
Parameters:
file - The file to unmarshal from
Returns:
the object which resulted from unmarshalling the given file
Throws:
XMLMarshalException - if an error occurred during unmarshalling

unmarshal

public java.lang.Object unmarshal(java.io.File file,
                                  java.lang.Class clazz)
                           throws XMLMarshalException
PUBLIC: Read and parse the XML document from the file and map the XML data into an object. The file must contain a valid XML document, and be mapped by a project used to create the XMLContext.
Parameters:
file - The file to unmarshal from
clazz - The type of object to return.
Returns:
the object which resulted from unmarshalling the given file
Throws:
XMLMarshalException - if an error occurred during unmarshalling

unmarshal

public java.lang.Object unmarshal(java.io.InputStream inputStream)
                           throws XMLMarshalException
PUBLIC: Read and parse the XML document from the inputStream and map the XML data into an object. The inputStream must contain a valid XML document, and be mapped by a project used to create the XMLContext. The type of object returned will be based on the root element of the XML document.
Parameters:
inputStream - The inputStream to unmarshal from
Returns:
the object which resulted from unmarshalling the given inputStream
Throws:
XMLMarshalException - if an error occurred during unmarshalling

unmarshal

public java.lang.Object unmarshal(java.io.InputStream inputStream,
                                  java.lang.Class clazz)
                           throws XMLMarshalException
PUBLIC: Read and parse the XML document from the inputStream and map the XML data into an object. The file must contain a valid XML document, and be mapped by a project used to create the XMLContext.
Parameters:
inputStream - The inputStream to unmarshal from
clazz - The type of object to return.
Returns:
the object which resulted from unmarshalling the given inputStream
Throws:
XMLMarshalException - if an error occurred during unmarshalling

unmarshal

public java.lang.Object unmarshal(java.io.Reader reader)
                           throws XMLMarshalException
PUBLIC: Read and parse the XML document from the reader and map the XML data into an object. The reader must contain a valid XML document, and be mapped by a project used to create the XMLContext. The type of object returned will be based on the root element of the XML document.
Parameters:
reader - The reader to unmarshal from
Returns:
the object which resulted from unmarshalling the given reader
Throws:
XMLMarshalException - if an error occurred during unmarshalling

unmarshal

public java.lang.Object unmarshal(java.io.Reader reader,
                                  java.lang.Class clazz)
                           throws XMLMarshalException
PUBLIC: Read and parse the XML document from the reader and map the XML data into an object. The file must contain a valid XML document, and be mapped by a project used to create the XMLContext.
Parameters:
reader - The reader to unmarshal from
clazz - The type of object to return.
Returns:
the object which resulted from unmarshalling the given reader
Throws:
XMLMarshalException - if an error occurred during unmarshalling

unmarshal

public java.lang.Object unmarshal(java.net.URL url)
                           throws XMLMarshalException
PUBLIC: Read and parse the XML document from the url and map the XML data into an object. The url must reference a valid XML document, and be mapped by a project used to create the XMLContext. The type of object returned will be based on the root element of the XML document.
Parameters:
url - The url to unmarshal from
Returns:
the object which resulted from unmarshalling the given url
Throws:
XMLMarshalException - if an error occurred during unmarshalling

unmarshal

public java.lang.Object unmarshal(java.net.URL url,
                                  java.lang.Class clazz)
                           throws XMLMarshalException
PUBLIC: Read and parse the XML document from the url and map the XML data into an object. The url must reference a valid XML document, and be mapped by a project used to create the XMLContext.
Parameters:
url - The url to unmarshal from
clazz - The type of object to return.
Returns:
the object which resulted from unmarshalling the given url
Throws:
XMLMarshalException - if an error occurred during unmarshalling

unmarshal

public java.lang.Object unmarshal(org.xml.sax.InputSource inputSource)
                           throws XMLMarshalException
PUBLIC: Read and parse the XML document from the inputSource and map the XML data into an object. The inputSource must contain a valid XML document, and be mapped by a project used to create the XMLContext. The type of object returned will be based on the root element of the XML document.
Parameters:
inputSource - The inputSource to unmarshal from
Returns:
the object which resulted from unmarshalling the given inputSource
Throws:
XMLMarshalException - if an error occurred during unmarshalling

unmarshal

public java.lang.Object unmarshal(org.xml.sax.InputSource inputSource,
                                  java.lang.Class clazz)
                           throws XMLMarshalException
PUBLIC: Read and parse the XML document from the inputSource and map the XML data into an object. The inputSource must contain a valid XML document, and be mapped by a project used to create the XMLContext.
Parameters:
inputSource - The inputSource to unmarshal from
clazz - The type of object to return.
Returns:
the object which resulted from unmarshalling the given inputSource
Throws:
XMLMarshalException - if an error occurred during unmarshalling

unmarshal

public java.lang.Object unmarshal(org.w3c.dom.Node node)
                           throws XMLMarshalException
PUBLIC: Map the XML node into an object. The node must be a valid XML document, and be mapped by a project used to create the XMLContext.
Parameters:
node - The node to unmarshal from
Returns:
the object which resulted from unmarshalling the given node
Throws:
XMLMarshalException - if an error occurred during unmarshalling

unmarshal

public java.lang.Object unmarshal(org.w3c.dom.Node node,
                                  java.lang.Class clazz)
                           throws XMLMarshalException
PUBLIC: Map the XML node into an object. The node must be a valid XML document, and be mapped by a project used to create the XMLContext.
Parameters:
node - The node to unmarshal from
clazz - The type of object to return.
Returns:
the object which resulted from unmarshalling the given node
Throws:
XMLMarshalException - if an error occurred during unmarshalling

unmarshal

public java.lang.Object unmarshal(javax.xml.transform.Source source)
                           throws XMLMarshalException
PUBLIC: Read and parse the XML document from the source and map the XML data into an object. The source must contain a valid XML document, and be mapped by a project used to create the XMLContext. The type of object returned will be based on the root element of the XML document.
Parameters:
source - The source to unmarshal from
Returns:
the object which resulted from unmarshalling the given source
Throws:
XMLMarshalException - if an error occurred during unmarshalling

getProperties

public java.util.Properties getProperties()
Return a properties object for a given instance of the XMLUnmarshaller.
Returns:

getProperty

public java.lang.Object getProperty(java.lang.Object key)
Return the property for a given key, if one exists.
Returns:

unmarshal

public java.lang.Object unmarshal(javax.xml.transform.Source source,
                                  java.lang.Class clazz)
                           throws XMLMarshalException
PUBLIC: Read and parse the XML document from the source and map the XML data into an object. The source must contain a valid XML document, and be mapped by a project used to create the XMLContext.
Parameters:
source - The inputSource to unmarshal from
clazz - The type of object to return.
Returns:
the object which resulted from unmarshalling the given source
Throws:
XMLMarshalException - if an error occurred during unmarshalling

unmarshal

public java.lang.Object unmarshal(org.xml.sax.XMLReader xmlReader,
                                  org.xml.sax.InputSource inputSource)

unmarshal

public java.lang.Object unmarshal(org.xml.sax.XMLReader xmlReader,
                                  org.xml.sax.InputSource inputSource,
                                  java.lang.Class clazz)

getUnmarshallerHandler

public XMLUnmarshallerHandler getUnmarshallerHandler()

getAttachmentUnmarshaller

public XMLAttachmentUnmarshaller getAttachmentUnmarshaller()

setAttachmentUnmarshaller

public void setAttachmentUnmarshaller(XMLAttachmentUnmarshaller atu)

setResultAlwaysXMLRoot

public void setResultAlwaysXMLRoot(boolean alwaysReturnRoot)

isResultAlwaysXMLRoot

public boolean isResultAlwaysXMLRoot()

setSchema

public void setSchema(javax.xml.validation.Schema schema)

getSchema

public javax.xml.validation.Schema getSchema()

clone

public XMLUnmarshaller clone()
Overrides:
clone in class java.lang.Object

Skip navigation links

Copyright © 1998, 2012, Oracle. All Rights Reserved.