Package org.jboss.ws.api.util
Class DOMUtils
java.lang.Object
org.jboss.ws.api.util.DOMUtils
Basic DOM2 utilities
- Author:
- Alessio Soldano, Thomas Diesler
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcopyAttributes(Element destElement, Element srcElement) Copy attributes between elementsstatic ElementcreateElement(String localPart, String prefix, String uri, Document doc) Create an Element for a given name, prefix and urigetAttributes(Element el) Get the attributes as Map<QName, String>static StringgetAttributeValue(Element el, String attrName) Get the value from the given attributestatic StringgetAttributeValue(Element el, QName attrName) Get the value from the given attributestatic booleangetAttributeValueAsBoolean(Element el, String attrName) Get the boolean value from the given attributestatic booleangetAttributeValueAsBoolean(Element el, QName attrName) Get the boolean value from the given attributestatic IntegergetAttributeValueAsInteger(Element el, String attrName) Get the integer value from the given attributestatic IntegergetAttributeValueAsInteger(Element el, QName attrName) Get the integer value from the given attributestatic QNamegetAttributeValueAsQName(Element el, String attrName) Get the qname value from the given attributestatic QNamegetAttributeValueAsQName(Element el, QName attrName) Get the qname value from the given attributegetChildElements(Node node) Gets child elementsgetChildElements(Node node, String nodeName) Gets the child elements for a given local name without namespacegetChildElements(Node node, String nodeName, boolean recursive) Gets the child elements for a given local name without namespacegetChildElements(Node node, QName nodeName) Gets the child element for a given qnamegetChildElements(Node node, QName nodeName, boolean recursive) Gets the child element for a given qnamegetChildElementsAsList(Node node, String nodeName) getChildElementsAsList(Node node, String nodeName, boolean recursive) getChildElementsAsList(Node node, QName nodeName) getChildElementsAsList(Node node, QName nodeName, boolean recursive) static QNameGet the qname of the given node.static ElementgetFirstChildElement(Node node) Gets the first child elementstatic ElementgetFirstChildElement(Node node, boolean recursive) Gets the first child elementstatic ElementgetFirstChildElement(Node node, String nodeName) Gets the first child element for a given local name without namespacestatic ElementgetFirstChildElement(Node node, String nodeName, boolean recursive) Gets the first child element for a given local name without namespacestatic ElementgetFirstChildElement(Node node, QName nodeName) Gets the first child element for a given qnamestatic ElementgetFirstChildElement(Node node, QName nodeName, boolean recursive) Gets the first child element for a given qnamestatic ElementgetParentElement(Node node) Gets parent element or null if there is nonestatic StringgetTextContent(Node node) Get the concatenated text content, or null.static booleanhasChildElements(Node node) True if the node has child elementsstatic booleanhasTextChildNodesOnly(Node node) True if the node has text child elements onlystatic Elementparse(InputStream xmlStream, DocumentBuilder builder) Parse the given XML stream and return the root Elementstatic Elementparse(String xmlString, DocumentBuilder builder) Parse the given XML string and return the root Elementstatic Elementparse(InputSource source, DocumentBuilder builder) Parse the given input source and return the root Elementstatic QNameresolveQName(Element el, String qualifiedName) Transform the given qualified name into a QNamestatic ElementsourceToElement(Source source, DocumentBuilder builder)
-
Constructor Details
-
DOMUtils
public DOMUtils()
-
-
Method Details
-
getElementQName
Get the qname of the given node.- Parameters:
el- node- Returns:
- Qname
-
resolveQName
Transform the given qualified name into a QName- Parameters:
el- nodequalifiedName- qualified name- Returns:
- QName
-
getAttributeValue
Get the value from the given attribute- Parameters:
el- elementattrName- attribute name- Returns:
- null if the attribute value is empty or the attribute is not present
-
getAttributeValue
Get the value from the given attribute- Parameters:
el- elementattrName- attribute name- Returns:
- null if the attribute value is empty or the attribute is not present
-
getAttributeValueAsQName
Get the qname value from the given attribute- Parameters:
el- elementattrName- attribute name- Returns:
- QName
-
getAttributeValueAsQName
Get the qname value from the given attribute- Parameters:
el- elementattrName- attribute name- Returns:
- QName
-
getAttributeValueAsBoolean
Get the boolean value from the given attribute- Parameters:
el- elementattrName- attribute name- Returns:
- boolean
-
getAttributeValueAsBoolean
Get the boolean value from the given attribute- Parameters:
el- elementattrName- attribute name- Returns:
- boolean
-
getAttributeValueAsInteger
Get the integer value from the given attribute- Parameters:
el- elementattrName- attribute name- Returns:
- Integer
-
getAttributeValueAsInteger
Get the integer value from the given attribute- Parameters:
el- elementattrName- attribute name- Returns:
- Integer
-
getAttributes
Get the attributes as Map<QName, String>- Parameters:
el- element- Returns:
- Map
-
copyAttributes
Copy attributes between elements- Parameters:
destElement- elementsrcElement- element
-
hasTextChildNodesOnly
True if the node has text child elements only- Parameters:
node- start node- Returns:
- True if the node has text child
-
hasChildElements
True if the node has child elements- Parameters:
node- start node- Returns:
- true when child has elements
-
getChildElements
Gets child elements- Parameters:
node- start node- Returns:
- Iterator
-
getTextContent
Get the concatenated text content, or null.- Parameters:
node- node- Returns:
- string
-
getFirstChildElement
Gets the first child element- Parameters:
node- start node- Returns:
- element
-
getFirstChildElement
Gets the first child element- Parameters:
node- childrecursive- recurse flag- Returns:
- element
-
getFirstChildElement
Gets the first child element for a given local name without namespace- Parameters:
node- childnodeName- name- Returns:
- element
-
getFirstChildElement
Gets the first child element for a given local name without namespace- Parameters:
node- childnodeName- namerecursive- recurse flag- Returns:
- element
-
getFirstChildElement
Gets the first child element for a given qname- Parameters:
node- childnodeName- name- Returns:
- element
-
getFirstChildElement
Gets the first child element for a given qname- Parameters:
node- childnodeName- namerecursive- recurse flag- Returns:
- element
-
getChildElements
Gets the child elements for a given local name without namespace- Parameters:
node- childnodeName- name- Returns:
- Iterator
-
getChildElements
Gets the child elements for a given local name without namespace- Parameters:
node- childnodeName- namerecursive- recurse flag- Returns:
- Iterator
-
getChildElements
Gets the child element for a given qname- Parameters:
node- childnodeName- name- Returns:
- Iterator
-
getChildElements
Gets the child element for a given qname- Parameters:
node- childnodeName- namerecursive- recurse flag- Returns:
- Iterator
-
getChildElementsAsList
-
getChildElementsAsList
-
getChildElementsAsList
-
getChildElementsAsList
-
getParentElement
Gets parent element or null if there is none- Parameters:
node- child- Returns:
- element
-
sourceToElement
- Throws:
IOException
-
parse
Parse the given XML string and return the root Element- Parameters:
xmlString- string to be parsedbuilder- document builder- Returns:
- element
- Throws:
IOException- exception
-
parse
Parse the given XML stream and return the root Element- Parameters:
xmlStream- input streambuilder- document builder- Returns:
- element
- Throws:
IOException- exception
-
parse
Parse the given input source and return the root Element- Parameters:
source- input sourcebuilder- document builder- Returns:
- element
- Throws:
IOException- exception
-
createElement
Create an Element for a given name, prefix and uri- Parameters:
localPart- xml local partprefix- xml prefixuri- uridoc- document- Returns:
- element
-