com.ibm.di.connector.maximo.util
Class Dom

java.lang.Object
  extended by com.ibm.di.connector.maximo.util.Dom

public final class Dom
extends Object

This class consists exclusively of static methods that operate on or return XML content and DOM elements.

Since:
7.1

Constructor Summary
Dom()
           
 
Method Summary
static Map<String,String> getAttributes(Node rootNode)
          Returns a map containing the child nodes found in the given XML node.
static Map<String,String> getAttributes(Node rootNode, Set<String> names)
          Searches the specified XML node for child nodes with the specified names.
static String getAttributeValue(Node node, String attributeName)
          Returns the value of the specified attribute.
static NodeList getElements(String elementName, Document document)
          Returns all elements specified by elementName.
static NodeList getElements(String elementName, String xml)
          Parses the XML content and returns all elements specified by elementName.
static String getTextValue(Node node)
          Returns the text value of the specified XML node.
static boolean isNull(Node node)
          Indicates if the specified XML node has null value.
static Document parse(String xml)
          Parses the XML content.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Dom

public Dom()
Method Detail

getAttributes

public static Map<String,String> getAttributes(Node rootNode)
Returns a map containing the child nodes found in the given XML node.

Parameters:
rootNode - XML node whose child nodes are to be returned
Returns:
map containing the child nodes found in the given XML node

getAttributes

public static Map<String,String> getAttributes(Node rootNode,
                                               Set<String> names)
Searches the specified XML node for child nodes with the specified names.

Parameters:
rootNode - XML node whose child nodes are to be returned
names - names of the attributes to be found
Returns:
a map containing the child nodes found and its respective values

getAttributeValue

public static String getAttributeValue(Node node,
                                       String attributeName)
Returns the value of the specified attribute.

Parameters:
node - node containing the specified attribute
attributeName - attribute's name
Returns:
value of the specified attribute, or null if the attribute does not exist

getElements

public static NodeList getElements(String elementName,
                                   Document document)
Returns all elements specified by elementName.

Parameters:
elementName - name of the element to be returned
document - DOM document
Returns:
a list of all elements found with the specified name s

getElements

public static NodeList getElements(String elementName,
                                   String xml)
                            throws MxConnXmlParsingException
Parses the XML content and returns all elements specified by elementName.

Parameters:
elementName - name of the element to be returned
xml - XML content to be parsed
Returns:
a list of all elements found with the specified name
Throws:
MxConnXmlParsingException - if it is not possible to parse the XML content

getTextValue

public static String getTextValue(Node node)
Returns the text value of the specified XML node.

Parameters:
node - XML node
Returns:
text value of the specified XML node

isNull

public static boolean isNull(Node node)
Indicates if the specified XML node has null value. NOTE: Not used.

Parameters:
node - XML node
Returns:
true if the specified XML node has null value, otherwise false

parse

public static Document parse(String xml)
                      throws MxConnXmlParsingException
Parses the XML content.

Parameters:
xml - XML content to be parsed
Returns:
a DOM document
Throws:
MxConnXmlParsingException - if it is not possible to parse the XML content