org.jboss.wsf.common
Class DOMUtils

java.lang.Object
  extended by org.jboss.wsf.common.DOMUtils

public final class DOMUtils
extends java.lang.Object

DOM2 utilites

Author:
Thomas.Diesler@jboss.org, alessio.soldano@jboss.com

Method Summary
static void clearThreadLocals()
           
static void copyAttributes(org.w3c.dom.Element destElement, org.w3c.dom.Element srcElement)
          Copy attributes between elements
static org.w3c.dom.Element createElement(javax.xml.namespace.QName qname)
          Create an Element for a given QName
static org.w3c.dom.Element createElement(java.lang.String localPart)
          Create an Element for a given name
static org.w3c.dom.Element createElement(java.lang.String localPart, java.lang.String prefix)
          Create an Element for a given name and prefix
static org.w3c.dom.Element createElement(java.lang.String localPart, java.lang.String prefix, java.lang.String uri)
          Create an Element for a given name, prefix and uri
static org.w3c.dom.Text createTextNode(java.lang.String value)
          Create a org.w3c.dom.Text node
static java.util.Map getAttributes(org.w3c.dom.Element el)
          Get the attributes as Map
static java.lang.String getAttributeValue(org.w3c.dom.Element el, javax.xml.namespace.QName attrName)
          Get the value from the given attribute
static java.lang.String getAttributeValue(org.w3c.dom.Element el, java.lang.String attrName)
          Get the value from the given attribute
static boolean getAttributeValueAsBoolean(org.w3c.dom.Element el, javax.xml.namespace.QName attrName)
          Get the boolean value from the given attribute
static boolean getAttributeValueAsBoolean(org.w3c.dom.Element el, java.lang.String attrName)
          Get the boolean value from the given attribute
static java.lang.Integer getAttributeValueAsInteger(org.w3c.dom.Element el, javax.xml.namespace.QName attrName)
          Get the integer value from the given attribute
static java.lang.Integer getAttributeValueAsInteger(org.w3c.dom.Element el, java.lang.String attrName)
          Get the integer value from the given attribute
static javax.xml.namespace.QName getAttributeValueAsQName(org.w3c.dom.Element el, javax.xml.namespace.QName attrName)
          Get the qname value from the given attribute
static javax.xml.namespace.QName getAttributeValueAsQName(org.w3c.dom.Element el, java.lang.String attrName)
          Get the qname value from the given attribute
static java.util.Iterator<org.w3c.dom.Element> getChildElements(org.w3c.dom.Node node)
          Gets child elements
static java.util.Iterator getChildElements(org.w3c.dom.Node node, javax.xml.namespace.QName nodeName)
          Gets the child element for a given qname
static java.util.Iterator getChildElements(org.w3c.dom.Node node, javax.xml.namespace.QName nodeName, boolean recursive)
          Gets the child element for a given qname
static java.util.Iterator getChildElements(org.w3c.dom.Node node, java.lang.String nodeName)
          Gets the child elements for a given local name without namespace
static java.util.Iterator getChildElements(org.w3c.dom.Node node, java.lang.String nodeName, boolean recursive)
          Gets the child elements for a given local name without namespace
static java.util.List<org.w3c.dom.Element> getChildElementsAsList(org.w3c.dom.Node node, javax.xml.namespace.QName nodeName)
           
static java.util.List<org.w3c.dom.Element> getChildElementsAsList(org.w3c.dom.Node node, javax.xml.namespace.QName nodeName, boolean recursive)
           
static java.util.List<org.w3c.dom.Element> getChildElementsAsList(org.w3c.dom.Node node, java.lang.String nodeName)
           
static java.util.List<org.w3c.dom.Element> getChildElementsAsList(org.w3c.dom.Node node, java.lang.String nodeName, boolean recursive)
           
static javax.xml.parsers.DocumentBuilder getDocumentBuilder()
          Initialize the DocumentBuilder
static javax.xml.namespace.QName getElementQName(org.w3c.dom.Element el)
          Get the qname of the given node.
static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Node node)
          Gets the first child element
static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Node node, boolean recursive)
          Gets the first child element
static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Node node, javax.xml.namespace.QName nodeName)
          Gets the first child element for a given qname
static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Node node, javax.xml.namespace.QName nodeName, boolean recursive)
          Gets the first child element for a given qname
static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Node node, java.lang.String nodeName)
          Gets the first child element for a given local name without namespace
static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Node node, java.lang.String nodeName, boolean recursive)
          Gets the first child element for a given local name without namespace
static org.w3c.dom.Document getOwnerDocument()
          Get the owner document that is associated with the current thread
static org.w3c.dom.Element getParentElement(org.w3c.dom.Node node)
          Gets parent element or null if there is none
static java.lang.String getTextContent(org.w3c.dom.Node node)
          Get the concatenated text content, or null.
static boolean hasChildElements(org.w3c.dom.Node node)
          True if the node has child elements
static boolean hasTextChildNodesOnly(org.w3c.dom.Node node)
          True if the node has text child elements only
static org.w3c.dom.Element parse(org.xml.sax.InputSource source)
          Parse the given input source and return the root Element
static org.w3c.dom.Element parse(java.io.InputStream xmlStream)
          Parse the given XML stream and return the root Element
static org.w3c.dom.Element parse(java.lang.String xmlString)
          Parse the given XML string and return the root Element
static org.w3c.dom.Document peekOwnerDocument()
          Peek at the owner document without creating a new one if not set.
static javax.xml.namespace.QName resolveQName(org.w3c.dom.Element el, java.lang.String qualifiedName)
          Transform the given qualified name into a QName
static void setOwnerDocument(org.w3c.dom.Document doc)
           
static org.w3c.dom.Element sourceToElement(javax.xml.transform.Source source)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

clearThreadLocals

public static void clearThreadLocals()

getDocumentBuilder

public static javax.xml.parsers.DocumentBuilder getDocumentBuilder()
Initialize the DocumentBuilder


parse

public static org.w3c.dom.Element parse(java.lang.String xmlString)
                                 throws java.io.IOException
Parse the given XML string and return the root Element

Throws:
java.io.IOException

parse

public static org.w3c.dom.Element parse(java.io.InputStream xmlStream)
                                 throws java.io.IOException
Parse the given XML stream and return the root Element

Throws:
java.io.IOException

parse

public static org.w3c.dom.Element parse(org.xml.sax.InputSource source)
                                 throws java.io.IOException
Parse the given input source and return the root Element

Throws:
java.io.IOException

createElement

public static org.w3c.dom.Element createElement(java.lang.String localPart)
Create an Element for a given name


createElement

public static org.w3c.dom.Element createElement(java.lang.String localPart,
                                                java.lang.String prefix)
Create an Element for a given name and prefix


createElement

public static org.w3c.dom.Element createElement(java.lang.String localPart,
                                                java.lang.String prefix,
                                                java.lang.String uri)
Create an Element for a given name, prefix and uri


createElement

public static org.w3c.dom.Element createElement(javax.xml.namespace.QName qname)
Create an Element for a given QName


createTextNode

public static org.w3c.dom.Text createTextNode(java.lang.String value)
Create a org.w3c.dom.Text node


getElementQName

public static javax.xml.namespace.QName getElementQName(org.w3c.dom.Element el)
Get the qname of the given node.


resolveQName

public static javax.xml.namespace.QName resolveQName(org.w3c.dom.Element el,
                                                     java.lang.String qualifiedName)
Transform the given qualified name into a QName


getAttributeValue

public static java.lang.String getAttributeValue(org.w3c.dom.Element el,
                                                 java.lang.String attrName)
Get the value from the given attribute

Returns:
null if the attribute value is empty or the attribute is not present

getAttributeValue

public static java.lang.String getAttributeValue(org.w3c.dom.Element el,
                                                 javax.xml.namespace.QName attrName)
Get the value from the given attribute

Returns:
null if the attribute value is empty or the attribute is not present

getAttributeValueAsQName

public static javax.xml.namespace.QName getAttributeValueAsQName(org.w3c.dom.Element el,
                                                                 java.lang.String attrName)
Get the qname value from the given attribute


getAttributeValueAsQName

public static javax.xml.namespace.QName getAttributeValueAsQName(org.w3c.dom.Element el,
                                                                 javax.xml.namespace.QName attrName)
Get the qname value from the given attribute


getAttributeValueAsBoolean

public static boolean getAttributeValueAsBoolean(org.w3c.dom.Element el,
                                                 java.lang.String attrName)
Get the boolean value from the given attribute


getAttributeValueAsBoolean

public static boolean getAttributeValueAsBoolean(org.w3c.dom.Element el,
                                                 javax.xml.namespace.QName attrName)
Get the boolean value from the given attribute


getAttributeValueAsInteger

public static java.lang.Integer getAttributeValueAsInteger(org.w3c.dom.Element el,
                                                           java.lang.String attrName)
Get the integer value from the given attribute


getAttributeValueAsInteger

public static java.lang.Integer getAttributeValueAsInteger(org.w3c.dom.Element el,
                                                           javax.xml.namespace.QName attrName)
Get the integer value from the given attribute


getAttributes

public static java.util.Map getAttributes(org.w3c.dom.Element el)
Get the attributes as Map


copyAttributes

public static void copyAttributes(org.w3c.dom.Element destElement,
                                  org.w3c.dom.Element srcElement)
Copy attributes between elements


hasTextChildNodesOnly

public static boolean hasTextChildNodesOnly(org.w3c.dom.Node node)
True if the node has text child elements only


hasChildElements

public static boolean hasChildElements(org.w3c.dom.Node node)
True if the node has child elements


getChildElements

public static java.util.Iterator<org.w3c.dom.Element> getChildElements(org.w3c.dom.Node node)
Gets child elements


getTextContent

public static java.lang.String getTextContent(org.w3c.dom.Node node)
Get the concatenated text content, or null.


getFirstChildElement

public static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Node node)
Gets the first child element


getFirstChildElement

public static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Node node,
                                                       boolean recursive)
Gets the first child element


getFirstChildElement

public static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Node node,
                                                       java.lang.String nodeName)
Gets the first child element for a given local name without namespace


getFirstChildElement

public static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Node node,
                                                       java.lang.String nodeName,
                                                       boolean recursive)
Gets the first child element for a given local name without namespace


getFirstChildElement

public static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Node node,
                                                       javax.xml.namespace.QName nodeName)
Gets the first child element for a given qname


getFirstChildElement

public static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Node node,
                                                       javax.xml.namespace.QName nodeName,
                                                       boolean recursive)
Gets the first child element for a given qname


getChildElements

public static java.util.Iterator getChildElements(org.w3c.dom.Node node,
                                                  java.lang.String nodeName)
Gets the child elements for a given local name without namespace


getChildElements

public static java.util.Iterator getChildElements(org.w3c.dom.Node node,
                                                  java.lang.String nodeName,
                                                  boolean recursive)
Gets the child elements for a given local name without namespace


getChildElements

public static java.util.Iterator getChildElements(org.w3c.dom.Node node,
                                                  javax.xml.namespace.QName nodeName)
Gets the child element for a given qname


getChildElements

public static java.util.Iterator getChildElements(org.w3c.dom.Node node,
                                                  javax.xml.namespace.QName nodeName,
                                                  boolean recursive)
Gets the child element for a given qname


getChildElementsAsList

public static java.util.List<org.w3c.dom.Element> getChildElementsAsList(org.w3c.dom.Node node,
                                                                         java.lang.String nodeName)

getChildElementsAsList

public static java.util.List<org.w3c.dom.Element> getChildElementsAsList(org.w3c.dom.Node node,
                                                                         java.lang.String nodeName,
                                                                         boolean recursive)

getChildElementsAsList

public static java.util.List<org.w3c.dom.Element> getChildElementsAsList(org.w3c.dom.Node node,
                                                                         javax.xml.namespace.QName nodeName)

getChildElementsAsList

public static java.util.List<org.w3c.dom.Element> getChildElementsAsList(org.w3c.dom.Node node,
                                                                         javax.xml.namespace.QName nodeName,
                                                                         boolean recursive)

getParentElement

public static org.w3c.dom.Element getParentElement(org.w3c.dom.Node node)
Gets parent element or null if there is none


peekOwnerDocument

public static org.w3c.dom.Document peekOwnerDocument()
Peek at the owner document without creating a new one if not set.


setOwnerDocument

public static void setOwnerDocument(org.w3c.dom.Document doc)

getOwnerDocument

public static org.w3c.dom.Document getOwnerDocument()
Get the owner document that is associated with the current thread


sourceToElement

public static org.w3c.dom.Element sourceToElement(javax.xml.transform.Source source)
                                           throws java.io.IOException
Throws:
java.io.IOException


Copyright © 2009 JBoss, a division of Red Hat. All Rights Reserved.