Class Binder<XmlNode>

java.lang.Object
jakarta.xml.bind.Binder<XmlNode>
Type Parameters:
XmlNode - the template parameter, 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.

public abstract class Binder<XmlNode> extends Object
Enable synchronization between XML infoset nodes and Jakarta XML Binding objects representing same XML document.

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:

  • load XML document into an XML infoset representation
  • 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.)
  • application access/updates Jakarta XML Binding view of XML document.
  • 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).

Since:
1.6, JAXB 2.0