Package com.hannonhill.cascade.velocity
Class CascadeXPathTool
- java.lang.Object
-
- com.hannonhill.cascade.velocity.CascadeXPathTool
-
public class CascadeXPathTool extends java.lang.ObjectThis class is used to perform various XPath calls on JDOM nodes.- Since:
- 7.12.3
-
-
Constructor Summary
Constructors Constructor Description CascadeXPathTool()Constructs aCascadeXPathTooland initializes anXPathinstance with an XPath expression that selects all nodes.CascadeXPathTool(java.lang.String path)Constructs aCascadeXPathTooland initializes anXPathinstance with the provided XPath expression.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddNamespace(java.lang.String prefix, java.lang.String uri)Adds a namespace definition to the list of namespaces known of this XPath expression.java.lang.StringgetXPath()Returns the wrapped XPath expression as a string.static CascadeXPathToolnewInstance(java.lang.String path)Returns aCascadeXPathToolthat is initialized using the provided XPath expression.java.lang.NumbernumberValueOf(java.lang.Object context)Returns the number value of the first node selected by applying the wrapped XPath expression to the given context.java.util.ListselectNodes(java.lang.Object context)Wrapper forXPath.selectNodes(Object)that checks for a null context and throws a more meaningful error message.static java.util.ListselectNodes(java.lang.Object context, java.lang.String path)Wrapper forXPath.selectNodes(Object, String)that checks for a null context and throws a more meaningful error message.java.lang.ObjectselectSingleNode(java.lang.Object context)Wrapper forXPath.selectSingleNode(Object)that checks for a null context and throws a more meaningful error message.static java.lang.ObjectselectSingleNode(java.lang.Object context, java.lang.String path)Wrapper forXPath.selectSingleNode(Object, String)that checks for a null context and throws a more meaningful error message.voidsetVariable(java.lang.String name, java.lang.Object value)Defines an XPath variable and sets its value.java.lang.StringvalueOf(java.lang.Object context)Returns the string value of the first node selected by applying the wrapped XPath expression to the given context.
-
-
-
Constructor Detail
-
CascadeXPathTool
public CascadeXPathTool() throws java.lang.ExceptionConstructs aCascadeXPathTooland initializes anXPathinstance with an XPath expression that selects all nodes.- Throws:
java.lang.Exception
-
CascadeXPathTool
public CascadeXPathTool(java.lang.String path) throws java.lang.ExceptionConstructs aCascadeXPathTooland initializes anXPathinstance with the provided XPath expression.- Parameters:
path-- Throws:
java.lang.Exception
-
-
Method Detail
-
newInstance
public static CascadeXPathTool newInstance(java.lang.String path) throws java.lang.Exception
Returns aCascadeXPathToolthat is initialized using the provided XPath expression.- Parameters:
path-- Returns:
- Throws:
java.lang.Exception
-
addNamespace
public void addNamespace(java.lang.String prefix, java.lang.String uri)Adds a namespace definition to the list of namespaces known of this XPath expression.- Parameters:
prefix-uri-
-
getXPath
public java.lang.String getXPath()
Returns the wrapped XPath expression as a string.- Returns:
-
numberValueOf
public java.lang.Number numberValueOf(java.lang.Object context) throws java.lang.ExceptionReturns the number value of the first node selected by applying the wrapped XPath expression to the given context.- Parameters:
context-- Returns:
- Throws:
java.lang.Exception
-
selectNodes
public java.util.List selectNodes(java.lang.Object context) throws java.lang.ExceptionWrapper forXPath.selectNodes(Object)that checks for a null context and throws a more meaningful error message.- Parameters:
context-- Returns:
- Throws:
java.lang.Exception
-
selectNodes
public static java.util.List selectNodes(java.lang.Object context, java.lang.String path) throws java.lang.ExceptionWrapper forXPath.selectNodes(Object, String)that checks for a null context and throws a more meaningful error message.- Parameters:
context-path-- Returns:
- Throws:
java.lang.Exception
-
selectSingleNode
public java.lang.Object selectSingleNode(java.lang.Object context) throws java.lang.ExceptionWrapper forXPath.selectSingleNode(Object)that checks for a null context and throws a more meaningful error message.- Parameters:
context-- Returns:
- Throws:
java.lang.Exception
-
selectSingleNode
public static java.lang.Object selectSingleNode(java.lang.Object context, java.lang.String path) throws java.lang.ExceptionWrapper forXPath.selectSingleNode(Object, String)that checks for a null context and throws a more meaningful error message.- Parameters:
context-path-- Returns:
- Throws:
java.lang.Exception
-
setVariable
public void setVariable(java.lang.String name, java.lang.Object value)Defines an XPath variable and sets its value.- Parameters:
name-value-
-
valueOf
public java.lang.String valueOf(java.lang.Object context) throws java.lang.ExceptionReturns the string value of the first node selected by applying the wrapped XPath expression to the given context.- Parameters:
context-- Returns:
- Throws:
java.lang.Exception
-
-