Top Description Fields Constructors Methods
javax.xml.bind.annotation

public Class W3CDomHandler

extends Object
implements DomHandler<Element, DOMResult>
Class Inheritance
All Implemented Interfaces
javax.xml.bind.annotation.DomHandler
Imports
org.w3c.dom.Document, .DocumentFragment, .Element, .Node, javax.xml.bind.ValidationEventHandler, javax.xml.parsers.DocumentBuilder, javax.xml.transform.Source, javax.xml.transform.dom.DOMResult, .DOMSource

DomHandler implementation for W3C DOM (org.w3c.dom package.)
Author
Kohsuke Kawaguchi
Since
1.6, JAXB 2.0

Field Summary

Modifier and TypeField and Description
private DocumentBuilder

Constructor Summary

AccessConstructor and Description
public
W3CDomHandler()

Default constructor.

public
W3CDomHandler(DocumentBuilder
must not be null. JAXB uses this DocumentBuilder to create a new element.
builder
)

Constructor that allows applications to specify which DOM implementation to be used.

Method Summary

Modifier and TypeMethod and Description
public DOMResult
createUnmarshaller(ValidationEventHandler
if any error happens between the invocation of this method and the invocation of getElement(Result), they must be reported to this handler. The caller must provide a non-null error handler. The Result object created from this method may hold a reference to this error handler.
errorHandler
)

Implements javax.xml.bind.annotation.DomHandler.createUnmarshaller.

When a JAXB provider needs to unmarshal a part of a document into an infoset representation, it first calls this method to create a Result object.
public DocumentBuilder
public Element
public Source
marshal(Element element, ValidationEventHandler
Receives any errors happened during the process of converting an element into a Source. The caller must provide a non-null error handler.
errorHandler
)

Implements javax.xml.bind.annotation.DomHandler.marshal.

This method is called when a JAXB provider needs to marshal an element to XML.
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

builderback to summary
private DocumentBuilder builder

Constructor Detail

W3CDomHandlerback to summary
public W3CDomHandler()

Default constructor. It is up to a JAXB provider to decide which DOM implementation to use or how that is configured.

W3CDomHandlerback to summary
public W3CDomHandler(DocumentBuilder builder)

Constructor that allows applications to specify which DOM implementation to be used.

Parameters
builder:DocumentBuilder

must not be null. JAXB uses this DocumentBuilder to create a new element.

Method Detail

createUnmarshallerback to summary
public DOMResult createUnmarshaller(ValidationEventHandler errorHandler)

Implements javax.xml.bind.annotation.DomHandler.createUnmarshaller.

Doc from javax.xml.bind.annotation.DomHandler.createUnmarshaller.

When a JAXB provider needs to unmarshal a part of a document into an infoset representation, it first calls this method to create a Result object.

A JAXB provider will then send a portion of the XML into the given result. Such a portion always form a subtree of the whole XML document rooted at an element.

Parameters
errorHandler:ValidationEventHandler

if any error happens between the invocation of this method and the invocation of getElement(Result), they must be reported to this handler. The caller must provide a non-null error handler. The Result object created from this method may hold a reference to this error handler.

Returns:DOMResult

null if the operation fails. The error must have been reported to the error handler.

getBuilderback to summary
public DocumentBuilder getBuilder()
getElementback to summary
public Element getElement(DOMResult r)

Implements javax.xml.bind.annotation.DomHandler.getElement.

Doc from javax.xml.bind.annotation.DomHandler.getElement.

Once the portion is sent to the Result. This method is called by a JAXB provider to obtain the unmarshalled element representation.

Multiple invocations of this method may return different objects. This method can be invoked only when the whole sub-tree are fed to the Result object.

Parameters
r:DOMResult

The Result object created by createUnmarshaller(ValidationEventHandler).

Returns:Element

null if the operation fails. The error must have been reported to the error handler.

marshalback to summary
public Source marshal(Element element, ValidationEventHandler errorHandler)

Implements javax.xml.bind.annotation.DomHandler.marshal.

Doc from javax.xml.bind.annotation.DomHandler.marshal.

This method is called when a JAXB provider needs to marshal an element to XML.

If non-null, the returned Source must contain a whole document rooted at one element, which will then be weaved into a bigger document that the JAXB provider is marshalling.

Parameters
errorHandler:ValidationEventHandler

Receives any errors happened during the process of converting an element into a Source. The caller must provide a non-null error handler.

Returns:Source

null if there was an error. The error should have been reported to the handler.

setBuilderback to summary
public void setBuilder(DocumentBuilder builder)