W3CDomHandler (Java Platform SE 7 ) (original) (raw)
- 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 the Result. 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) * ### Methods inherited from class java.lang.[Object](../../../../java/lang/Object.html "class in java.lang") `[clone](../../../../java/lang/Object.html#clone%28%29), [equals](../../../../java/lang/Object.html#equals%28java.lang.Object%29), [finalize](../../../../java/lang/Object.html#finalize%28%29), [getClass](../../../../java/lang/Object.html#getClass%28%29), [hashCode](../../../../java/lang/Object.html#hashCode%28%29), [notify](../../../../java/lang/Object.html#notify%28%29), [notifyAll](../../../../java/lang/Object.html#notifyAll%28%29), [toString](../../../../java/lang/Object.html#toString%28%29), [wait](../../../../java/lang/Object.html#wait%28%29), [wait](../../../../java/lang/Object.html#wait%28long%29), [wait](../../../../java/lang/Object.html#wait%28long,%20int%29)`
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](../../../../javax/xml/parsers/DocumentBuilder.html "class in javax.xml.parsers") builder) Constructor that allows applications to specify which DOM implementation to be used. Parameters: `builder` \- must not be null. JAXB uses this [DocumentBuilder](../../../../javax/xml/parsers/DocumentBuilder.html "class in javax.xml.parsers") to create a new element.
Method Detail
* #### getBuilder public [DocumentBuilder](../../../../javax/xml/parsers/DocumentBuilder.html "class in javax.xml.parsers") getBuilder() * #### setBuilder public void setBuilder([DocumentBuilder](../../../../javax/xml/parsers/DocumentBuilder.html "class in javax.xml.parsers") builder) * #### createUnmarshaller public [DOMResult](../../../../javax/xml/transform/dom/DOMResult.html "class in javax.xml.transform.dom") createUnmarshaller([ValidationEventHandler](../../../../javax/xml/bind/ValidationEventHandler.html "interface in javax.xml.bind") errorHandler) **Description copied from interface: `[DomHandler](../../../../javax/xml/bind/annotation/DomHandler.html#createUnmarshaller%28javax.xml.bind.ValidationEventHandler%29)`** 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](../../../../javax/xml/transform/Result.html "interface in javax.xml.transform") 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](../../../../javax/xml/bind/annotation/DomHandler.html#createUnmarshaller%28javax.xml.bind.ValidationEventHandler%29)` in interface `[DomHandler](../../../../javax/xml/bind/annotation/DomHandler.html "interface in javax.xml.bind.annotation")<[Element](../../../../org/w3c/dom/Element.html "interface in org.w3c.dom"),[DOMResult](../../../../javax/xml/transform/dom/DOMResult.html "class in javax.xml.transform.dom")>` Parameters: `errorHandler` \- if any error happens between the invocation of this method and the invocation of [DomHandler.getElement(Result)](../../../../javax/xml/bind/annotation/DomHandler.html#getElement%28ResultT%29), they must be reported to this handler. The caller must provide a non-null error handler. The [Result](../../../../javax/xml/transform/Result.html "interface in javax.xml.transform") 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](../../../../org/w3c/dom/Element.html "interface in org.w3c.dom") getElement([DOMResult](../../../../javax/xml/transform/dom/DOMResult.html "class in javax.xml.transform.dom") r) **Description copied from interface: `[DomHandler](../../../../javax/xml/bind/annotation/DomHandler.html#getElement%28ResultT%29)`** Once the portion is sent to the [Result](../../../../javax/xml/transform/Result.html "interface in javax.xml.transform"). 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](../../../../javax/xml/transform/Result.html "interface in javax.xml.transform") object. **Specified by:** `[getElement](../../../../javax/xml/bind/annotation/DomHandler.html#getElement%28ResultT%29)` in interface `[DomHandler](../../../../javax/xml/bind/annotation/DomHandler.html "interface in javax.xml.bind.annotation")<[Element](../../../../org/w3c/dom/Element.html "interface in org.w3c.dom"),[DOMResult](../../../../javax/xml/transform/dom/DOMResult.html "class in javax.xml.transform.dom")>` Parameters: `r` \- The [Result](../../../../javax/xml/transform/Result.html "interface in javax.xml.transform") object created by [DomHandler.createUnmarshaller(ValidationEventHandler)](../../../../javax/xml/bind/annotation/DomHandler.html#createUnmarshaller%28javax.xml.bind.ValidationEventHandler%29). Returns: null if the operation fails. The error must have been reported to the error handler. * #### marshal public [Source](../../../../javax/xml/transform/Source.html "interface in javax.xml.transform") marshal([Element](../../../../org/w3c/dom/Element.html "interface in org.w3c.dom") element, [ValidationEventHandler](../../../../javax/xml/bind/ValidationEventHandler.html "interface in javax.xml.bind") errorHandler) **Description copied from interface: `[DomHandler](../../../../javax/xml/bind/annotation/DomHandler.html#marshal%28ElementT,%20javax.xml.bind.ValidationEventHandler%29)`** This method is called when a JAXB provider needs to marshal an element to XML. If non-null, the returned [Source](../../../../javax/xml/transform/Source.html "interface in javax.xml.transform") 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](../../../../javax/xml/bind/annotation/DomHandler.html#marshal%28ElementT,%20javax.xml.bind.ValidationEventHandler%29)` in interface `[DomHandler](../../../../javax/xml/bind/annotation/DomHandler.html "interface in javax.xml.bind.annotation")<[Element](../../../../org/w3c/dom/Element.html "interface in org.w3c.dom"),[DOMResult](../../../../javax/xml/transform/dom/DOMResult.html "class in javax.xml.transform.dom")>` `errorHandler` \- Receives any errors happened during the process of converting an element into a [Source](../../../../javax/xml/transform/Source.html "interface in javax.xml.transform"). 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.
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2020, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.