public final class DOMUtils
extends org.jboss.ws.api.util.DOMUtils
org.jboss.wsf.util.DOMUtils
adding parse and creation methods.
These leverage static thread-local instances of Document
and DocumentBuilder
.
The ThreadLocal attributes can be reset using the clearThreadLocals() method.Modifier and Type | Method and Description |
---|---|
static void |
clearThreadLocals() |
static Element |
createElement(QName qname)
Create an Element for a given QName.
|
static Element |
createElement(String localPart)
Create an Element for a given name.
|
static Element |
createElement(String localPart,
String prefix)
Create an Element for a given name and prefix.
|
static Element |
createElement(String localPart,
String prefix,
String uri)
Create an Element for a given name, prefix and uri.
|
static Text |
createTextNode(String value)
Create a org.w3c.dom.Text node.
|
static DocumentBuilder |
getDocumentBuilder()
Initialize the DocumentBuilder, set the current thread association and returns it
|
static Document |
getOwnerDocument()
Get the owner document that is associated with the current thread
|
static DocumentBuilder |
newDocumentBuilder(DocumentBuilderFactory factory)
Creates a new DocumentBuilder instance using the provided DocumentBuilderFactory
|
static String |
node2String(Node node)
Converts XML node in pretty mode using UTF-8 encoding to string.
|
static String |
node2String(Node node,
boolean prettyPrint)
Converts XML node in specified pretty mode using UTF-8 encoding to string.
|
static String |
node2String(Node node,
boolean prettyPrint,
String encoding)
Converts XML node in specified pretty mode and encoding to string.
|
static Element |
parse(InputSource source)
Parse the given input source and return the root Element.
|
static Element |
parse(InputStream xmlStream)
Parse the given XML stream and return the root Element
This uses the document builder associated with the current thread.
|
static Element |
parse(InputStream xmlStream,
DocumentBuilder builder)
Parse the given XML stream and return the root Element
|
static Element |
parse(String xmlString)
Parse the given XML string and return the root Element
This uses the document builder associated with the current thread.
|
static Document |
peekOwnerDocument()
Peek at the owner document without creating a new one if not set.
|
static void |
setOwnerDocument(Document doc) |
static Element |
sourceToElement(Source source)
Parse the contents of the provided source into an element.
|
copyAttributes, createElement, getAttributes, getAttributeValue, getAttributeValue, getAttributeValueAsBoolean, getAttributeValueAsBoolean, getAttributeValueAsInteger, getAttributeValueAsInteger, getAttributeValueAsQName, getAttributeValueAsQName, getChildElements, getChildElements, getChildElements, getChildElements, getChildElements, getChildElementsAsList, getChildElementsAsList, getChildElementsAsList, getChildElementsAsList, getElementQName, getFirstChildElement, getFirstChildElement, getFirstChildElement, getFirstChildElement, getFirstChildElement, getFirstChildElement, getParentElement, getTextContent, hasChildElements, hasTextChildNodesOnly, parse, parse, resolveQName, sourceToElement
public static void clearThreadLocals()
public static DocumentBuilder newDocumentBuilder(DocumentBuilderFactory factory)
factory
- public static DocumentBuilder getDocumentBuilder()
public static Element parse(String xmlString) throws IOException
IOException
public static Element parse(InputStream xmlStream, DocumentBuilder builder) throws IOException
IOException
public static Element parse(InputStream xmlStream) throws IOException
IOException
public static Element parse(InputSource source) throws IOException
IOException
public static Element createElement(String localPart)
public static Element createElement(String localPart, String prefix)
public static Element createElement(String localPart, String prefix, String uri)
public static Element createElement(QName qname)
public static Text createTextNode(String value)
public static Document peekOwnerDocument()
public static void setOwnerDocument(Document doc)
public static Document getOwnerDocument()
public static Element sourceToElement(Source source) throws IOException
source
- IOException
public static String node2String(Node node) throws UnsupportedEncodingException
node
- XML document or elementException
- if some error occursUnsupportedEncodingException
public static String node2String(Node node, boolean prettyPrint) throws UnsupportedEncodingException
node
- XML document or elementprettyPrint
- whether XML have to be pretty formatedException
- if some error occursUnsupportedEncodingException
public static String node2String(Node node, boolean prettyPrint, String encoding) throws UnsupportedEncodingException
node
- XML document or elementprettyPrint
- whether XML have to be pretty formatedencoding
- to useUnsupportedEncodingException
Copyright © 2019 JBoss, by Red Hat. All rights reserved.