XmlNode, is the
root interface/class for the XML infoset preserving representation.
A Binder implementation is required to minimally support
an XmlNode value of org.w3c.dom.Node.class.
A Binder implementation can support alternative XML infoset
preserving representations.
An instance of this class maintains the association between XML nodes of
an infoset preserving view and a Jakarta XML Binding representation of an XML document.
Navigation between the two views is provided by the methods
getXMLNode(Object) and getJAXBNode(Object).
Modifications can be made to either the infoset preserving view or the
Jakarta XML Binding representation of the document while the other view remains
unmodified. The binder is able to synchronize the changes made in the
modified view back into the other view using the appropriate
Binder update methods, updateXML(Object, Object) or
updateJAXB(Object).
A typical usage scenario is the following:
unmarshal(Object) XML infoset view to Jakarta XML Binding view.
(Note to conserve resources, it is possible to only unmarshal a
subtree of the XML infoset view to the Jakarta XML Binding view.)updateXML(Object) synchronizes modifications to Jakarta XML Binding view
back into the XML infoset view. Update operation preserves as
much of original XML infoset as possible (i.e. comments, PI, ...)
A Binder instance is created using the factory method
JAXBContext#createBinder() or JAXBContext#createBinder(Class).
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public abstract ValidationEventHandler | Returns: the current ValidationEventHandler or the default event handler if it hasn't been setReturn the current event handler or the default event handler if one hasn't been set. |
| public abstract Object | Returns: null if the specified XML node is not known to thisBinder, or if it is not associated with a
Jakarta XML Binding object.the XML element xmlNode)Gets the Jakarta XML Binding object associated with the given XML element. |
| public abstract Object | Returns: the value of the requested propertythe name of the property to retrieve name)Get the particular property in the underlying implementation of
|
| public abstract Schema | Returns: the Schema object for validation or null if not presentGets the last |
| public abstract XmlNode | Returns: null if the specified Jakarta XML Binding object is not known to thisBinder, or if it is not associated with an
XML element.An instance that is reachable from a prior
call to a bind or update method that returned
a Jakarta XML Binding object tree. jaxbObject)Gets the XML element associated with the given Jakarta XML Binding object. |
| public abstract void | |
| public abstract void | setEventHandler(ValidationEventHandler
the validation event handler handler)Allow an application to register a |
| public abstract 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)Set the particular property in the underlying implementation of
|
| public abstract void | |
| public abstract Object | Returns: the newly created root object of the Jakarta XML Binding object tree.the document/element to unmarshal XML data from. xmlNode)Unmarshal XML infoset view to a Jakarta XML Binding object tree. |
| public abstract < the declared type T> JAXBElement | |
| public abstract Object | Returns: Returns the updated Jakarta XML Binding object. Typically, this is the same object that was returned from earliermarshal(Object, Object) or
updateJAXB(Object) method invocation,
but it maybe
a different object, for example when the name of the XML
element has changed.the XML node xmlNode)Takes an XML node and updates its associated Jakarta XML Binding object and its descendants. |
| public abstract XmlNode | |
| public abstract XmlNode | Returns: Returns the updated XML node. Typically, this is the same node you passed in as xmlNode, but it maybe a different object, for example when the tag name of the object has changed.root of potentially modified Jakarta XML Binding object tree jaxbObject, XmlNode root of update target XML parse tree xmlNode)Changes in Jakarta XML Binding object tree are updated in its associated XML parse tree. |
| Binder | back to summary |
|---|---|
| protected Binder() Do-nothing constructor for the derived classes. | |
| getEventHandler | back to summary |
|---|---|
| public abstract ValidationEventHandler getEventHandler() throws JAXBException Return the current event handler or the default event handler if one hasn't been set.
| |
| getJAXBNode | back to summary |
|---|---|
| public abstract Object getJAXBNode(XmlNode xmlNode) Gets the Jakarta XML Binding object associated with the given XML element. Once a Jakarta XML Binding object tree is associated with an XML fragment, this method enables navigation between the two trees. An association between an XML element and a Jakarta XML Binding object is established by the unmarshal, marshal and update methods. Note that this association is partial; not all XML elements have associated Jakarta XML Binding objects, and not all Jakarta XML Binding objects have associated XML elements.
| |
| getProperty | back to summary |
|---|---|
| public abstract Object getProperty(String name) throws PropertyException Get the particular property in the underlying implementation of
| |
| getSchema | back to summary |
|---|---|
| public abstract Schema getSchema() Gets the last
| |
| getXMLNode | back to summary |
|---|---|
| public abstract XmlNode getXMLNode(Object jaxbObject) Gets the XML element associated with the given Jakarta XML Binding object. Once a Jakarta XML Binding object tree is associated with an XML fragment, this method enables navigation between the two trees. An association between an XML element and a Jakarta XML Binding object is established by the bind methods and the update methods. Note that this association is partial; not all XML elements have associated Jakarta XML Binding objects, and not all Jakarta XML Binding objects have associated XML elements.
| |
| marshal | back to summary |
|---|---|
| public abstract void marshal(Object jaxbObject, XmlNode xmlNode) throws JAXBException Marshal a Jakarta XML Binding object tree to a new XML document.
This method is similar to
When
| |
| setEventHandler | back to summary |
|---|---|
| public abstract void setEventHandler(ValidationEventHandler handler) throws JAXBException Allow an application to register a
The Calling this method with a null parameter will cause the Binder to revert back to the default default event handler.
| |
| setProperty | back to summary |
|---|---|
| public abstract void setProperty(String name, Object value) throws PropertyException Set the particular property in the underlying implementation of
| |
| setSchema | back to summary |
|---|---|
| public abstract void setSchema(Schema schema) Specifies whether marshal, unmarshal and update methods performs validation on their XML content.
| |
| unmarshal | back to summary |
|---|---|
| public abstract Object unmarshal(XmlNode xmlNode) throws JAXBException Unmarshal XML infoset view to a Jakarta XML Binding object tree.
This method is similar to
When
This method throws
| |
| unmarshal | back to summary |
|---|---|
| public abstract <T> JAXBElement Unmarshal XML root element by provided Implements Unmarshal by Declared Type
This method is similar to
When
| |
| updateJAXB | back to summary |
|---|---|
| public abstract Object updateJAXB(XmlNode xmlNode) throws JAXBException Takes an XML node and updates its associated Jakarta XML Binding object and its descendants. This operation can be thought of as an "in-place" unmarshalling. The difference is that instead of creating a whole new Jakarta XML Binding tree, this operation updates an existing tree, reusing as much Jakarta XML Binding objects as possible. As a side-effect, this operation updates the association between XML nodes and Jakarta XML Binding objects.
| |
| updateXML | back to summary |
|---|---|
| public abstract XmlNode updateXML(Object jaxbObject) throws JAXBException Takes an Jakarta XML Binding object and updates its associated XML node and its descendants. This is a convenience method of: updateXML( jaxbObject, getXMLNode(jaxbObject));
| |
| updateXML | back to summary |
|---|---|
| public abstract XmlNode updateXML(Object jaxbObject, XmlNode xmlNode) throws JAXBException Changes in Jakarta XML Binding object tree are updated in its associated XML parse tree. This operation can be thought of as an "in-place" marshalling. The difference is that instead of creating a whole new XML tree, this operation updates an existing tree while trying to preserve the XML as much as possible. For example, unknown elements/attributes in XML that were not bound to Jakarta XML Binding will be left untouched (whereas a marshalling operation would create a new tree that doesn't contain any of those.) As a side-effect, this operation updates the association between XML nodes and Jakarta XML Binding objects.
| |