public class DomUtil
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
protected |
DomUtil() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
getContentValue(org.w3c.dom.Element elem)
This methods returns the content of the element as a string.
|
static org.w3c.dom.Element |
getElement(org.w3c.dom.Node node,
java.lang.String localName)
Returns the first child element (if any) of the passed in node whose local name is the one
passed in argument.
|
static org.w3c.dom.Element |
getFirstChildElement(org.w3c.dom.Node node)
Returns the first child element (if any) of the passed in node.
|
static org.w3c.dom.Element |
getNextElement(org.w3c.dom.Node node)
Returns the element (if any) that is following the node that is passed in.
|
static java.lang.String |
getNodeName(org.w3c.dom.Node node)
This methods returns the content of the element as a string.
|
static boolean |
isXmlWhiteSpace(byte b)
This method returns true if the passed in byte is an XML whitespace character, i.e. one of blank space,
tab, cariage return, or line feed.
|
static org.w3c.dom.Element |
parseSettings(java.lang.String settings)
Parse the settings string and extract the root Element.
|
static void |
serialize(org.w3c.dom.Document doc,
java.io.Writer writer)
Deprecated.
Explicitly specify the document encoding by using serialize(Document, Writer, String) instead.
|
static void |
serialize(org.w3c.dom.Document doc,
java.io.Writer writer,
java.lang.String encoding)
Serializes the
Document and outputs it in the Writer that is passed. |
static void |
serialize(org.w3c.dom.Element element,
java.io.Writer writer,
boolean prettyPrint)
Deprecated.
Explicitly specify the element encoding by using serialize(Element, Writer, String, boolean).
|
static void |
serialize(org.w3c.dom.Element element,
java.io.Writer writer,
java.lang.String encoding,
boolean prettyPrint)
|
private static void |
serialize(org.w3c.dom.Node node,
org.w3c.dom.Document document,
java.io.Writer writer,
java.lang.String charset,
boolean prettyPrint) |
static int |
skipSpacesBeforeProlog(byte[] buf)
This method is used to figure out whether there are whitespaces to be skipped before the XML prolog.
|
static java.lang.String |
toString(org.w3c.dom.Document doc)
Serializes the
Document into a String. |
static java.lang.String |
toString(org.w3c.dom.Document doc,
boolean prettyPrint)
Serializes the
Document into a String. |
static java.lang.String |
toString(org.w3c.dom.Document doc,
java.lang.String charsetName,
boolean prettyPrint)
Serializes the
Document into a String. |
static java.lang.String |
toString(org.w3c.dom.Element element)
Serializes the
Element into a String. |
static java.lang.String |
toString(org.w3c.dom.Element element,
boolean indent)
Serializes the
Element into a String. |
static java.lang.String |
toString(org.w3c.dom.Node node)
Serializes the
Node into a String. |
static java.lang.String |
toString(java.lang.Object node) |
static java.lang.String |
toStringUnwrap(org.w3c.dom.Element element)
Serializes the
Element into a String. |
static java.lang.String |
toStringUnwrap(org.w3c.dom.Element element,
boolean format)
Serializes the
Element into a String. |
static java.lang.String |
toStringUnwrap(org.w3c.dom.Node node)
Serializes the
Node into a String. |
static void |
turnOffValidation(javax.xml.parsers.DocumentBuilderFactory factory)
This method allows turning off downloading external DTDs as well as turning off DTD validation.
|
public static void turnOffValidation(javax.xml.parsers.DocumentBuilderFactory factory)
Most of our code should call this method on their DocumentBuilderFactory to avoid runtime failures due to network failures that might happen.
public static final org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Node node)
node
- - a Nodepublic static final org.w3c.dom.Element getNextElement(org.w3c.dom.Node node)
node
- - a Nodepublic static final org.w3c.dom.Element getElement(org.w3c.dom.Node node, java.lang.String localName)
node
- - a Nodepublic static final java.lang.String getNodeName(org.w3c.dom.Node node)
public static final java.lang.String getContentValue(org.w3c.dom.Element elem)
elem
- - an Element@Deprecated public static final void serialize(org.w3c.dom.Document doc, java.io.Writer writer) throws java.io.IOException
Document
and outputs it in the Writer
that is passed.
This method assumes UTF-8 for the encoding of the documentdoc
- the Documentwriter
- the Writerjava.io.IOException
public static final void serialize(org.w3c.dom.Document doc, java.io.Writer writer, java.lang.String encoding) throws java.io.IOException
Document
and outputs it in the Writer
that is passed.doc
- the Documentwriter
- the Writerencoding
- the encoding of the documentjava.io.IOException
private static void serialize(org.w3c.dom.Node node, org.w3c.dom.Document document, java.io.Writer writer, java.lang.String charset, boolean prettyPrint) throws java.io.IOException
java.io.IOException
public static final void serialize(org.w3c.dom.Element element, java.io.Writer writer, java.lang.String encoding, boolean prettyPrint) throws java.io.IOException
java.io.IOException
@Deprecated public static final void serialize(org.w3c.dom.Element element, java.io.Writer writer, boolean prettyPrint) throws java.io.IOException
java.io.IOException
public static final java.lang.String toString(org.w3c.dom.Document doc) throws java.io.IOException
Document
into a String.doc
- the Documentjava.io.IOException
public static final java.lang.String toString(org.w3c.dom.Document doc, boolean prettyPrint) throws java.io.IOException
Document
into a String. The stringified document matches is a faithful
representation of the one being passed-in: no namespace fixup is made.
This method assumes that the charset of the document is UTF-8.doc
- the documentprettyPrint
- format the output by adding whitespace to produce a pretty-printed, indented,
human-readable formjava.io.IOException
public static final java.lang.String toString(org.w3c.dom.Document doc, java.lang.String charsetName, boolean prettyPrint) throws java.io.IOException
Document
into a String. The stringified document matches is a faithful
representation of the one being passed-in: no namespace fixup is made.
This method assumes that the charset of the document is UTF-8.doc
- the documentcharsetName
- the character set of the documentprettyPrint
- format the output by adding whitespace to produce a pretty-printed, indented,
human-readable formjava.io.IOException
public static final java.lang.String toStringUnwrap(org.w3c.dom.Element element) throws java.io.IOException
Element
into a String. java.io.IOException
public static final java.lang.String toStringUnwrap(org.w3c.dom.Element element, boolean format) throws java.io.IOException
Element
into a String. java.io.IOException
public static final java.lang.String toString(org.w3c.dom.Element element) throws java.io.IOException
Element
into a String. java.io.IOException
public static final java.lang.String toString(org.w3c.dom.Element element, boolean indent) throws java.io.IOException
Element
into a String.java.io.IOException
public static final java.lang.String toStringUnwrap(org.w3c.dom.Node node) throws java.io.IOException
Node
into a String.
If the node is an element and the element does not have sub-elements, the string returned does not
contain the tag of the element, only its content (i.e. the text).
Otherwise, the string returned contains both tag of the element as well as its sub-elements.node
- the Nodejava.io.IOException
public static final java.lang.String toString(org.w3c.dom.Node node) throws java.io.IOException
Node
into a String.node
- the Nodejava.io.IOException
public static final java.lang.String toString(java.lang.Object node) throws java.io.IOException
java.io.IOException
public static org.w3c.dom.Element parseSettings(java.lang.String settings) throws java.lang.Exception
settings
- The settings String
java.lang.Exception
public static int skipSpacesBeforeProlog(byte[] buf)
public static boolean isXmlWhiteSpace(byte b)