- java.lang.Object
-
- javax.xml.bind.annotation.W3CDomHandler
-
- All Implemented Interfaces:
- DomHandler<Element,DOMResult>
public class W3CDomHandler extends Object implements DomHandler<Element,DOMResult>
DomHandler
implementation for W3C DOM (org.w3c.dom
package.)- Since:
- JAXB2.0
-
-
Constructor Summary
Constructors Constructor and Description W3CDomHandler()
Default constructor.W3CDomHandler(DocumentBuilder builder)
Constructor that allows applications to specify which DOM implementation to be used.
-
Method Summary
Methods Modifier and Type Method and Description DOMResult
createUnmarshaller(ValidationEventHandler errorHandler)
When a JAXB provider needs to unmarshal a part of a document into an infoset representation, it first calls this method to create aResult
object.DocumentBuilder
getBuilder()
Element
getElement(DOMResult r)
Once the portion is sent to theResult
.Source
marshal(Element element, ValidationEventHandler errorHandler)
This method is called when a JAXB provider needs to marshal an element to XML.void
setBuilder(DocumentBuilder builder)
-
-
-
Constructor Detail
-
W3CDomHandler
public W3CDomHandler()
Default constructor. It is up to a JAXB provider to decide which DOM implementation to use or how that is configured.
-
W3CDomHandler
public W3CDomHandler(DocumentBuilder builder)
Constructor that allows applications to specify which DOM implementation to be used.- Parameters:
builder
- must not be null. JAXB uses thisDocumentBuilder
to create a new element.
-
-
Method Detail
-
getBuilder
public DocumentBuilder getBuilder()
-
setBuilder
public void setBuilder(DocumentBuilder builder)
-
createUnmarshaller
public DOMResult createUnmarshaller(ValidationEventHandler errorHandler)
Description copied from interface:DomHandler
When a JAXB provider needs to unmarshal a part of a document into an infoset representation, it first calls this method to create aResult
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.
- Specified by:
createUnmarshaller
in interfaceDomHandler<Element,DOMResult>
- Parameters:
errorHandler
- if any error happens between the invocation of this method and the invocation ofDomHandler.getElement(Result)
, they must be reported to this handler. The caller must provide a non-null error handler. TheResult
object created from this method may hold a reference to this error handler.- Returns:
- null if the operation fails. The error must have been reported to the error handler.
-
getElement
public Element getElement(DOMResult r)
Description copied from interface:DomHandler
Once the portion is sent to theResult
. 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.- Specified by:
getElement
in interfaceDomHandler<Element,DOMResult>
- Parameters:
r
- TheResult
object created byDomHandler.createUnmarshaller(ValidationEventHandler)
.- Returns:
- null if the operation fails. The error must have been reported to the error handler.
-
marshal
public Source marshal(Element element, ValidationEventHandler errorHandler)
Description copied from interface:DomHandler
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.- Specified by:
marshal
in interfaceDomHandler<Element,DOMResult>
errorHandler
- Receives any errors happened during the process of converting an element into aSource
. The caller must provide a non-null error handler.- Returns:
- null if there was an error. The error should have been reported to the handler.
-
-
Document created the 11/06/2005, last modified the 04/03/2020
Source of the printed document:https://www.gaudry.be/en/java-api-rf-javax/xml/bind/annotation/w3cdomhandler.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.