NextApp Echo3
v3.0.b4

nextapp.echo.app.util
Class DomUtil

java.lang.Object
  extended by nextapp.echo.app.util.DomUtil

public class DomUtil
extends java.lang.Object

A utility class which provides methods for working with a W3C DOM.


Field Summary
static java.util.Properties OUTPUT_PROPERTIES_INDENT
           
 
Method Summary
static org.w3c.dom.Document createDocument(java.lang.String qualifiedName, java.lang.String publicId, java.lang.String systemId, java.lang.String namespaceUri)
          Creates a new document.
static boolean getBooleanAttribute(org.w3c.dom.Element element, java.lang.String attributeName)
          Determines whether a specific boolean flag is set on an element.
static org.w3c.dom.Element getChildElementByTagName(org.w3c.dom.Element parentElement, java.lang.String name)
          Retrieves the first immediate child element of the specified element whose name matches the provided name parameter.
static int getChildElementCountByTagName(org.w3c.dom.Element parentElement, java.lang.String name)
          Counts the number of immediate child elements of the specified element whose names match the provided name parameter.
static org.w3c.dom.Element[] getChildElementsByTagName(org.w3c.dom.Element parentElement, java.lang.String name)
          Retrieves all immediate child elements of the specified element whose names match the provided name parameter.
static javax.xml.parsers.DocumentBuilder getDocumentBuilder()
          Retrieves a thread-specific DocumentBuilder.
static java.lang.String getElementText(org.w3c.dom.Element element)
          Returns the text content of a DOM Element.
static javax.xml.transform.TransformerFactory getTransformerFactory()
          Retrieves a thread-specific TransformerFactory.
static void save(org.w3c.dom.Document document, java.io.OutputStream out, java.util.Properties outputProperties)
          Writes the Document to the specified OutputStream.
static void save(org.w3c.dom.Document document, java.io.PrintWriter w, java.util.Properties outputProperties)
          Writes the Document to the specified PrintWriter.
static void setElementText(org.w3c.dom.Element element, java.lang.String value)
          Sets the text content of a DOM Element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OUTPUT_PROPERTIES_INDENT

public static final java.util.Properties OUTPUT_PROPERTIES_INDENT
Method Detail

createDocument

public static org.w3c.dom.Document createDocument(java.lang.String qualifiedName,
                                                  java.lang.String publicId,
                                                  java.lang.String systemId,
                                                  java.lang.String namespaceUri)
Creates a new document.

Parameters:
qualifiedName - the qualified name of the document type to be created
publicId - the external subset public identifier
systemId - the external subset system identifier
namespaceUri - the namespace URI of the document element to create

getDocumentBuilder

public static javax.xml.parsers.DocumentBuilder getDocumentBuilder()
Retrieves a thread-specific DocumentBuilder.

Returns:
the DocumentBuilder serving the current thread.

getTransformerFactory

public static javax.xml.transform.TransformerFactory getTransformerFactory()
Retrieves a thread-specific TransformerFactory.

Returns:
the TransformerFactory serving the current thread.

getBooleanAttribute

public static boolean getBooleanAttribute(org.w3c.dom.Element element,
                                          java.lang.String attributeName)
Determines whether a specific boolean flag is set on an element.

Parameters:
element - The element to analyze.
attributeName - The name of the boolean 'flag' attribute.
Returns:
True if the value of the attribute is 'true', false if it is not or if the attribute does not exist.

getChildElementByTagName

public static org.w3c.dom.Element getChildElementByTagName(org.w3c.dom.Element parentElement,
                                                           java.lang.String name)
Retrieves the first immediate child element of the specified element whose name matches the provided name parameter.

Parameters:
parentElement - The element to search.
name - The name of the child element.
Returns:
The child element, or null if none was found.

getChildElementsByTagName

public static org.w3c.dom.Element[] getChildElementsByTagName(org.w3c.dom.Element parentElement,
                                                              java.lang.String name)
Retrieves all immediate child elements of the specified element whose names match the provided name parameter.

Parameters:
parentElement - The element to search.
name - The name of the child element.
Returns:
An array of matching child elements.

getChildElementCountByTagName

public static int getChildElementCountByTagName(org.w3c.dom.Element parentElement,
                                                java.lang.String name)
Counts the number of immediate child elements of the specified element whose names match the provided name parameter.

Parameters:
parentElement - The element to analyze.
name - The name of the child element.
Returns:
The number of matching child elements.

getElementText

public static java.lang.String getElementText(org.w3c.dom.Element element)
Returns the text content of a DOM Element.

Parameters:
element - The Element to analyze.

save

public static void save(org.w3c.dom.Document document,
                        java.io.OutputStream out,
                        java.util.Properties outputProperties)
                 throws org.xml.sax.SAXException
Writes the Document to the specified OutputStream.

Parameters:
document - the Document
out - the OutputStream
outputProperties - output properties passed to XML transformer
Throws:
org.xml.sax.SAXException

save

public static void save(org.w3c.dom.Document document,
                        java.io.PrintWriter w,
                        java.util.Properties outputProperties)
                 throws org.xml.sax.SAXException
Writes the Document to the specified PrintWriter.

Parameters:
document - the Document
w - the PrintWriter
outputProperties - output properties passed to XML transformer
Throws:
org.xml.sax.SAXException

setElementText

public static void setElementText(org.w3c.dom.Element element,
                                  java.lang.String value)
Sets the text content of a DOM Element.

Parameters:
element - The Element to modify.
value - The new text value.

NextApp Echo3
v3.0.b4