Top Description Fields Constructors Methods
org.glassfish.jaxb.runtime.v2.runtime

public Class BinderImpl<XmlNode>

extends Binder<XmlNode>
Class Inheritance
Imports
org.glassfish.jaxb.core.unmarshaller.InfosetScanner, org.glassfish.jaxb.runtime.v2.runtime.output.DOMOutput, org.glassfish.jaxb.runtime.v2.runtime.unmarshaller.InterningXmlVisitor, .SAXConnector, .UnmarshallerImpl, jakarta.xml.bind.*, org.w3c.dom.Element, .Node, org.xml.sax.SAXException, javax.xml.namespace.QName, javax.xml.validation.Schema

Implementation of Binder.

Todo

investigate how much in-place unmarshalling is implemented - some preliminary work is there. Probably buggy.

Todo

work on the marshaller side.

Author
Kohsuke Kawaguchi ([email protected])

Field Summary

Modifier and TypeField and Description
private final AssociationMap<XmlNode>
assoc

A Binder always works with the same association map.

private final JAXBContextImpl
context

The parent context object.

private MarshallerImpl
marshaller

Lazily create marshaller to do Java->XML binding.

private final InfosetScanner<XmlNode>
private UnmarshallerImpl
unmarshaller

Lazily created unmarshaller to do XML->Java binding.

Constructor Summary

AccessConstructor and Description
pack-priv
BinderImpl(JAXBContextImpl _context, InfosetScanner<XmlNode> scanner)

Method Summary

Modifier and TypeMethod and Description
private Object
associativeUnmarshal(XmlNode xmlNode, boolean inplace, Class<T> expectedType)

private DOMOutput
createOutput(XmlNode xmlNode)

private boolean
public ValidationEventHandler
getEventHandler()

Implements abstract jakarta.xml.bind.Binder.getEventHandler.

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

public Object
getJAXBNode(XmlNode xmlNode)

Implements abstract jakarta.xml.bind.Binder.getJAXBNode.

Gets the Jakarta XML Binding object associated with the given XML element.

private MarshallerImpl
public Marshaller.Listener
public Object
getProperty(String name)

Implements abstract jakarta.xml.bind.Binder.getProperty.

Get the particular property in the underlying implementation of Binder.

public Schema
getSchema()

Implements abstract jakarta.xml.bind.Binder.getSchema.

Gets the last Schema object (including null) set by the setSchema(Schema) method.

private UnmarshallerImpl
public Unmarshaller.Listener
public XmlNode
getXMLNode(Object jaxbObject)

Implements abstract jakarta.xml.bind.Binder.getXMLNode.

Gets the XML element associated with the given Jakarta XML Binding object.

public void
marshal(Object jaxbObject, XmlNode xmlNode)

Implements abstract jakarta.xml.bind.Binder.marshal.

Marshal a Jakarta XML Binding object tree to a new XML document.

public void
setEventHandler(ValidationEventHandler handler)

Implements abstract jakarta.xml.bind.Binder.setEventHandler.

Allow an application to register a ValidationEventHandler.

public void
public void
setProperty(String name, Object value)

Implements abstract jakarta.xml.bind.Binder.setProperty.

Set the particular property in the underlying implementation of Binder.

public void
setSchema(Schema schema)

Implements abstract jakarta.xml.bind.Binder.setSchema.

Specifies whether marshal, unmarshal and update methods performs validation on their XML content.

public void
public Object
unmarshal(XmlNode xmlNode)

Implements abstract jakarta.xml.bind.Binder.unmarshal.

Unmarshal XML infoset view to a Jakarta XML Binding object tree.

public <T> JAXBElement<T>
unmarshal(XmlNode xmlNode, Class<T> expectedType)

Implements abstract jakarta.xml.bind.Binder.unmarshal.

Unmarshal XML root element by provided declaredType to a Jakarta XML Binding object tree.

public Object
updateJAXB(XmlNode xmlNode)

Implements abstract jakarta.xml.bind.Binder.updateJAXB.

Takes an XML node and updates its associated Jakarta XML Binding object and its descendants.

public XmlNode
updateXML(Object jaxbObject)

Implements abstract jakarta.xml.bind.Binder.updateXML.

Takes an Jakarta XML Binding object and updates its associated XML node and its descendants.

public XmlNode
updateXML(Object jaxbObject, XmlNode xmlNode)

Implements abstract jakarta.xml.bind.Binder.updateXML.

Changes in Jakarta XML Binding object tree are updated in its associated XML parse tree.

Field Detail

assocback to summary
private final AssociationMap<XmlNode> assoc

A Binder always works with the same association map.

contextback to summary
private final JAXBContextImpl context

The parent context object.

marshallerback to summary
private MarshallerImpl marshaller

Lazily create marshaller to do Java->XML binding.

See Also
getMarshaller()
scannerback to summary
private final InfosetScanner<XmlNode> scanner
unmarshallerback to summary
private UnmarshallerImpl unmarshaller

Lazily created unmarshaller to do XML->Java binding.

See Also
getUnmarshaller()

Constructor Detail

BinderImplback to summary
pack-priv BinderImpl(JAXBContextImpl _context, InfosetScanner<XmlNode> scanner)

Method Detail

associativeUnmarshalback to summary
private Object associativeUnmarshal(XmlNode xmlNode, boolean inplace, Class<T> expectedType) throws JAXBException
createOutputback to summary
private DOMOutput createOutput(XmlNode xmlNode)
excludePropertyback to summary
private boolean excludeProperty(String name)
getEventHandlerback to summary
public ValidationEventHandler getEventHandler()

Implements abstract jakarta.xml.bind.Binder.getEventHandler.

Doc from jakarta.xml.bind.Binder.getEventHandler.

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

Annotations
@Override
getJAXBNodeback to summary
public Object getJAXBNode(XmlNode xmlNode)

Implements abstract jakarta.xml.bind.Binder.getJAXBNode.

Doc from jakarta.xml.bind.Binder.getJAXBNode.

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.

Annotations
@Override
getMarshallerback to summary
private MarshallerImpl getMarshaller()
getMarshallerListenerback to summary
public Marshaller.Listener getMarshallerListener()
getPropertyback to summary
public Object getProperty(String name) throws PropertyException

Implements abstract jakarta.xml.bind.Binder.getProperty.

Doc from jakarta.xml.bind.Binder.getProperty.

Get the particular property in the underlying implementation of Binder. This method can only be used to get one of the standard Jakarta XML Binding defined unmarshal/marshal properties or a provider specific property for binder, unmarshal or marshal. Attempting to get an undefined property will result in a PropertyException being thrown. See Supported Unmarshal Properties and Supported Marshal Properties.

Annotations
@Override
Exceptions
PropertyException:
when there is an error retrieving the given property or value property name
getSchemaback to summary
public Schema getSchema()

Implements abstract jakarta.xml.bind.Binder.getSchema.

Doc from jakarta.xml.bind.Binder.getSchema.

Gets the last Schema object (including null) set by the setSchema(Schema) method.

Annotations
@Override
getUnmarshallerback to summary
private UnmarshallerImpl getUnmarshaller()
getUnmarshallerListenerback to summary
public Unmarshaller.Listener getUnmarshallerListener()
getXMLNodeback to summary
public XmlNode getXMLNode(Object jaxbObject)

Implements abstract jakarta.xml.bind.Binder.getXMLNode.

Doc from jakarta.xml.bind.Binder.getXMLNode.

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.

Annotations
@Override
marshalback to summary
public void marshal(Object jaxbObject, XmlNode xmlNode) throws JAXBException

Implements abstract jakarta.xml.bind.Binder.marshal.

Doc from jakarta.xml.bind.Binder.marshal.

Marshal a Jakarta XML Binding object tree to a new XML document.

This method is similar to Marshaller#marshal(Object, Node) with the addition of maintaining the association between Jakarta XML Binding objects and the produced XML nodes, enabling future update operations such as updateXML(Object, Object) or updateJAXB(Object).

When getSchema() is non-null, the marshalled xml content is validated during this operation.

Annotations
@Override
Exceptions
JAXBException:
If any unexpected problem occurs during the marshalling.
setEventHandlerback to summary
public void setEventHandler(ValidationEventHandler handler) throws JAXBException

Implements abstract jakarta.xml.bind.Binder.setEventHandler.

Doc from jakarta.xml.bind.Binder.setEventHandler.

Allow an application to register a ValidationEventHandler.

The ValidationEventHandler will be called by the Jakarta XML Binding Provider if any validation errors are encountered during calls to any of the Binder unmarshal, marshal and update methods.

Calling this method with a null parameter will cause the Binder to revert back to the default default event handler.

Annotations
@Override
Exceptions
JAXBException:
if an error was encountered while setting the event handler
setMarshallerListenerback to summary
public void setMarshallerListener(Marshaller.Listener listener)
setPropertyback to summary
public void setProperty(String name, Object value) throws PropertyException

Implements abstract jakarta.xml.bind.Binder.setProperty.

Doc from jakarta.xml.bind.Binder.setProperty.

Set the particular property in the underlying implementation of Binder. This method can only be used to set one of the standard Jakarta XML Binding defined unmarshal/marshal properties or a provider specific property for binder, unmarshal or marshal. Attempting to set an undefined property will result in a PropertyException being thrown. See Supported Unmarshal Properties and Supported Marshal Properties.

Annotations
@Override
Exceptions
PropertyException:
when there is an error processing the given property or value
setSchemaback to summary
public void setSchema(Schema schema)

Implements abstract jakarta.xml.bind.Binder.setSchema.

Doc from jakarta.xml.bind.Binder.setSchema.

Specifies whether marshal, unmarshal and update methods performs validation on their XML content.

Annotations
@Override
setUnmarshallerListenerback to summary
public void setUnmarshallerListener(Unmarshaller.Listener listener)
unmarshalback to summary
public Object unmarshal(XmlNode xmlNode) throws JAXBException

Implements abstract jakarta.xml.bind.Binder.unmarshal.

Doc from jakarta.xml.bind.Binder.unmarshal.

Unmarshal XML infoset view to a Jakarta XML Binding object tree.

This method is similar to Unmarshaller#unmarshal(Node) with the addition of maintaining the association between XML nodes and the produced Jakarta XML Binding objects, enabling future update operations, updateXML(Object, Object) or updateJAXB(Object).

When getSchema() is non-null, xmlNode and its descendants is validated during this operation.

This method throws UnmarshalException when the Binder's JAXBContext does not have a mapping for the XML element name or the type, specifiable via @xsi:type, of xmlNode to a Jakarta XML Binding mapped class. The method unmarshal(Object, Class) enables an application to specify the Jakarta XML Binding mapped class that the xmlNode should be mapped to.

Annotations
@Override
Exceptions
JAXBException:
If any unexpected errors occur while unmarshalling
unmarshalback to summary
public <T> JAXBElement<T> unmarshal(XmlNode xmlNode, Class<T> expectedType) throws JAXBException

Implements abstract jakarta.xml.bind.Binder.unmarshal.

Doc from jakarta.xml.bind.Binder.unmarshal.

Unmarshal XML root element by provided declaredType to a Jakarta XML Binding object tree.

Implements Unmarshal by Declared Type

This method is similar to Unmarshaller#unmarshal(Node, Class) with the addition of maintaining the association between XML nodes and the produced Jakarta XML Binding objects, enabling future update operations, updateXML(Object, Object) or updateJAXB(Object).

When getSchema() is non-null, xmlNode and its descendants is validated during this operation.

Annotations
@Override
Exceptions
JAXBException:
If any unexpected errors occur while unmarshalling
updateJAXBback to summary
public Object updateJAXB(XmlNode xmlNode) throws JAXBException

Implements abstract jakarta.xml.bind.Binder.updateJAXB.

Doc from jakarta.xml.bind.Binder.updateJAXB.

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.

Annotations
@Override
Exceptions
JAXBException:
If any unexpected problem occurs updating corresponding Jakarta XML Binding mapped content.
updateXMLback to summary
public XmlNode updateXML(Object jaxbObject) throws JAXBException

Implements abstract jakarta.xml.bind.Binder.updateXML.

Doc from jakarta.xml.bind.Binder.updateXML.

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));
Annotations
@Override
Exceptions
JAXBException:
If any unexpected problem occurs updating corresponding XML content.
updateXMLback to summary
public XmlNode updateXML(Object jaxbObject, XmlNode xmlNode) throws JAXBException

Implements abstract jakarta.xml.bind.Binder.updateXML.

Doc from jakarta.xml.bind.Binder.updateXML.

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.

Annotations
@Override
@SuppressWarnings:unchecked
Exceptions
JAXBException:
If any unexpected problem occurs updating corresponding XML content.