com.filenet.wcm.toolkit.server.util.xml
Class XMLNodeUtil

java.lang.Object
  extended bycom.filenet.wcm.toolkit.server.util.xml.XMLNodeUtil

public class XMLNodeUtil
extends java.lang.Object

XML utility class that does NOT use xpath to retirve node data. Instead it uses a basic tag name look up scheme and uses the the standard chaild Node iterators provider with the Node object implementation.


Constructor Summary
XMLNodeUtil()
           
 
Method Summary
protected static void addChildren(java.util.ArrayList childList, org.w3c.dom.Node parent, java.lang.String nameToFind)
          Helper method to add any child nodes that match the passed in tag name to the child list.
static java.lang.String getCDATANodeText(org.w3c.dom.Node node)
          Helper method to get the text value of a specified CDATA node.
static java.util.ArrayList getChildList(org.w3c.dom.Node parent, java.lang.String nameToFind)
          Helper method to retrieve an array list of children under a parent node.
static org.w3c.dom.Node getChildNode(org.w3c.dom.Node parent, java.lang.String nameToFind)
          Helper method to find a child node under a parent.
static java.lang.String getChildNodeText(org.w3c.dom.Node parent, java.lang.String nameToFind)
          Helper method to find a child node under a parent and return it's text value.
static org.w3c.dom.Node getChildNodeWithAttrValue(java.util.ArrayList childList, java.lang.String nameToFind, java.lang.String valueToFind)
          Helper method to find a child node in a list of node that has an attribute with a particular value.
static org.w3c.dom.Node getChildNodeWithValue(java.util.ArrayList childList, java.lang.String nameToFind, java.lang.String valueToFind)
          Helper method to find a child node in a list of node that has a particular value.
static java.lang.String getNodeText(org.w3c.dom.Node node)
          Helper method to get the text value of a specified node.
static org.w3c.dom.Node getSelectNode(org.w3c.dom.Node parent, java.lang.String pathToNode)
          Helper method to find a child node under a parent.
static java.util.ArrayList getSelectNodeList(org.w3c.dom.Node parent, java.lang.String pathToNode)
          Helper method to retrieve an array list of children under a parent node.
static void setNodeText(org.w3c.dom.Node node, java.lang.String value)
          Helper method to set the text value of a specified node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLNodeUtil

public XMLNodeUtil()
Method Detail

getChildNode

public static org.w3c.dom.Node getChildNode(org.w3c.dom.Node parent,
                                            java.lang.String nameToFind)
                                     throws java.lang.Exception
Helper method to find a child node under a parent. Does not use xpath!

Parameters:
parent - Node holding the parent
nameToFind - String holding the XML element tag name to look for under the parent node.
Returns:
Node object of child that matches the passed in tag name.
Throws:
java.lang.Exception - If there are problems retrieving data or with an invalid parameter.

getSelectNode

public static org.w3c.dom.Node getSelectNode(org.w3c.dom.Node parent,
                                             java.lang.String pathToNode)
                                      throws java.lang.Exception
Helper method to find a child node under a parent. Does not use xpath!

Parameters:
parent - Node holding the parent
pathToNode - String holding simple XML tag path (ie: "propdesc/symname"). Does not use xpath, and therfore does not handle queries (ie: "propdesc[symname = 'myprop'].
Returns:
Node object of child that matches the passed in tag name.
Throws:
java.lang.Exception - If there are problems retrieving data or with an invalid parameter.

getChildList

public static java.util.ArrayList getChildList(org.w3c.dom.Node parent,
                                               java.lang.String nameToFind)
                                        throws java.lang.Exception
Helper method to retrieve an array list of children under a parent node. Does not use xpath.

Parameters:
parent - Node holding the parent
nameToFind - String holding the XML element tag name to look for under the parent node.
Returns:
ArrayList of child Node objects.
Throws:
java.lang.Exception - If there are problems retrieving data or with an invalid parameter.

addChildren

protected static void addChildren(java.util.ArrayList childList,
                                  org.w3c.dom.Node parent,
                                  java.lang.String nameToFind)
Helper method to add any child nodes that match the passed in tag name to the child list.

Parameters:
childList - ArrayList holding the current list of children
parent - Node to for children thath match the specified tag.
nameToFind - String holding XML element name to look for.

getSelectNodeList

public static java.util.ArrayList getSelectNodeList(org.w3c.dom.Node parent,
                                                    java.lang.String pathToNode)
                                             throws java.lang.Exception
Helper method to retrieve an array list of children under a parent node. Does not use xpath.

Parameters:
parent - Node holding the parent
pathToNode - String holding simple XML tag path (ie: "propdesc/symname"). Does not use xpath, and therfore does not handle queries (ie: "propdesc[symname = 'myprop'].
Returns:
ArrayList of child Node objects.
Throws:
java.lang.Exception - If there are problems retrieving data or with an invalid parameter.

getChildNodeWithValue

public static org.w3c.dom.Node getChildNodeWithValue(java.util.ArrayList childList,
                                                     java.lang.String nameToFind,
                                                     java.lang.String valueToFind)
                                              throws java.lang.Exception
Helper method to find a child node in a list of node that has a particular value. Does not use xpath!

Parameters:
childList - ArrayList holding the child node to look through
nameToFind - String holding the XML element tag name to look for under the parent node.
valueToFind - String holding the XML element value to look for under the child node mathcing the name.
Returns:
Node object of child that matches the passed in tag name.
Throws:
java.lang.Exception - If there are problems retrieving data or with an invalid parameter.

getChildNodeWithAttrValue

public static org.w3c.dom.Node getChildNodeWithAttrValue(java.util.ArrayList childList,
                                                         java.lang.String nameToFind,
                                                         java.lang.String valueToFind)
                                                  throws java.lang.Exception
Helper method to find a child node in a list of node that has an attribute with a particular value. Does not use xpath!

Parameters:
childList - ArrayList holding the child node to look through
nameToFind - String holding the XML attribute tag name to look for under the parent node.
valueToFind - String holding the XML attribute value to look for under the child node mathcing the name.
Returns:
Node object of child that matches the passed in tag name.
Throws:
java.lang.Exception - If there are problems retrieving data or with an invalid parameter.

getNodeText

public static java.lang.String getNodeText(org.w3c.dom.Node node)
Helper method to get the text value of a specified node.

Parameters:
node - Node object to find value
Returns:
String text value of specified node

getCDATANodeText

public static java.lang.String getCDATANodeText(org.w3c.dom.Node node)
Helper method to get the text value of a specified CDATA node.

Parameters:
node - Node object to find value
Returns:
String text value of specified node

getChildNodeText

public static java.lang.String getChildNodeText(org.w3c.dom.Node parent,
                                                java.lang.String nameToFind)
                                         throws java.lang.Exception
Helper method to find a child node under a parent and return it's text value. Does not use xpath!

Parameters:
parent - Node holding the parent
nameToFind - String holding the XML element tag name to look for under the parent node.
Returns:
String text value of child node to find.
Throws:
java.lang.Exception - If there are problems retrieving data or with an invalid parameter.

setNodeText

public static void setNodeText(org.w3c.dom.Node node,
                               java.lang.String value)
Helper method to set the text value of a specified node.

Parameters:
node - Node object to set value on
value - String text value to set


© Copyright IBM Corp. 2002, 2007. All Rights Reserved.