public interface XPathOperations
The templates that implement this interface do not use precompiled XPath expressions. Consider using the XPathExpressionFactory
or the XPathExpressionFactoryBean
for optimal performance, but less flexibility.
Jaxp13XPathTemplate
,
JaxenXPathTemplate
Modifier and Type | Method and Description |
---|---|
void |
evaluate(String expression,
Source context,
NodeCallbackHandler callbackHandler)
Evaluates the given expression, handling the result
Node objects on a per-node basis with a NodeCallbackHandler . |
<T> List<T> |
evaluate(String expression,
Source context,
NodeMapper<T> nodeMapper)
Evaluates the given expression, mapping each result
Node objects to a Java object via a NodeMapper . |
boolean |
evaluateAsBoolean(String expression,
Source context)
Evaluates the given expression as a
boolean . |
double |
evaluateAsDouble(String expression,
Source context)
Evaluates the given expression as a
double . |
Node |
evaluateAsNode(String expression,
Source context)
Evaluates the given expression as a
Node . |
List<Node> |
evaluateAsNodeList(String expression,
Source context)
Evaluates the given expression as a list of
Node objects. |
<T> T |
evaluateAsObject(String expression,
Source context,
NodeMapper<T> nodeMapper)
Evaluates the given expression, mapping a single
Node result to a Java object via a NodeMapper . |
String |
evaluateAsString(String expression,
Source context)
Evaluates the given expression as a
String . |
boolean evaluateAsBoolean(String expression, Source context) throws XPathException
boolean
. Returns the boolean evaluation of the expression, or
false
if it is invalid.
The return value is determined per the boolean()
function defined in the XPath specification.
This means that an expression that selects zero nodes will return false
, while an expression that
selects one or more nodes will return true
.
An expression that returns a string returns false
for empty strings and true
for all other
strings.
An expression that returns a number returns false
for zero and true
for non-zero numbers.
expression
- the XPath expressioncontext
- the context starting pointXPathException
- in case of XPath errorsNode evaluateAsNode(String expression, Source context) throws XPathException
Node
. Returns the evaluation of the expression, or null
if it is invalid.expression
- the XPath expressioncontext
- the context starting pointXPathException
- in case of XPath errorsList<Node> evaluateAsNodeList(String expression, Source context) throws XPathException
Node
objects. Returns the evaluation of the expression, or an
empty list if no results are found.expression
- the XPath expressioncontext
- the context starting pointXPathException
- in case of XPath errorsdouble evaluateAsDouble(String expression, Source context) throws XPathException
double
. Returns the evaluation of the expression, or Double.NaN
if it is invalid.
The return value is determined per the number()
function as defined in the XPath specification.
This means that if the expression selects multiple nodes, it will return the number value of the first node.
expression
- the XPath expressioncontext
- the context starting pointXPathException
- in case of XPath errorsString evaluateAsString(String expression, Source context) throws XPathException
String
. Returns the evaluation of the expression, or
null
if it is invalid.
The return value is determined per the string()
function as defined in the XPath specification.
This means that if the expression selects multiple nodes, it will return the string value of the first node.
expression
- the XPath expressioncontext
- the context starting pointXPathException
- in case of XPath errors<T> T evaluateAsObject(String expression, Source context, NodeMapper<T> nodeMapper) throws XPathException
Node
result to a Java object via a NodeMapper
.expression
- the XPath expressioncontext
- the context starting pointnodeMapper
- object that will map one object per nodeXPathException
- in case of XPath errors<T> List<T> evaluate(String expression, Source context, NodeMapper<T> nodeMapper) throws XPathException
Node
objects to a Java object via a NodeMapper
.expression
- the XPath expressioncontext
- the context starting pointnodeMapper
- object that will map one object per nodeXPathException
- in case of XPath errorsvoid evaluate(String expression, Source context, NodeCallbackHandler callbackHandler) throws XPathException
Node
objects on a per-node basis with a NodeCallbackHandler
.expression
- the XPath expressioncontext
- the context starting pointcallbackHandler
- object that will extract results, one row at a timeXPathException
- in case of XPath errorsCopyright © 2018 Pivotal Software. All rights reserved.