|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object atg.junit.nucleus.XmlUtils
public class XmlUtils
A utility class to help with common XML manipulation functions.
Constructor Summary | |
---|---|
XmlUtils()
|
Method Summary | |
---|---|
static java.lang.String |
getAttribute(org.w3c.dom.Node pNode,
java.lang.String pName)
gets the value of the named attribute. |
static java.lang.String |
getAttribute(org.w3c.dom.Node pNode,
java.lang.String pName,
java.lang.String pDefault)
returns the value of the named attribute, or the specified default if the attribute value is null. |
static boolean |
getBooleanAttribute(org.w3c.dom.Node pNode,
java.lang.String pName,
boolean pDefault)
returns the value of the named attribute as a boolean. |
static java.lang.Boolean |
getBooleanAttribute(org.w3c.dom.Node pNode,
java.lang.String pName,
java.lang.Boolean pDefault)
returns the value of the named attribute as a Boolean object. |
static boolean |
getBooleanValue(java.lang.String pValue,
java.lang.String pDescriptor,
boolean pDefault)
converts the specified value into a boolean. |
static java.lang.Integer |
getIntegerAttribute(org.w3c.dom.Node pNode,
java.lang.String pName,
boolean pAllowNull)
returns the value of the named attribute as an Integer object. |
static java.lang.Integer |
getIntegerValue(java.lang.String pValue,
java.lang.String pDescriptor,
boolean pAllowNull)
converts the specified String into an Integer. |
static java.lang.Long |
getLongAttribute(org.w3c.dom.Node pNode,
java.lang.String pName,
boolean pAllowNull)
returns the value of the named attribute as a Long object. |
static java.lang.Long |
getLongValue(java.lang.String pValue,
java.lang.String pDescriptor,
boolean pAllowNull)
converts the specified String into a Long. |
static java.util.List<org.w3c.dom.Node> |
getNodes(org.w3c.dom.Document pDocument,
java.lang.String[] pChildren)
retrieves the Node(s) represented within the DOM hierarchy at the location designated by the 'nested' child nodes. |
static java.util.List<org.w3c.dom.Node> |
getNodes(java.io.File pXmlFile,
boolean pValidateDoc,
java.lang.String[] pChildren)
retrieves the Node(s) represented within the DOM hierarchy at the location designated by the 'nested' child nodes. |
static org.w3c.dom.NodeList |
getNodes(org.w3c.dom.Node pNode,
java.lang.String pChild)
returns the Element NodeList for the specified child of the parent Node. |
static java.util.List<org.w3c.dom.Node> |
getNodes(org.w3c.dom.Node pNode,
java.lang.String[] pChildren)
retrieves the Node(s) represented within the DOM hierarchy at the location designated by the 'nested' child nodes. |
static java.lang.String |
getNodeTextValue(org.w3c.dom.Node pElement)
Returns the String value of the content of the Node specified. |
static org.w3c.dom.Document |
initializeFile(java.io.File pXmlFile,
boolean pValidateDoc)
Initializes the XML file to be parsed and gets the Document tree for it. |
static void |
main(java.lang.String[] pArgs)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XmlUtils()
Method Detail |
---|
public static org.w3c.dom.Document initializeFile(java.io.File pXmlFile, boolean pValidateDoc) throws java.io.FileNotFoundException, java.lang.Exception
File
- the XML file to parseboolean
- true if the file should be validated against its DTD; otherwise false.
java.io.FileNotFoundException
- if the specified file can not be located.
java.lang.Exception
- if an error occurs parsing the file to a DOM.public static java.util.List<org.w3c.dom.Node> getNodes(java.io.File pXmlFile, boolean pValidateDoc, java.lang.String[] pChildren) throws java.io.FileNotFoundException, java.lang.Exception
File
- the XML document in which to lookboolean
- true if the file should be validated against its DTD; otherwise false.String[]
- the nested child nodes to retrieve. for example, if you specified
an array { "foo", "bar", "flippy" } this method would return all 'flippy' Nodes for the XML
document:
<foo< <bar< <flippy .../< <flippy .../< </bar< </foo<
java.io.FileNotFoundException
- if the specified file can not be located.
java.lang.Exception
- if an error occurs parsing the file to a DOM.public static java.util.List<org.w3c.dom.Node> getNodes(org.w3c.dom.Document pDocument, java.lang.String[] pChildren)
Document
- the XML document parsed to a DOMString[]
- the nested child nodes to retrieve. for example, if you specified
an array { "foo", "bar", "flippy" } this method would return all 'flippy' Nodes for the XML
document:
<foo< <bar< <flippy .../< <flippy .../< </bar< </foo<
public static java.util.List<org.w3c.dom.Node> getNodes(org.w3c.dom.Node pNode, java.lang.String[] pChildren)
Node
- the Node at which to start searchingString[]
- the nested child nodes to retrieve. for example, if you specified
an array { "foo", "bar", "flippy" } this method would return all 'flippy' Nodes for the XML
document:
<foo< <bar< <flippy .../< <flippy .../< </bar< </foo<
public static org.w3c.dom.NodeList getNodes(org.w3c.dom.Node pNode, java.lang.String pChild)
Node
- the parent nodeString
- the name of the child node(s)
public static java.lang.String getNodeTextValue(org.w3c.dom.Node pElement)
Node
- the node whose content to get.
public static java.lang.String getAttribute(org.w3c.dom.Node pNode, java.lang.String pName)
Node
- the node whose attribute should be retrieved.String
- the name of attribute whose value should be retrieved.
public static java.lang.String getAttribute(org.w3c.dom.Node pNode, java.lang.String pName, java.lang.String pDefault)
Node
- the node whose attribute should be retrieved.String
- the name of attribute whose value should be retrieved.String
- the default value to return if a value does not exist for the specified
attribute, or if the specified attribute is not defined in this Node.
public static java.lang.Integer getIntegerAttribute(org.w3c.dom.Node pNode, java.lang.String pName, boolean pAllowNull) throws FileFormatException
Node
- the node whose attribute should be retrieved.String
- the name of attribute whose value should be retrieved.String
- the default value to return if a value does not exist for the specified
attribute, or if the specified attribute is not defined in this Node.
FileFormatException
- if the value specified by the attribute can not be converted to an Integer,
or if pAllowNull is false and no value was specified for the attribute.public static java.lang.Integer getIntegerValue(java.lang.String pValue, java.lang.String pDescriptor, boolean pAllowNull) throws FileFormatException
String
- the value to convert.String
- a descriptor of what the value is for.boolean
- true if the input value can be null; otherwise false.
FileFormatException
- if the String can not be converted to an Integer or if it is
null and pAllowNull is false.public static java.lang.Long getLongAttribute(org.w3c.dom.Node pNode, java.lang.String pName, boolean pAllowNull) throws FileFormatException
Node
- the node whose attribute should be retrieved.String
- the name of attribute whose value should be retrieved.String
- the default value to return if a value does not exist for the specified
attribute, or if the specified attribute is not defined in this Node.
FileFormatException
- if the value specified by the attribute can not be converted to a Long,
or if pAllowNull is false and no value was specified for the attribute.public static java.lang.Long getLongValue(java.lang.String pValue, java.lang.String pDescriptor, boolean pAllowNull) throws FileFormatException
String
- the value to convert.String
- a descriptor of what the value is for.boolean
- true if the input value can be null; otherwise false.
FileFormatException
- if the String can not be converted to a Long or if it is
null and pAllowNull is false.public static boolean getBooleanAttribute(org.w3c.dom.Node pNode, java.lang.String pName, boolean pDefault) throws FileFormatException
Node
- the node whose attribute should be retrieved.String
- the name of attribute whose value should be retrieved.boolean
- the default value to return if a value does not exist for the specified
attribute, or if the specified attribute is not defined in this Node.
FileFormatException
- if the value specified by the attribute can not be converted to a boolean.public static boolean getBooleanValue(java.lang.String pValue, java.lang.String pDescriptor, boolean pDefault) throws FileFormatException
String
- the value which should be converted.String
- a descriptor of what the value is for.boolean
- the default value to return if the specified value is null or empty.
FileFormatException
- if the specified value can not be converted to a boolean.public static java.lang.Boolean getBooleanAttribute(org.w3c.dom.Node pNode, java.lang.String pName, java.lang.Boolean pDefault) throws FileFormatException
Node
- the node whose attribute should be retrieved.String
- the name of attribute whose value should be retrieved.Boolean
- the default value to return if a value does not exist for the specified
attribute, or if the specified attribute is not defined in this Node.
FileFormatException
- if the value specified by the attribute can not be converted to a boolean.public static void main(java.lang.String[] pArgs)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |