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).
javax.xml.bind.Unmarshaller
| Modifier and Type | Field 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 |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected UnmarshalException | Returns: the resulting UnmarshalExceptionCreates an UnmarshalException from a SAXException. |
| public <A extends XmlAdapter | getAdapter(Class<A> type)
Implements javax. |
| public AttachmentUnmarshaller | |
| public ValidationEventHandler | Returns: the current ValidationEventHandler or the default event handler if it hasn't been setImplements javax. |
| public Unmarshaller. | getListener()
Implements javax. Return |
| public Object | getProperty(String
the name of the property to retrieve name)Implements javax. |
| public Schema | getSchema()
Implements javax. Schema object
being used to perform unmarshal-time validation.
|
| protected XMLReader | |
| public boolean | Returns: true if the Unmarshaller is configured to validate during unmarshal operations, false otherwiseImplements javax. |
| public void | setAdapter(XmlAdapter<ValueType, BoundType> adapter)
Implements javax. XmlAdapter with this unmarshaller.
|
| public <A extends XmlAdapter | setAdapter(Class<A>
The type of the adapter. The specified instance will be used when
type, A javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter#value()
refers to this type.The instance of the adapter to be used. If null, it will un-register
the current adapter set for this type. adapter)Implements javax. XmlAdapter with this unmarshaller.
|
| public void | setAttachmentUnmarshaller(AttachmentUnmarshaller au)
Implements javax. 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. |
| public void | setListener(Unmarshaller.
provides unmarshal event callbacks for this listenerUnmarshallerImplements javax.
Register unmarshal event callback |
| 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. |
| public void | setSchema(Schema
Schema object to validate unmarshal operations against or null to disable validation schema)Implements javax. 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. |
| 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. |
| 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. |
| private Object | |
| public final Object | unmarshal(URL
the url to unmarshal XML data from url)Implements javax. |
| public final Object | unmarshal(File
the file to unmarshal XML data from f)Implements javax. |
| public final Object | unmarshal(InputStream
the InputStream to unmarshal XML data from is)Implements javax. |
| public final Object | unmarshal(Reader
the Reader to unmarshal XML data from reader)Implements javax. |
| public Object | unmarshal(XMLEventReader
The parser to be read. reader)Implements javax. |
| public Object | unmarshal(XMLStreamReader
The parser to be read. reader)Implements javax. |
| public <T> JAXBElement | 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 expectedType)node's XML data.Implements javax. declaredType
and return the resulting content tree.
|
| public <T> JAXBElement | 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 expectedType)source's xml root elementImplements javax. declaredType and return the
resulting content tree.
|
| public <T> JAXBElement | unmarshal(XMLStreamReader
The parser to be read. reader, Class<T> appropriate JAXB mapped class to hold expectedType)reader's START_ELEMENT XML data.Implements javax. declaredType
and return the resulting content tree.
|
| public <T> JAXBElement | unmarshal(XMLEventReader
The parser to be read. reader, Class<T> appropriate JAXB mapped class to hold expectedType)reader's START_ELEMENT XML data.Implements javax. declaredType
and return the resulting content tree.
|
| eventHandler | back to summary |
|---|---|
| private ValidationEventHandler eventHandler handler that will be used to process errors and warnings during unmarshal | |
| reader | back to summary |
|---|---|
| private XMLReader reader XMLReader that will be used to parse a document. | |
| validating | back to summary |
|---|---|
| protected boolean validating whether or not the unmarshaller will validate | |
| AbstractUnmarshallerImpl | back to summary |
|---|---|
| public AbstractUnmarshallerImpl() | |
| createUnmarshalException | back 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.
| |
| getAdapter | back to summary |
|---|---|
| public <A extends XmlAdapter Implements javax. Doc from javax. Gets the adapter associated with the specified type.
This is the reverse operation of the | |
| getAttachmentUnmarshaller | back to summary |
|---|---|
| public AttachmentUnmarshaller getAttachmentUnmarshaller() Implements javax. | |
| getEventHandler | back to summary |
|---|---|
| public ValidationEventHandler getEventHandler() throws JAXBException Implements javax. Return the current event handler or the default event handler if one hasn't been set.
| |
| getListener | back to summary |
|---|---|
| public Unmarshaller. Implements javax. Doc from javax. Return
| |
| getProperty | back to summary |
|---|---|
| public Object getProperty(String name) throws PropertyException Implements javax. 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.
| |
| getSchema | back to summary |
|---|---|
| public Schema getSchema() Implements javax. Doc from javax. Get the JAXP 1.3
This method provides replacement functionality for the deprecated
| |
| getXMLReader | back to summary |
|---|---|
| protected XMLReader getXMLReader() throws JAXBException Obtains a configured XMLReader.
This method is used when the client-specified
| |
| isValidating | back to summary |
|---|---|
| public boolean isValidating() throws JAXBException Implements javax. 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().
| |
| setAdapter | back to summary |
|---|---|
| public void setAdapter(XmlAdapter<ValueType, BoundType> adapter) Implements javax. Doc from javax. Associates a configured instance of
This is a convenience method that invokes | |
| setAdapter | back to summary |
|---|---|
| public <A extends XmlAdapter Implements javax. Doc from javax. Associates a configured instance of
Every unmarshaller internally maintains a
This method allows applications to use a configured instance of
| |
| setAttachmentUnmarshaller | back to summary |
|---|---|
| public void setAttachmentUnmarshaller(AttachmentUnmarshaller au) Implements javax. Doc from javax. Associate a context that resolves cid's, content-id URIs, to binary data passed as attachments. Unmarshal time validation, enabled via | |
| setEventHandler | back to summary |
|---|---|
| public void setEventHandler(ValidationEventHandler handler) throws JAXBException Implements javax. 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
| |
| setListener | back to summary |
|---|---|
| public void setListener(Unmarshaller. Implements javax. Doc from javax.
Register unmarshal event callback
There is only one Listener per Unmarshaller. Setting a Listener replaces the previous set Listener.
One can unregister current Listener by setting listener to
| |
| setProperty | back to summary |
|---|---|
| public void setProperty(String name, Object value) throws PropertyException Implements javax. 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.
| |
| setSchema | back to summary |
|---|---|
| public void setSchema(Schema schema) Implements javax. Doc from javax. Specify the JAXP 1.3
This method replaces the deprecated
Initially this property is set to
| |
| setValidating | back to summary |
|---|---|
| public void setValidating(boolean validating) throws JAXBException Implements javax. Specifies whether or not the Unmarshaller should validate during
unmarshal operations. By default, the This method may only be invoked before or after calling one of the unmarshal methods.
| |
| streamSourceToInputSource | back to summary |
|---|---|
| private static InputSource streamSourceToInputSource(StreamSource ss) | |
| unmarshal | back to summary |
|---|---|
| public Object unmarshal(Source source) throws JAXBException Implements javax. Doc from javax. Unmarshal XML data from the specified XML Source and return the resulting content tree. Implements Unmarshal Global Root Element.
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
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 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 | back to summary |
|---|---|
| private Object unmarshal(SAXSource source) throws JAXBException | |
| unmarshal | back 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. | |
| unmarshal | back to summary |
|---|---|
| public final Object unmarshal(InputSource source) throws JAXBException Implements javax. Doc from javax. Unmarshal XML data from the specified SAX InputSource and return the resulting content tree. Implements Unmarshal Global Root Element.
| |
| unmarshal | back to summary |
|---|---|
| private Object unmarshal(String url) throws JAXBException | |
| unmarshal | back to summary |
|---|---|
| public final Object unmarshal(URL url) throws JAXBException Implements javax. Doc from javax. Unmarshal XML data from the specified URL and return the resulting content tree. Implements Unmarshal Global Root Element.
| |
| unmarshal | back to summary |
|---|---|
| public final Object unmarshal(File f) throws JAXBException Implements javax. Doc from javax. Unmarshal XML data from the specified file and return the resulting content tree. Implements Unmarshal Global Root Element.
| |
| unmarshal | back to summary |
|---|---|
| public final Object unmarshal(InputStream is) throws JAXBException Implements javax. Doc from javax. 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.
| |
| unmarshal | back to summary |
|---|---|
| public final Object unmarshal(Reader reader) throws JAXBException Implements javax. Doc from javax. 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.
| |
| unmarshal | back to summary |
|---|---|
| public Object unmarshal(XMLEventReader reader) throws JAXBException Implements javax. Doc from javax. 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
| |
| unmarshal | back to summary |
|---|---|
| public Object unmarshal(XMLStreamReader reader) throws JAXBException Implements javax. Doc from javax. 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
| |
| unmarshal | back to summary |
|---|---|
| public <T> JAXBElement Implements javax. Doc from javax. Unmarshal XML data by JAXB mapped Implements Unmarshal by Declared Type
| |
| unmarshal | back to summary |
|---|---|
| public <T> JAXBElement Implements javax. Doc from javax. Unmarshal XML data from the specified XML Source by Implements Unmarshal by Declared Type See SAX 2.0 Parser Pluggability
| |
| unmarshal | back to summary |
|---|---|
| public <T> JAXBElement Implements javax. Doc from javax. Unmarshal root element to JAXB mapped 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
| |
| unmarshal | back to summary |
|---|---|
| public <T> JAXBElement Implements javax. Doc from javax. Unmarshal root element to JAXB mapped 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
| |