Package com.avoka.fc.core.util
Class XPath
java.lang.Object
com.avoka.fc.core.util.XPath
Provides an XPath implementation that "flips" the standard way of doing Jaxen around - it allows you to
define the element once, and then evaluate multiple xpath expressions against that node.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetPathValue
(String path) Return the trimmed string value for the given path.selectNodes
(String xpath) Select multiple nodes using the given XPathselectSingleNode
(String xpath) Select a single node using the given XPathvoid
setNodeValue
(String path, Boolean value) Set a node to a specified boolean valuevoid
setNodeValue
(String path, Number value) Set a node to a specified numeric valuevoid
setNodeValue
(String path, String value) Set a node to a specified valuevoid
setNodeValue
(String path, String value, boolean optional) Set a node to a specified valuestringValueOf
(String xpath) Return the string value for the given path.
-
Constructor Details
-
XPath
Create an XPath object based on the given document- Parameters:
document
- a non-null XML document
-
XPath
Create an XPath object based on the given element- Parameters:
documentElement
- a non-null XML document element
-
-
Method Details
-
selectSingleNode
Select a single node using the given XPath- Parameters:
xpath
- the input XPath- Returns:
- the element selected by the XPath
- Throws:
ApplicationException
- if there was an error evaluating the XPath
-
selectNodes
Select multiple nodes using the given XPath- Parameters:
xpath
- the input XPath- Returns:
- the list of elements selected by the XPath
- Throws:
ApplicationException
- if there was an error evaluating the XPath
-
stringValueOf
Return the string value for the given path.- Parameters:
xpath
- the input XPath- Returns:
- the string value
-
getPathValue
Return the trimmed string value for the given path.- Parameters:
path
- the input XPath- Returns:
- the trimmed string value
-
setNodeValue
Set a node to a specified value- Parameters:
path
- the XPath of an existing nodevalue
- the new value
-
setNodeValue
Set a node to a specified boolean value- Parameters:
path
- the XPath of an existing nodevalue
- the new value
-
setNodeValue
Set a node to a specified numeric value- Parameters:
path
- the XPath of an existing nodevalue
- the new value
-
setNodeValue
Set a node to a specified value- Parameters:
path
- the XPath of an existing nodevalue
- the new valueoptional
- Determines the behaviour if the node does not exist. If true, this will be silently ignored and nothing will be done; otherwise anApplicationException
will be thrown.
-