Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.fujitsu.iflow.common
Class DOMUtils

    java.lang.Object
      com.fujitsu.iflow.common.DOMUtils

public class DOMUtils
extends java.lang.Object

This class offers a number of helper functions for dealing with XML DOMS By centralizing all XML specific functions here, we can maximize reuse.

Method Summary
`static java.lang.String` | `convertDomToString(org.w3c.dom.Document doc)` This method is used to Serialize the DOM Document Object into a String.
`static org.w3c.dom.Document` | `convertStringToDocument(java.lang.String xmlString)` Deprecated. use version with three parameters instead
`static org.w3c.dom.Document` | `convertStringToDocument(java.lang.String xmlString, boolean validate, boolean isNamespaceAware)` This method is used to De-Serialize the DOM Document Object from a String.
`static org.w3c.dom.Element` | `convertStringToDom(java.lang.String xmlString)` This method is used to De-Serialize the DOM Document Object from a String.
`static org.w3c.dom.Element` | `convertStringToDom(java.lang.String xmlString, boolean validate, boolean isNamespaceAware)` This method is used to De-Serialize the DOM Document Object from a String.
`static org.w3c.dom.Element` | `createChildElement(org.w3c.dom.Document doc, org.w3c.dom.Element parent, java.lang.String name)` This method is used to create a Child element.
`static org.w3c.dom.Element` | `createChildElement(org.w3c.dom.Document doc, org.w3c.dom.Element parent, java.lang.String name, java.lang.String textValue)` This method is used to create a Child Text element.
`static org.w3c.dom.Element` | `createChildElement(org.w3c.dom.Document doc, org.w3c.dom.Element parent, java.lang.String name, java.lang.String textValue, java.lang.String[] attributeNames, java.lang.String[] attributeValues)` This method is used to create an element with Attributes.
`static org.w3c.dom.Document` | `createDocument()` This method creates a new Document Object without any root node.
`static org.w3c.dom.Document` | `createDocument(java.lang.String rootNodeName)` This method creates a new Document Object.
`static org.w3c.dom.Element` | `createElement(org.w3c.dom.Document doc, java.lang.String name, java.lang.String[] attributeNames, java.lang.String[] attributeValues)`
`static org.w3c.dom.NodeList` | `findNodes(org.w3c.dom.Node contextNode, java.lang.String expr)` Recursively searches a Node for children matching a particular Local Name
`static org.w3c.dom.NodeList` | `findNodes(org.w3c.dom.Node contextNode, java.lang.String expr, boolean recursively)` Searches a Node for children matching a particular Local Name
`static org.w3c.dom.Node` | `findNodeWithAttrValue(org.w3c.dom.Document doc, java.lang.String elementName, java.lang.String attrName, java.lang.String attrValue)`
`static java.util.Enumeration` | `getChildElements(org.w3c.dom.Element from)` Silly method.
`static java.util.List` | `getChildElementsList(org.w3c.dom.Node contextNode)` Get an ordered list of all ELEMENTs that are children of a context Node NOTE: This is DIFFERENT THAN getElementsByTagName("*") because this method does NOT traverse the full tree!!! It just gets direct children.
`static org.w3c.dom.Node` | `getFirstNodeByTagName(org.w3c.dom.Node contextNode, java.lang.String nodeName)` Returns the first child (direct descendant) with the specified name Returns null if no child is found with that name.
`static org.w3c.dom.Document` | `parseXMLInputStream(java.io.InputStream in)`
`static org.w3c.dom.Document` | `parseXMLReader(java.io.Reader str)`
`static java.lang.String` | `textValueOf(org.w3c.dom.Node node, boolean trim)` Returns the text of all the chidren of a node as a single string
`static java.lang.String` | `textValueOf(org.w3c.dom.Node contextNode, java.lang.String nodeName, boolean trim)`
`static java.lang.String[]` | `textValuesOfAll(org.w3c.dom.Node contextNode, java.lang.String nodeName, boolean trim)`
`static void` | `writeDom(org.w3c.dom.Document doc, java.io.OutputStream out)`
`static void` | `writeDom(org.w3c.dom.Document doc, java.io.Writer w)`
`static java.lang.String` | `xmlEscape(java.lang.String str)` Utility method to do XML escaping for the given xml string.
`static java.lang.String` | `xmlUnEscape(java.lang.String str)` Replacing escape sequences by corresponding characters

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### textValuesOfAll

    public static java.lang.String[] textValuesOfAll(org.w3c.dom.Node contextNode,
                                                     java.lang.String nodeName,
                                                     boolean trim)
                                              throws java.lang.Exception

  Parameters:
    `contextNode` -
    `nodeName` -
    `trim` -
  Throws:
    `java.lang.Exception`

### textValueOf

    public static java.lang.String textValueOf(org.w3c.dom.Node contextNode,
                                               java.lang.String nodeName,
                                               boolean trim)

  Parameters:
    `contextNode` -
    `trim` -

### textValueOf

    public static java.lang.String textValueOf(org.w3c.dom.Node node,
                                               boolean trim)

  Returns the text of all the chidren of a node as a single string

  Parameters:
    `node` - is the parent of the text

### getFirstNodeByTagName

    public static org.w3c.dom.Node getFirstNodeByTagName(org.w3c.dom.Node contextNode,
                                                         java.lang.String nodeName)

  Returns the first child (direct descendant) with the specified name Returns null if no child is found with that name. Should be called 'findChildByName'

  Parameters:
    `contextNode` -
    `nodeName` -

### findNodes

    public static org.w3c.dom.NodeList findNodes(org.w3c.dom.Node contextNode,
                                                 java.lang.String expr,
                                                 boolean recursively)
                                          throws java.lang.Exception

  Searches a Node for children matching a particular Local Name

  Parameters:
    `contextNode` - - the Node to start searching from
    `recursively` - - If true - this will recurse downward in the Node tree. If false, then this will only search DIRECT CHILD NODES of the contextNode.
  Throws:
    `java.lang.Exception`

### findNodes

    public static org.w3c.dom.NodeList findNodes(org.w3c.dom.Node contextNode,
                                                 java.lang.String expr)
                                          throws java.lang.Exception

  Recursively searches a Node for children matching a particular Local Name

  Parameters:
    `contextNode` -
  Throws:
    `java.lang.Exception`

### findNodeWithAttrValue

    public static org.w3c.dom.Node findNodeWithAttrValue(org.w3c.dom.Document doc,
                                                         java.lang.String elementName,
                                                         java.lang.String attrName,
                                                         java.lang.String attrValue)
                                                  throws java.lang.Exception

  Throws:
    `java.lang.Exception`

### getChildElementsList

    public static java.util.List getChildElementsList(org.w3c.dom.Node contextNode)

  Get an ordered list of all ELEMENTs that are children of a context Node NOTE: This is DIFFERENT THAN getElementsByTagName("*") because this method does NOT traverse the full tree!!! It just gets direct children.

  Parameters:
    `contextNode` - - a Node/Element from which we want to get all the child elements
  Returns:
    a List of org.w3c.dom.Element objects or an empty List if there are no child elements

### getChildElements

    public static java.util.Enumeration getChildElements(org.w3c.dom.Element from)

  Silly method. As part of porting this from the old XML parser to DOM, use this simple method to get child Elements. The old parser has a method for getting an Enumeration. That was used in hundreds of places. This simple method is an easy replacement for that.

  Parameters:
    `from` - - a Node/Element from which we want to get all the child elements
  Returns:
    an Enumeration of org.w3c.dom.Element objects or an empty Enumeration if there are no child elements

### createDocument

    public static org.w3c.dom.Document createDocument(java.lang.String rootNodeName)
                                               throws java.lang.Exception

  This method creates a new Document Object. Pass in the name of the root node name. The Document will be created and the root Element with this name will be attached to it. Retrieve the root element with the standard getDocumentElement.

  Returns:
    Created Document
  Throws:
    `java.lang.Exception`

### createDocument

    public static org.w3c.dom.Document createDocument()
                                               throws java.lang.Exception

  This method creates a new Document Object without any root node. Use this method if you need just the Document by itself. You may need this if you will be importing the root node or if you will have a namespace qualified root node.

  Returns:
    Created Document
  Throws:
    `java.lang.Exception`

### createChildElement

    public static org.w3c.dom.Element createChildElement(org.w3c.dom.Document doc,
                                                         org.w3c.dom.Element parent,
                                                         java.lang.String name,
                                                         java.lang.String textValue)

  This method is used to create a Child Text element.

  Parameters:
    `doc` - document on which the Text Element has to be created.
    `parent` - Parent Element.
    `name` - Tag name of the Text Element.
    `textValue` - tag value of the Text Element.
  Returns:
    Element.

### createChildElement

    public static org.w3c.dom.Element createChildElement(org.w3c.dom.Document doc,
                                                         org.w3c.dom.Element parent,
                                                         java.lang.String name)

  This method is used to create a Child element.

  Parameters:
    `doc` - document on which the Child Element has to be created.
    `parent` - Parent Element.
    `name` - Tag name of the Child Element.
  Returns:
    Element.

### createElement

    public static org.w3c.dom.Element createElement(org.w3c.dom.Document doc,
                                                    java.lang.String name,
                                                    java.lang.String[] attributeNames,
                                                    java.lang.String[] attributeValues)

### createChildElement

    public static org.w3c.dom.Element createChildElement(org.w3c.dom.Document doc,
                                                         org.w3c.dom.Element parent,
                                                         java.lang.String name,
                                                         java.lang.String textValue,
                                                         java.lang.String[] attributeNames,
                                                         java.lang.String[] attributeValues)

  This method is used to create an element with Attributes.

  Parameters:
    `doc` - document on which the Child Element has to be created.
    `parent` - Parent Element.
    `name` - Tag Name of the Element
    `attributeNames` - List of Attribute names.
    `attributeValues` - List of Attribute values.
  Returns:
    Element

### convertDomToString

    public static java.lang.String convertDomToString(org.w3c.dom.Document doc)
                                               throws java.lang.Exception

  This method is used to Serialize the DOM Document Object into a String. This is the preferred way to convert an XML dom tree to a String, but PLEASE try not to use this. Creating XML copies as strings in memory is a bad practice. Streaming them directly to a file, or to a socket, is better. But, if you need to have a String, use this one.

  Parameters:
    `doc` - Document Object.
  Returns:
    XML String.
  Throws:
    `java.lang.Exception`

### convertStringToDocument

    public static org.w3c.dom.Document convertStringToDocument(java.lang.String xmlString,
                                                               boolean validate,
                                                               boolean isNamespaceAware)
                                                        throws java.lang.Exception

  This method is used to De-Serialize the DOM Document Object from a String.

  Parameters:
    `xmlString` - The XML String.
    `validate` -
    `isNamespaceAware` -
  Returns:
    Document of the DOM.
  Throws:
    `java.lang.Exception`

### convertStringToDom

    public static org.w3c.dom.Element convertStringToDom(java.lang.String xmlString,
                                                         boolean validate,
                                                         boolean isNamespaceAware)
                                                  throws java.lang.Exception

  This method is used to De-Serialize the DOM Document Object from a String.

  Parameters:
    `xmlString` - The XML String.
    `validate` -
    `isNamespaceAware` -
  Returns:
    Root element of the DOM.
  Throws:
    `java.lang.Exception`

### convertStringToDom

    public static org.w3c.dom.Element convertStringToDom(java.lang.String xmlString)
                                                  throws java.lang.Exception

  This method is used to De-Serialize the DOM Document Object from a String.

  Parameters:
    `xmlString` - The XML String.
  Returns:
    Root element of the DOM.
  Throws:
    `java.lang.Exception`

### convertStringToDocument

    public static org.w3c.dom.Document convertStringToDocument(java.lang.String xmlString)
                                                        throws java.lang.Exception

  Deprecated. use version with three parameters instead

  This method is used to De-Serialize the DOM Document Object from a String.

  Parameters:
    `xmlString` - The XML String.
  Returns:
    Document element of the DOM.
  Throws:
    `java.lang.Exception`

### writeDom

    public static void writeDom(org.w3c.dom.Document doc,
                                java.io.Writer w)
                         throws java.lang.Exception

  Throws:
    `java.lang.Exception`

### writeDom

    public static void writeDom(org.w3c.dom.Document doc,
                                java.io.OutputStream out)
                         throws java.lang.Exception

  Throws:
    `java.lang.Exception`

### parseXMLInputStream

    public static org.w3c.dom.Document parseXMLInputStream(java.io.InputStream in)
                                                    throws java.lang.Exception

  Throws:
    `java.lang.Exception`

### parseXMLReader

    public static org.w3c.dom.Document parseXMLReader(java.io.Reader str)
                                               throws java.lang.Exception

  Throws:
    `java.lang.Exception`

### xmlEscape

    public static java.lang.String xmlEscape(java.lang.String str)

  Utility method to do XML escaping for the given xml string.

  Returns:
    escaped String.

### xmlUnEscape

    public static java.lang.String xmlUnEscape(java.lang.String str)

  Replacing escape sequences by corresponding characters

  Parameters:
    `str` - String the changes have to be done within
  Returns:
    String containing the changes

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD