public interface XPathExpression
XPathExpressionFactory
.
Implementations of this interface are precompiled, and thus faster, but less flexible, than the XPath expressions
used by XPathOperations
implementations.
Modifier and Type | Method and Description |
---|---|
<T> List<T> |
evaluate(Node node,
NodeMapper<T> nodeMapper)
Evaluates the given expression, mapping each result
Node objects to a Java object via a NodeMapper . |
boolean |
evaluateAsBoolean(Node node)
Evaluates the given expression as a
boolean . |
Node |
evaluateAsNode(Node node)
Evaluates the given expression as a
Node . |
List<Node> |
evaluateAsNodeList(Node node)
Evaluates the given expression, and returns all
Node objects that conform to it. |
double |
evaluateAsNumber(Node node)
Evaluates the given expression as a number (
double ). |
<T> T |
evaluateAsObject(Node node,
NodeMapper<T> nodeMapper)
Evaluates the given expression, mapping a single
Node result to a Java object via a NodeMapper . |
String |
evaluateAsString(Node node)
Evaluates the given expression as a String.
|
boolean evaluateAsBoolean(Node node) 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.
node
- the starting pointXPathException
- in case of XPath errorsNode evaluateAsNode(Node node) throws XPathException
Node
. Returns the evaluation of the expression, or null
if it is invalid.node
- the starting pointXPathException
- in case of XPath errorsList<Node> evaluateAsNodeList(Node node) throws XPathException
Node
objects that conform to it. Returns an empty list if
no result could be found.node
- the starting pointNode
s that are selected by the expressionXPathException
- in case of XPath errorsdouble evaluateAsNumber(Node node) throws XPathException
double
). Returns the numeric 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.
node
- the starting pointXPathException
- in case of XPath errorsString evaluateAsString(Node node) throws XPathException
null
if no result could be found.
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.
node
- the starting pointXPathException
- in case of XPath errors<T> T evaluateAsObject(Node node, NodeMapper<T> nodeMapper) throws XPathException
Node
result to a Java object via a NodeMapper
.node
- the starting pointnodeMapper
- object that will map one object per nodeXPathException
- in case of XPath errors<T> List<T> evaluate(Node node, NodeMapper<T> nodeMapper) throws XPathException
Node
objects to a Java object via a NodeMapper
.node
- the starting pointnodeMapper
- object that will map one object per nodeXPathException
- in case of XPath errorsCopyright © 2020 Pivotal Software. All rights reserved.