org.adfemg.audits.utils
Class XmlUtils

java.lang.Object
  extended by org.adfemg.audits.utils.XmlUtils

public class XmlUtils
extends java.lang.Object


Constructor Summary
XmlUtils()
           
 
Method Summary
static java.lang.String docElementName(org.w3c.dom.Document document)
          Returns the name of the document (root) element if it exists, or null if none can be found.
static boolean doesAttributExist(org.w3c.dom.NamedNodeMap nodeMap, java.lang.String attributeName)
          Checks if a nodeName exist in a NamedNodeMap.
static boolean doesNodeExist(org.w3c.dom.NodeList nodeList, java.lang.String nodeName)
          Checks if a nodeName exist in a NodeList.
static org.w3c.dom.Node findFirstAttributeInList(org.w3c.dom.NamedNodeMap nodeMap, java.lang.String attributeName)
          Looks for a attribute in a NamedNodeMap, returns the first one if any is found.
static org.w3c.dom.Node findFirstNodeInList(org.w3c.dom.NodeList nodeList, java.lang.String nodeName)
          Looks for a node in a NodeList, returns the first one if any is found.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlUtils

public XmlUtils()
Method Detail

doesNodeExist

public static boolean doesNodeExist(org.w3c.dom.NodeList nodeList,
                                    java.lang.String nodeName)
Checks if a nodeName exist in a NodeList.

Parameters:
nodeList - the NodeList to check.
nodeName - the name to look up.
Returns:
true if found, false if not.

findFirstNodeInList

public static org.w3c.dom.Node findFirstNodeInList(org.w3c.dom.NodeList nodeList,
                                                   java.lang.String nodeName)
Looks for a node in a NodeList, returns the first one if any is found. Returns null if none is found.

Parameters:
nodeList - the NodeList to check.
nodeName - the nodeName to look up.
Returns:
Node if found, null if not.

findFirstAttributeInList

public static org.w3c.dom.Node findFirstAttributeInList(org.w3c.dom.NamedNodeMap nodeMap,
                                                        java.lang.String attributeName)
Looks for a attribute in a NamedNodeMap, returns the first one if any is found. Returns null if none is found.

Parameters:
nodeMap -
attributeName -
Returns:
the first Node if any is found, null if none is found.

doesAttributExist

public static boolean doesAttributExist(org.w3c.dom.NamedNodeMap nodeMap,
                                        java.lang.String attributeName)
Checks if a nodeName exist in a NamedNodeMap.

Parameters:
nodeMap -
attributeName -
Returns:
true if nodeName exist, false if it does not.

docElementName

public static java.lang.String docElementName(org.w3c.dom.Document document)
Returns the name of the document (root) element if it exists, or null if none can be found. This can be used to prevent NullPointerExceptions when requesting document.getDocumentElement().getNodeName() directly.

Parameters:
document - XML document
Returns:
name of the document root element or null if input document is null or the document does not have a document element (eg empty doc)