Top Description Fields Constructors Methods
javax.xml.bind.helpers

public abstract Class AbstractUnmarshallerImpl

extends Object
implements Unmarshaller
Class Inheritance
All Implemented Interfaces
javax.xml.bind.Unmarshaller
Imports
org.xml.sax.InputSource, .SAXException, .XMLReader, org.w3c.dom.Node, javax.xml.bind.JAXBException, .PropertyException, .UnmarshalException, .Unmarshaller, .ValidationEventHandler, .JAXBElement, javax.xml.bind.annotation.adapters.XmlAdapter, javax.xml.bind.attachment.AttachmentUnmarshaller, javax.xml.parsers.ParserConfigurationException, .SAXParserFactory, javax.xml.stream.XMLEventReader, .XMLStreamReader, javax.xml.transform.Source, javax.xml.transform.dom.DOMSource, javax.xml.transform.sax.SAXSource, javax.xml.transform.stream.StreamSource, javax.xml.validation.Schema, java.io.*, java.net.URL

Partial default Unmarshaller implementation.

This class provides a partial default implementation for the javax.xml.bind.Unmarshallerinterface.

A JAXB Provider has to implement five methods (getUnmarshallerHandler, unmarshal(Node), unmarshal(XMLReader,InputSource), unmarshal(XMLStreamReader), and unmarshal(XMLEventReader).

Author
Since
1.6, JAXB 1.0
See Also
javax.xml.bind.Unmarshaller

Field Summary

Modifier and TypeField and Description
private ValidationEventHandler
eventHandler

handler that will be used to process errors and warnings during unmarshal

private XMLReader
reader

XMLReader that will be used to parse a document.

protected boolean
validating

whether or not the unmarshaller will validate

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected UnmarshalException

Returns:

the resulting UnmarshalException
createUnmarshalException
(SAXException e)

Creates an UnmarshalException from a SAXException.

public <A extends XmlAdapter<ValueType, BoundType>> A
getAdapter(Class<A> type)

Implements javax.xml.bind.Unmarshaller.getAdapter.

Gets the adapter associated with the specified type.
public AttachmentUnmarshaller
public ValidationEventHandler

Returns:

the current ValidationEventHandler or the default event handler if it hasn't been set
getEventHandler
()

Implements javax.xml.bind.Unmarshaller.getEventHandler.

Return the current event handler or the default event handler if one hasn't been set.
public Unmarshaller.Listener
public Object
getProperty(String
the name of the property to retrieve
name
)

Implements javax.xml.bind.Unmarshaller.getProperty.

Default implementation of the getProperty method always throws PropertyException since there are no required properties.
public Schema
getSchema()

Implements javax.xml.bind.Unmarshaller.getSchema.

Get the JAXP 1.3 Schema object being used to perform unmarshal-time validation.
protected XMLReader
getXMLReader()

Obtains a configured XMLReader.

public boolean

Returns:

true if the Unmarshaller is configured to validate during unmarshal operations, false otherwise
isValidating
()

Implements javax.xml.bind.Unmarshaller.isValidating.

Indicates whether or not the Unmarshaller is configured to validate during unmarshal operations.
public void
setAdapter(XmlAdapter<ValueType, BoundType> adapter)

Implements javax.xml.bind.Unmarshaller.setAdapter.

Associates a configured instance of XmlAdapter with this unmarshaller.
public <A extends XmlAdapter<ValueType, BoundType>> void
setAdapter(Class<A>
The type of the adapter. The specified instance will be used when javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter#value() refers to this type.
type
,
A
The instance of the adapter to be used. If null, it will un-register the current adapter set for this type.
adapter
)

Implements javax.xml.bind.Unmarshaller.setAdapter.

Associates a configured instance of XmlAdapter with this unmarshaller.
public void
setAttachmentUnmarshaller(AttachmentUnmarshaller au)

Implements javax.xml.bind.Unmarshaller.setAttachmentUnmarshaller.

Associate a context that resolves cid's, content-id URIs, to binary data passed as attachments.

public void
setEventHandler(ValidationEventHandler
the validation event handler
handler
)

Implements javax.xml.bind.Unmarshaller.setEventHandler.

Allow an application to register a validation event handler.
public void
setListener(Unmarshaller.Listener
provides unmarshal event callbacks for this Unmarshaller
listener
)

Implements javax.xml.bind.Unmarshaller.setListener.

Register unmarshal event callback Listener with this Unmarshaller.

public void
setProperty(String
the name of the property to be set. This value can either be specified using one of the constant fields or a user supplied string.
name
,
Object
the value of the property to be set
value
)

Implements javax.xml.bind.Unmarshaller.setProperty.

Default implementation of the setProperty method always throws PropertyException since there are no required properties.
public void
setSchema(Schema
Schema object to validate unmarshal operations against or null to disable validation
schema
)

Implements javax.xml.bind.Unmarshaller.setSchema.

Specify the JAXP 1.3 Schema object that should be used to validate subsequent unmarshal operations against.
public void
setValidating(boolean
true if the Unmarshaller should validate during unmarshal, false otherwise
validating
)

Implements javax.xml.bind.Unmarshaller.setValidating.

Specifies whether or not the Unmarshaller should validate during unmarshal operations.
private static InputSource
public Object
unmarshal(Source
the XML Source to unmarshal XML data from (providers are only required to support SAXSource, DOMSource, and StreamSource)
source
)

Implements javax.xml.bind.Unmarshaller.unmarshal.

Unmarshal XML data from the specified XML Source and return the resulting content tree.
private Object
protected abstract Object
unmarshal(XMLReader reader, InputSource source)

Unmarshals an object by using the specified XMLReader and the InputSource.

public final Object
unmarshal(InputSource
the input source to unmarshal XML data from
source
)

Implements javax.xml.bind.Unmarshaller.unmarshal.

Unmarshal XML data from the specified SAX InputSource and return the resulting content tree.
private Object
public final Object
unmarshal(URL
the url to unmarshal XML data from
url
)

Implements javax.xml.bind.Unmarshaller.unmarshal.

Unmarshal XML data from the specified URL and return the resulting content tree.
public final Object
unmarshal(File
the file to unmarshal XML data from
f
)

Implements javax.xml.bind.Unmarshaller.unmarshal.

Unmarshal XML data from the specified file and return the resulting content tree.
public final Object
unmarshal(InputStream
the InputStream to unmarshal XML data from
is
)

Implements javax.xml.bind.Unmarshaller.unmarshal.

Unmarshal XML data from the specified InputStream and return the resulting content tree.
public final Object
unmarshal(Reader
the Reader to unmarshal XML data from
reader
)

Implements javax.xml.bind.Unmarshaller.unmarshal.

Unmarshal XML data from the specified Reader and return the resulting content tree.
public Object
unmarshal(XMLEventReader
The parser to be read.
reader
)

Implements javax.xml.bind.Unmarshaller.unmarshal.

Unmarshal XML data from the specified pull parser and return the resulting content tree.
public Object
unmarshal(XMLStreamReader
The parser to be read.
reader
)

Implements javax.xml.bind.Unmarshaller.unmarshal.

Unmarshal XML data from the specified pull parser and return the resulting content tree.
public <T> JAXBElement<T>
unmarshal(Node
the document/element to unmarshal XML data from. The caller must support at least Document and Element.
node
,
Class<T>
appropriate JAXB mapped class to hold node's XML data.
expectedType
)

Implements javax.xml.bind.Unmarshaller.unmarshal.

Unmarshal XML data by JAXB mapped declaredType and return the resulting content tree.
public <T> JAXBElement<T>
unmarshal(Source
the XML Source to unmarshal XML data from (providers are only required to support SAXSource, DOMSource, and StreamSource)
source
,
Class<T>
appropriate JAXB mapped class to hold source's xml root element
expectedType
)

Implements javax.xml.bind.Unmarshaller.unmarshal.

Unmarshal XML data from the specified XML Source by declaredType and return the resulting content tree.
public <T> JAXBElement<T>
unmarshal(XMLStreamReader
The parser to be read.
reader
,
Class<T>
appropriate JAXB mapped class to hold reader's START_ELEMENT XML data.
expectedType
)

Implements javax.xml.bind.Unmarshaller.unmarshal.

Unmarshal root element to JAXB mapped declaredType and return the resulting content tree.
public <T> JAXBElement<T>
unmarshal(XMLEventReader
The parser to be read.
reader
,
Class<T>
appropriate JAXB mapped class to hold reader's START_ELEMENT XML data.
expectedType
)

Implements javax.xml.bind.Unmarshaller.unmarshal.

Unmarshal root element to JAXB mapped declaredType and return the resulting content tree.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

eventHandlerback to summary
private ValidationEventHandler eventHandler

handler that will be used to process errors and warnings during unmarshal

readerback to summary
private XMLReader reader

XMLReader that will be used to parse a document.

validatingback to summary
protected boolean validating

whether or not the unmarshaller will validate

Constructor Detail

AbstractUnmarshallerImplback to summary
public AbstractUnmarshallerImpl()

Method Detail

createUnmarshalExceptionback to summary
protected UnmarshalException createUnmarshalException(SAXException e)

Creates an UnmarshalException from a SAXException. This is an utility method provided for the derived classes.

When a provider-implemented ContentHandler wants to throw a JAXBException, it needs to wrap the exception by a SAXException. If the unmarshaller implementation blindly wrap SAXException by JAXBException, such an exception will be a JAXBException wrapped by a SAXException wrapped by another JAXBException. This is silly.

This method checks the nested exception of SAXException and reduce those excessive wrapping.

Returns:UnmarshalException

the resulting UnmarshalException

getAdapterback to summary
public <A extends XmlAdapter<ValueType, BoundType>> A getAdapter(Class<A> type)

Implements javax.xml.bind.Unmarshaller.getAdapter.

Doc from javax.xml.bind.Unmarshaller.getAdapter.

Gets the adapter associated with the specified type. This is the reverse operation of the setAdapter method.

getAttachmentUnmarshallerback to summary
public AttachmentUnmarshaller getAttachmentUnmarshaller()

Implements javax.xml.bind.Unmarshaller.getAttachmentUnmarshaller.

getEventHandlerback to summary
public ValidationEventHandler getEventHandler() throws JAXBException

Implements javax.xml.bind.Unmarshaller.getEventHandler.

Return the current event handler or the default event handler if one hasn't been set.

Returns:ValidationEventHandler

the current ValidationEventHandler or the default event handler if it hasn't been set

Exceptions
JAXBException:
if an error was encountered while getting the current event handler
getListenerback to summary
public Unmarshaller.Listener getListener()

Implements javax.xml.bind.Unmarshaller.getListener.

Doc from javax.xml.bind.Unmarshaller.getListener.

Return Listener registered with this Unmarshaller.

Returns:Unmarshaller.Listener

registered Listener or null if no Listener is registered with this Unmarshaller.

getPropertyback to summary
public Object getProperty(String name) throws PropertyException

Implements javax.xml.bind.Unmarshaller.getProperty.

Default implementation of the getProperty method always throws PropertyException since there are no required properties. If a provider needs to handle additional properties, it should override this method in a derived class.

Parameters
name:String

Doc from javax.xml.bind.Unmarshaller.getProperty.

the name of the property to retrieve

Returns:Object

Doc from javax.xml.bind.Unmarshaller.getProperty.

the value of the requested property

Exceptions
PropertyException:

Doc from javax.xml.bind.Unmarshaller.getProperty.

when there is an error retrieving the given property or value property name

getSchemaback to summary
public Schema getSchema()

Implements javax.xml.bind.Unmarshaller.getSchema.

Doc from javax.xml.bind.Unmarshaller.getSchema.

Get the JAXP 1.3 Schema object being used to perform unmarshal-time validation. If there is no Schema set on the unmarshaller, then this method will return null indicating that unmarshal-time validation will not be performed.

This method provides replacement functionality for the deprecated isValidating() API as well as access to the Schema object. To determine if the Unmarshaller has validation enabled, simply test the return type for null:

boolean isValidating = u.getSchema()!=null;
Returns:Schema

the Schema object being used to perform unmarshal-time validation or null if not present

getXMLReaderback to summary
protected XMLReader getXMLReader() throws JAXBException

Obtains a configured XMLReader. This method is used when the client-specified SAXSource object doesn't have XMLReader. Unmarshaller is not re-entrant, so we will only use one instance of XMLReader.

isValidatingback to summary
public boolean isValidating() throws JAXBException

Implements javax.xml.bind.Unmarshaller.isValidating.

Indicates whether or not the Unmarshaller is configured to validate during unmarshal operations.

Note

I named this method isValidating() to stay in-line with JAXP, as opposed to naming it getValidating().

Returns:boolean

true if the Unmarshaller is configured to validate during unmarshal operations, false otherwise

Exceptions
JAXBException:
if an error occurs while retrieving the validating flag
setAdapterback to summary
public void setAdapter(XmlAdapter<ValueType, BoundType> adapter)

Implements javax.xml.bind.Unmarshaller.setAdapter.

Doc from javax.xml.bind.Unmarshaller.setAdapter.

Associates a configured instance of XmlAdapter with this unmarshaller.

This is a convenience method that invokes setAdapter(adapter.getClass(),adapter);.

setAdapterback to summary
public <A extends XmlAdapter<ValueType, BoundType>> void setAdapter(Class<A> type, A adapter)

Implements javax.xml.bind.Unmarshaller.setAdapter.

Doc from javax.xml.bind.Unmarshaller.setAdapter.

Associates a configured instance of XmlAdapter with this unmarshaller.

Every unmarshaller internally maintains a java.util.Map<Class,XmlAdapter>, which it uses for unmarshalling classes whose fields/methods are annotated with javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter.

This method allows applications to use a configured instance of XmlAdapter. When an instance of an adapter is not given, an unmarshaller will create one by invoking its default constructor.

Parameters
type:Class<A>

The type of the adapter. The specified instance will be used when javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter#value() refers to this type.

adapter:A

The instance of the adapter to be used. If null, it will un-register the current adapter set for this type.

setAttachmentUnmarshallerback to summary
public void setAttachmentUnmarshaller(AttachmentUnmarshaller au)

Implements javax.xml.bind.Unmarshaller.setAttachmentUnmarshaller.

Doc from javax.xml.bind.Unmarshaller.setAttachmentUnmarshaller.

Associate a context that resolves cid's, content-id URIs, to binary data passed as attachments.

Unmarshal time validation, enabled via setSchema(Schema), must be supported even when unmarshaller is performing XOP processing.

setEventHandlerback to summary
public void setEventHandler(ValidationEventHandler handler) throws JAXBException

Implements javax.xml.bind.Unmarshaller.setEventHandler.

Allow an application to register a validation event handler.

The validation event handler will be called by the JAXB Provider if any validation errors are encountered during calls to any of the unmarshal methods. If the client application does not register a validation event handler before invoking the unmarshal methods, then all validation events will be silently ignored and may result in unexpected behaviour.

Parameters
handler:ValidationEventHandler

the validation event handler

Exceptions
JAXBException:
if an error was encountered while setting the event handler
setListenerback to summary
public void setListener(Unmarshaller.Listener listener)

Implements javax.xml.bind.Unmarshaller.setListener.

Doc from javax.xml.bind.Unmarshaller.setListener.

Register unmarshal event callback Listener with this Unmarshaller.

There is only one Listener per Unmarshaller. Setting a Listener replaces the previous set Listener. One can unregister current Listener by setting listener to null.

Parameters
listener:Unmarshaller.Listener

provides unmarshal event callbacks for this Unmarshaller

setPropertyback to summary
public void setProperty(String name, Object value) throws PropertyException

Implements javax.xml.bind.Unmarshaller.setProperty.

Default implementation of the setProperty method always throws PropertyException since there are no required properties. If a provider needs to handle additional properties, it should override this method in a derived class.

Parameters
name:String

Doc from javax.xml.bind.Unmarshaller.setProperty.

the name of the property to be set. This value can either be specified using one of the constant fields or a user supplied string.

value:Object

Doc from javax.xml.bind.Unmarshaller.setProperty.

the value of the property to be set

Exceptions
PropertyException:

Doc from javax.xml.bind.Unmarshaller.setProperty.

when there is an error processing the given property or value

setSchemaback to summary
public void setSchema(Schema schema)

Implements javax.xml.bind.Unmarshaller.setSchema.

Doc from javax.xml.bind.Unmarshaller.setSchema.

Specify the JAXP 1.3 Schema object that should be used to validate subsequent unmarshal operations against. Passing null into this method will disable validation.

This method replaces the deprecated setValidating(boolean) API.

Initially this property is set to null.

Parameters
schema:Schema

Schema object to validate unmarshal operations against or null to disable validation

setValidatingback to summary
public void setValidating(boolean validating) throws JAXBException

Implements javax.xml.bind.Unmarshaller.setValidating.

Specifies whether or not the Unmarshaller should validate during unmarshal operations. By default, the Unmarshaller does not validate.

This method may only be invoked before or after calling one of the unmarshal methods.

Parameters
validating:boolean

true if the Unmarshaller should validate during unmarshal, false otherwise

Exceptions
JAXBException:
if an error occurred while enabling or disabling validation at unmarshal time
streamSourceToInputSourceback to summary
private static InputSource streamSourceToInputSource(StreamSource ss)
unmarshalback to summary
public Object unmarshal(Source source) throws JAXBException

Implements javax.xml.bind.Unmarshaller.unmarshal.

Doc from javax.xml.bind.Unmarshaller.unmarshal.

Unmarshal XML data from the specified XML Source and return the resulting content tree.

Implements Unmarshal Global Root Element.

SAX 2.0 Parser Pluggability

A client application can choose not to use the default parser mechanism supplied with their JAXB provider. Any SAX 2.0 compliant parser can be substituted for the JAXB provider's default mechanism. To do so, the client application must properly configure a SAXSource containing an XMLReader implemented by the SAX 2.0 parser provider. If the XMLReader has an org.xml.sax.ErrorHandler registered on it, it will be replaced by the JAXB Provider so that validation errors can be reported via the ValidationEventHandler mechanism of JAXB. If the SAXSource does not contain an XMLReader, then the JAXB provider's default parser mechanism will be used.

This parser replacement mechanism can also be used to replace the JAXB provider's unmarshal-time validation engine. The client application must properly configure their SAX 2.0 compliant parser to perform validation (as shown in the example above). Any SAXParserExceptions encountered by the parser during the unmarshal operation will be processed by the JAXB provider and converted into JAXB ValidationEvent objects which will be reported back to the client via the ValidationEventHandler registered with the Unmarshaller

Note

specifying a substitute validating SAX 2.0 parser for unmarshalling does not necessarily replace the validation engine used by the JAXB provider for performing on-demand validation.

The only way for a client application to specify an alternate parser mechanism to be used during unmarshal is via the unmarshal(SAXSource) API. All other forms of the unmarshal method (File, URL, Node, etc) will use the JAXB provider's default parser and validator mechanisms.

Parameters
source:Source

the XML Source to unmarshal XML data from (providers are only required to support SAXSource, DOMSource, and StreamSource)

Returns:Object

the newly created root object of the java content tree

Exceptions
JAXBException:
If any unexpected errors occur while unmarshalling
unmarshalback to summary
private Object unmarshal(SAXSource source) throws JAXBException
unmarshalback to summary
protected abstract Object unmarshal(XMLReader reader, InputSource source) throws JAXBException

Unmarshals an object by using the specified XMLReader and the InputSource. The callee should call the setErrorHandler method of the XMLReader so that errors are passed to the client-specified ValidationEventHandler.

unmarshalback to summary
public final Object unmarshal(InputSource source) throws JAXBException

Implements javax.xml.bind.Unmarshaller.unmarshal.

Doc from javax.xml.bind.Unmarshaller.unmarshal.

Unmarshal XML data from the specified SAX InputSource and return the resulting content tree.

Implements Unmarshal Global Root Element.

Parameters
source:InputSource

the input source to unmarshal XML data from

Returns:Object

the newly created root object of the java content tree

Exceptions
JAXBException:
If any unexpected errors occur while unmarshalling
unmarshalback to summary
private Object unmarshal(String url) throws JAXBException
unmarshalback to summary
public final Object unmarshal(URL url) throws JAXBException

Implements javax.xml.bind.Unmarshaller.unmarshal.

Doc from javax.xml.bind.Unmarshaller.unmarshal.

Unmarshal XML data from the specified URL and return the resulting content tree.

Implements Unmarshal Global Root Element.

Parameters
url:URL

the url to unmarshal XML data from

Returns:Object

the newly created root object of the java content tree

Exceptions
JAXBException:
If any unexpected errors occur while unmarshalling
unmarshalback to summary
public final Object unmarshal(File f) throws JAXBException

Implements javax.xml.bind.Unmarshaller.unmarshal.

Doc from javax.xml.bind.Unmarshaller.unmarshal.

Unmarshal XML data from the specified file and return the resulting content tree.

Implements Unmarshal Global Root Element.

Parameters
f:File

the file to unmarshal XML data from

Returns:Object

the newly created root object of the java content tree

Exceptions
JAXBException:
If any unexpected errors occur while unmarshalling
unmarshalback to summary
public final Object unmarshal(InputStream is) throws JAXBException

Implements javax.xml.bind.Unmarshaller.unmarshal.

Doc from javax.xml.bind.Unmarshaller.unmarshal.

Unmarshal XML data from the specified InputStream and return the resulting content tree. Validation event location information may be incomplete when using this form of the unmarshal API.

Implements Unmarshal Global Root Element.

Parameters
is:InputStream

the InputStream to unmarshal XML data from

Returns:Object

the newly created root object of the java content tree

Exceptions
JAXBException:
If any unexpected errors occur while unmarshalling
unmarshalback to summary
public final Object unmarshal(Reader reader) throws JAXBException

Implements javax.xml.bind.Unmarshaller.unmarshal.

Doc from javax.xml.bind.Unmarshaller.unmarshal.

Unmarshal XML data from the specified Reader and return the resulting content tree. Validation event location information may be incomplete when using this form of the unmarshal API, because a Reader does not provide the system ID.

Implements Unmarshal Global Root Element.

Parameters
reader:Reader

the Reader to unmarshal XML data from

Returns:Object

the newly created root object of the java content tree

Exceptions
JAXBException:
If any unexpected errors occur while unmarshalling
unmarshalback to summary
public Object unmarshal(XMLEventReader reader) throws JAXBException

Implements javax.xml.bind.Unmarshaller.unmarshal.

Doc from javax.xml.bind.Unmarshaller.unmarshal.

Unmarshal XML data from the specified pull parser and return the resulting content tree.

This method is an Unmarshal Global Root method.

This method assumes that the parser is on a START_DOCUMENT or START_ELEMENT event. Unmarshalling will be done from this start event to the corresponding end event. If this method returns successfully, the reader will be pointing at the token right after the end event.

Parameters
reader:XMLEventReader

The parser to be read.

Returns:Object

the newly created root object of the java content tree.

Exceptions
JAXBException:
If any unexpected errors occur while unmarshalling
unmarshalback to summary
public Object unmarshal(XMLStreamReader reader) throws JAXBException

Implements javax.xml.bind.Unmarshaller.unmarshal.

Doc from javax.xml.bind.Unmarshaller.unmarshal.

Unmarshal XML data from the specified pull parser and return the resulting content tree.

Implements Unmarshal Global Root Element.

This method assumes that the parser is on a START_DOCUMENT or START_ELEMENT event. Unmarshalling will be done from this start event to the corresponding end event. If this method returns successfully, the reader will be pointing at the token right after the end event.

Parameters
reader:XMLStreamReader

The parser to be read.

Returns:Object

the newly created root object of the java content tree.

Exceptions
JAXBException:
If any unexpected errors occur while unmarshalling
unmarshalback to summary
public <T> JAXBElement<T> unmarshal(Node node, Class<T> expectedType) throws JAXBException

Implements javax.xml.bind.Unmarshaller.unmarshal.

Doc from javax.xml.bind.Unmarshaller.unmarshal.

Unmarshal XML data by JAXB mapped declaredType and return the resulting content tree.

Implements Unmarshal by Declared Type

Parameters
node:Node

the document/element to unmarshal XML data from. The caller must support at least Document and Element.

expectedType:Class<T>

appropriate JAXB mapped class to hold node's XML data.

Returns:JAXBElement<T>

JAXB Element representation of node

Exceptions
JAXBException:
If any unexpected errors occur while unmarshalling
unmarshalback to summary
public <T> JAXBElement<T> unmarshal(Source source, Class<T> expectedType) throws JAXBException

Implements javax.xml.bind.Unmarshaller.unmarshal.

Doc from javax.xml.bind.Unmarshaller.unmarshal.

Unmarshal XML data from the specified XML Source by declaredType and return the resulting content tree.

Implements Unmarshal by Declared Type

See SAX 2.0 Parser Pluggability

Parameters
source:Source

the XML Source to unmarshal XML data from (providers are only required to support SAXSource, DOMSource, and StreamSource)

expectedType:Class<T>

appropriate JAXB mapped class to hold source's xml root element

Returns:JAXBElement<T>

Java content rooted by JAXB Element

Exceptions
JAXBException:
If any unexpected errors occur while unmarshalling
unmarshalback to summary
public <T> JAXBElement<T> unmarshal(XMLStreamReader reader, Class<T> expectedType) throws JAXBException

Implements javax.xml.bind.Unmarshaller.unmarshal.

Doc from javax.xml.bind.Unmarshaller.unmarshal.

Unmarshal root element to JAXB mapped declaredType and return the resulting content tree.

This method implements unmarshal by declaredType.

This method assumes that the parser is on a START_DOCUMENT or START_ELEMENT event. Unmarshalling will be done from this start event to the corresponding end event. If this method returns successfully, the reader will be pointing at the token right after the end event.

Parameters
reader:XMLStreamReader

The parser to be read.

expectedType:Class<T>

appropriate JAXB mapped class to hold reader's START_ELEMENT XML data.

Returns:JAXBElement<T>

content tree rooted by JAXB Element representation

Exceptions
JAXBException:
If any unexpected errors occur while unmarshalling
unmarshalback to summary
public <T> JAXBElement<T> unmarshal(XMLEventReader reader, Class<T> expectedType) throws JAXBException

Implements javax.xml.bind.Unmarshaller.unmarshal.

Doc from javax.xml.bind.Unmarshaller.unmarshal.

Unmarshal root element to JAXB mapped declaredType and return the resulting content tree.

This method implements unmarshal by declaredType.

This method assumes that the parser is on a START_DOCUMENT or START_ELEMENT event. Unmarshalling will be done from this start event to the corresponding end event. If this method returns successfully, the reader will be pointing at the token right after the end event.

Parameters
reader:XMLEventReader

The parser to be read.

expectedType:Class<T>

appropriate JAXB mapped class to hold reader's START_ELEMENT XML data.

Returns:JAXBElement<T>

content tree rooted by JAXB Element representation

Exceptions
JAXBException:
If any unexpected errors occur while unmarshalling