Unmarshaller implementation.
This class provides a partial default implementation for the
jakarta.xml.bind.Unmarshallerinterface.
A Jakarta XML Binding Provider has to implement five methods (getUnmarshallerHandler, unmarshal(Node), unmarshal(XMLReader,InputSource), unmarshal(XMLStreamReader), and unmarshal(XMLEventReader).
jakarta.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. |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| protected UnmarshalException | Returns: the resulting UnmarshalExceptionCreates an UnmarshalException from a SAXException. |
| public <A extends XmlAdapter | getAdapter(Class<A>
The type of the adapter. The specified instance will be used when
type)jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter#value()
refers to this type.Implements jakarta. |
| public AttachmentUnmarshaller | |
| public ValidationEventHandler | Returns: the current ValidationEventHandler or the default event handler if it hasn't been setImplements jakarta. |
| public Unmarshaller. | getListener()
Implements jakarta. Return |
| public Object | getProperty(String
the name of the property to retrieve name)Implements jakarta. |
| public Schema | getSchema()
Implements jakarta. Schema object
being used to perform unmarshal-time validation.
|
| protected XMLReader | |
| public <A extends XmlAdapter | setAdapter(A
the configured instance of adapter)XmlAdapterImplements jakarta. 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 jakarta.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 jakarta. XmlAdapter with this unmarshaller.
|
| public void | setAttachmentUnmarshaller(AttachmentUnmarshaller
the attachment unmarshaller to be set au)Implements jakarta. |
| public void | setEventHandler(ValidationEventHandler
the validation event handler handler)Implements jakarta. |
| public void | setListener(Unmarshaller.
provides unmarshal event callbacks for this listenerUnmarshallerImplements jakarta.
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 jakarta. |
| public void | setSchema(Schema
Schema object to validate unmarshal operations against or null to disable validation schema)Implements jakarta. Schema
object that should be used to validate subsequent unmarshal operations
against.
|
| 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 jakarta. |
| 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 jakarta. |
| private Object | |
| public final Object | unmarshal(URL
the url to unmarshal XML data from url)Implements jakarta. |
| public final Object | unmarshal(File
the file to unmarshal XML data from f)Implements jakarta. |
| public final Object | unmarshal(InputStream
the InputStream to unmarshal XML data from is)Implements jakarta. |
| public final Object | unmarshal(Reader
the Reader to unmarshal XML data from reader)Implements jakarta. |
| public Object | unmarshal(XMLEventReader
The parser to be read. reader)Implements jakarta. |
| public Object | unmarshal(XMLStreamReader
The parser to be read. reader)Implements jakarta. |
| 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 Jakarta XML Binding mapped class to hold expectedType)node's XML data.Implements jakarta. 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 Jakarta XML Binding mapped class to hold expectedType)source's xml root elementImplements jakarta. declaredType and return the
resulting content tree.
|
| public <T> JAXBElement | unmarshal(XMLStreamReader
The parser to be read. reader, Class<T> appropriate Jakarta XML Binding mapped class to hold expectedType)reader's START_ELEMENT XML data.Implements jakarta. declaredType
and return the resulting content tree.
|
| public <T> JAXBElement | unmarshal(XMLEventReader
The parser to be read. reader, Class<T> appropriate Jakarta XML Binding mapped class to hold expectedType)reader's START_ELEMENT XML data.Implements jakarta. 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. | |
| AbstractUnmarshallerImpl | back to summary |
|---|---|
| protected AbstractUnmarshallerImpl() Do-nothing constructor for the derived classes. | |
| 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 jakarta. Doc from jakarta. Gets the adapter associated with the specified type.
This is the reverse operation of the
| |
| getAttachmentUnmarshaller | back to summary |
|---|---|
| public AttachmentUnmarshaller getAttachmentUnmarshaller() Implements jakarta.
| |
| getEventHandler | back to summary |
|---|---|
| public ValidationEventHandler getEventHandler() throws JAXBException Implements jakarta. Return the current event handler or the default event handler if one hasn't been set.
| |
| getListener | back to summary |
|---|---|
| public Unmarshaller. Implements jakarta. Doc from jakarta. Return
| |
| getProperty | back to summary |
|---|---|
| public Object getProperty(String name) throws PropertyException Implements jakarta. 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 jakarta. Doc from jakarta. Get the JAXP | |
| getXMLReader | back to summary |
|---|---|
| protected XMLReader getXMLReader() throws JAXBException Obtains a configured XMLReader.
This method is used when the client-specified
| |
| setAdapter | back to summary |
|---|---|
| public <A extends XmlAdapter Implements jakarta. Doc from jakarta. Associates a configured instance of
This is a convenience method that invokes
| |
| setAdapter | back to summary |
|---|---|
| public <A extends XmlAdapter Implements jakarta. Doc from jakarta. 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 jakarta. Doc from jakarta. 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 jakarta. Allow an application to register a validation event handler.
The validation event handler will be called by the Jakarta XML Binding Provider if any
validation errors are encountered during calls to any of the
| |
| setListener | back to summary |
|---|---|
| public void setListener(Unmarshaller. Implements jakarta. Doc from jakarta.
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 jakarta. 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 jakarta. Doc from jakarta. Specify the JAXP
Initially this property is set to | |
| streamSourceToInputSource | back to summary |
|---|---|
| private static InputSource streamSourceToInputSource(StreamSource ss) | |
| unmarshal | back to summary |
|---|---|
| public Object unmarshal(Source source) throws JAXBException Implements jakarta. Doc from jakarta. 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 Jakarta XML Binding provider. Any SAX 2.0 compliant parser can be
substituted for the Jakarta XML Binding 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 Jakarta XML Binding
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 Jakarta XML Binding 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 jakarta. Doc from jakarta. 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 jakarta. Doc from jakarta. 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 jakarta. Doc from jakarta. 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 jakarta. Doc from jakarta. 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 jakarta. Doc from jakarta. 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 jakarta. Doc from jakarta. 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 jakarta. Doc from jakarta. 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 jakarta. Doc from jakarta. Unmarshal XML data by Jakarta XML Binding mapped Implements Unmarshal by Declared Type
| |
| unmarshal | back to summary |
|---|---|
| public <T> JAXBElement Implements jakarta. Doc from jakarta. 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 jakarta. Doc from jakarta. Unmarshal root element to Jakarta XML Binding 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 jakarta. Doc from jakarta. Unmarshal root element to Jakarta XML Binding 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
| |