TPTP 4.2.0 Testing Tools Project
Public API Specification

org.eclipse.hyades.test.common.util
Class XMLUtil

java.lang.Object
  extended byorg.eclipse.hyades.test.common.util.XMLUtil

public class XMLUtil
extends java.lang.Object


Constructor Summary
XMLUtil()
           
 
Method Summary
static java.lang.String adjustXMLValue(java.lang.String value)
          Deprecated. use useXMLSymbols(String) instead.
static org.w3c.dom.NodeList createNodeList(java.util.List nodes)
          Returns a NodeList with all nodes of a given list.
static java.lang.StringBuffer createXMLAttribute(java.lang.String attribute, java.lang.String value, boolean asChild)
          Returns the XML string for the specified attribute and value.
static org.w3c.dom.NodeList getChildrenByName(org.w3c.dom.Element element, java.lang.String name)
          Returns a NodeList with all the children identified by a name in a given element.
static int getIntValue(org.w3c.dom.Element element, java.lang.String tagName)
          Get the value of the attribute tagName in element as an integer
static java.lang.String getValue(org.w3c.dom.Element element, java.lang.String name)
          Returns a value identified by a name in a given element.
static org.w3c.dom.Document getXmlDom(java.lang.String filePath)
          Returns a document based on the content of the specified file.
static org.w3c.dom.Element loadDom(java.io.InputStream inputStream, java.lang.String name)
          Returns an Element with a given name that was loaded from the specified input stream.
static org.w3c.dom.Element loadDom(java.lang.String xml, java.lang.String name)
          Returns an Element with a given name that was loaded from the specified string.
static java.lang.String removeXMLSymbols(java.lang.String xml)
          Replaces XML symbols in the xml by they equivalent character.
static java.lang.String useXMLSymbols(java.lang.String string)
          Replaces some of the characters in the string by they XML symbol.
static java.lang.String xmlVariable(java.lang.String name, java.lang.String value)
          Deprecated. use createXMLAttribute(String, String, boolean) instead.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLUtil

public XMLUtil()
Method Detail

useXMLSymbols

public static java.lang.String useXMLSymbols(java.lang.String string)
Replaces some of the characters in the string by they XML symbol.

Parameters:
string -
Returns:
The changed String.

removeXMLSymbols

public static java.lang.String removeXMLSymbols(java.lang.String xml)
Replaces XML symbols in the xml by they equivalent character.

Parameters:
xml -
Returns:
The changed xml.

createXMLAttribute

public static java.lang.StringBuffer createXMLAttribute(java.lang.String attribute,
                                                        java.lang.String value,
                                                        boolean asChild)
Returns the XML string for the specified attribute and value. The value is passed to the useXMLSymbols(String) method.

If the value is null then the return is an empty StringBuffer.

If asChild is true than this method returns

value
. If it false the return is " attribute="value""

Parameters:
attribute -
value -
asChild -
Returns:
StringBuffer.

loadDom

public static org.w3c.dom.Element loadDom(java.io.InputStream inputStream,
                                          java.lang.String name)
Returns an Element with a given name that was loaded from the specified input stream.

Parameters:
inputStream -
name -
Returns:
Element

loadDom

public static org.w3c.dom.Element loadDom(java.lang.String xml,
                                          java.lang.String name)
Returns an Element with a given name that was loaded from the specified string.

Parameters:
xml -
name -
Returns:
Element

getValue

public static java.lang.String getValue(org.w3c.dom.Element element,
                                        java.lang.String name)
Returns a value identified by a name in a given element. This value can correspond to a regular XML attribute value or to a child node value. In the last case there should be only one element with the given name.

This method returns null if the value is a zero-length string.

Parameters:
element -
name -
Returns:
String

getChildrenByName

public static org.w3c.dom.NodeList getChildrenByName(org.w3c.dom.Element element,
                                                     java.lang.String name)
Returns a NodeList with all the children identified by a name in a given element.

Parameters:
element -
name -
Returns:
NodeList

createNodeList

public static org.w3c.dom.NodeList createNodeList(java.util.List nodes)
Returns a NodeList with all nodes of a given list. The returned node list will thrown a ClassCastException if there is a element in the list that is not a Node

Returns:
NodeList

getXmlDom

public static org.w3c.dom.Document getXmlDom(java.lang.String filePath)
Returns a document based on the content of the specified file.

Parameters:
filePath -
Returns:
Document

getIntValue

public static int getIntValue(org.w3c.dom.Element element,
                              java.lang.String tagName)
Get the value of the attribute tagName in element as an integer

Parameters:
element -
tagName -
Returns:
int

xmlVariable

public static java.lang.String xmlVariable(java.lang.String name,
                                           java.lang.String value)
Deprecated. use createXMLAttribute(String, String, boolean) instead.

Parameters:
name -
value -
Returns:
String

adjustXMLValue

public static java.lang.String adjustXMLValue(java.lang.String value)
Deprecated. use useXMLSymbols(String) instead.

Parameters:
value -
Returns:
String

TPTP 4.2.0 Testing Tools Project
Public API Specification