FileDocCategorySizeDatePackage
W3CDomHandler.javaAPI DocJava SE 6 API2606Tue Jun 10 00:27:04 BST 2008javax.xml.bind.annotation

W3CDomHandler

public class W3CDomHandler extends Object implements DomHandler
{@link DomHandler} implementation for W3C DOM (org.w3c.dom package.)
author
Kohsuke Kawaguchi
since
JAXB2.0

Fields Summary
private DocumentBuilder
builder
Constructors Summary
public W3CDomHandler()
Default constructor. It is up to a JAXB provider to decide which DOM implementation to use or how that is configured.

        this.builder = null;
    
public W3CDomHandler(DocumentBuilder builder)
Constructor that allows applications to specify which DOM implementation to be used.

param
builder must not be null. JAXB uses this {@link DocumentBuilder} to create a new element.

        if(builder==null)
            throw new IllegalArgumentException();
        this.builder = builder;
    
Methods Summary
public javax.xml.transform.dom.DOMResultcreateUnmarshaller(javax.xml.bind.ValidationEventHandler errorHandler)

        if(builder==null)
            return new DOMResult();
        else
            return new DOMResult(builder.newDocument());
    
public javax.xml.parsers.DocumentBuildergetBuilder()

        return builder;
    
public org.w3c.dom.ElementgetElement(javax.xml.transform.dom.DOMResult r)

        // JAXP spec is ambiguous about what really happens in this case,
        // so work defensively
        Node n = r.getNode();
        if( n instanceof Document ) {
            return ((Document)n).getDocumentElement();
        }
        if( n instanceof Element )
            return (Element)n;
        if( n instanceof DocumentFragment )
            return (Element)n.getChildNodes().item(0);

        // if the result object contains something strange,
        // it is not a user problem, but it is a JAXB provider's problem.
        // That's why we throw a runtime exception.
        throw new IllegalStateException(n.toString());
    
public javax.xml.transform.Sourcemarshal(org.w3c.dom.Element element, javax.xml.bind.ValidationEventHandler errorHandler)

        return new DOMSource(element);
    
public voidsetBuilder(javax.xml.parsers.DocumentBuilder builder)

        this.builder = builder;