org.springframework.xml.xpath
Interface XPathExpression


public interface XPathExpression

Defines the contract for a precompiled XPath expression. Concrete instances can be obtained through the XPathExpressionFactory.

Implementations of this interface are precompiled, and thus faster, but less flexible, than the XPath expressions used by XPathOperations implementations.

Since:
1.0.0
Author:
Arjen Poutsma

Method Summary
 List evaluate(org.w3c.dom.Node node, NodeMapper nodeMapper)
          Evaluates the given expression, mapping each result Node objects to a Java object via a NodeMapper.
 boolean evaluateAsBoolean(org.w3c.dom.Node node)
          Evaluates the given expression as a boolean.
 org.w3c.dom.Node evaluateAsNode(org.w3c.dom.Node node)
          Evaluates the given expression as a Node.
 List evaluateAsNodeList(org.w3c.dom.Node node)
          Evaluates the given expression, and returns all Node objects that conform to it.
 double evaluateAsNumber(org.w3c.dom.Node node)
          Evaluates the given expression as a number (double).
 Object evaluateAsObject(org.w3c.dom.Node node, NodeMapper nodeMapper)
          Evaluates the given expression, mapping a single Node result to a Java object via a NodeMapper.
 String evaluateAsString(org.w3c.dom.Node node)
          Evaluates the given expression as a String.
 

Method Detail

evaluateAsBoolean

boolean evaluateAsBoolean(org.w3c.dom.Node node)
                          throws XPathException
Evaluates the given expression as a boolean. Returns the boolean evaluation of the expression, or false if it is invalid.

Parameters:
node - the starting point
Returns:
the result of the evaluation
Throws:
XPathException - in case of XPath errors
See Also:
XPath specification

evaluateAsNode

org.w3c.dom.Node evaluateAsNode(org.w3c.dom.Node node)
                                throws XPathException
Evaluates the given expression as a Node. Returns the evaluation of the expression, or null if it is invalid.

Parameters:
node - the starting point
Returns:
the result of the evaluation
Throws:
XPathException - in case of XPath errors
See Also:
XPath specification

evaluateAsNodeList

List evaluateAsNodeList(org.w3c.dom.Node node)
                        throws XPathException
Evaluates the given expression, and returns all Node objects that conform to it. Returns an empty list if no result could be found.

Parameters:
node - the starting point
Returns:
a list of Nodes that are selected by the expression
Throws:
XPathException - in case of XPath errors
See Also:
XPath specification

evaluateAsNumber

double evaluateAsNumber(org.w3c.dom.Node node)
                        throws XPathException
Evaluates the given expression as a number (double). Returns the numeric evaluation of the expression, or Double.NaN if it is invalid.

Parameters:
node - the starting point
Returns:
the result of the evaluation
Throws:
XPathException - in case of XPath errors
See Also:
XPath specification

evaluateAsString

String evaluateAsString(org.w3c.dom.Node node)
                        throws XPathException
Evaluates the given expression as a String. Returns null if no result could be found.

Parameters:
node - the starting point
Returns:
the result of the evaluation
Throws:
XPathException - in case of XPath errors
See Also:
XPath specification

evaluateAsObject

Object evaluateAsObject(org.w3c.dom.Node node,
                        NodeMapper nodeMapper)
                        throws XPathException
Evaluates the given expression, mapping a single Node result to a Java object via a NodeMapper.

Parameters:
node - the starting point
nodeMapper - object that will map one object per node
Returns:
the single mapped object
Throws:
XPathException - in case of XPath errors
See Also:
XPath specification

evaluate

List evaluate(org.w3c.dom.Node node,
              NodeMapper nodeMapper)
              throws XPathException
Evaluates the given expression, mapping each result Node objects to a Java object via a NodeMapper.

Parameters:
node - the starting point
nodeMapper - object that will map one object per node
Returns:
the result list, containing mapped objects
Throws:
XPathException - in case of XPath errors
See Also:
XPath specification


Copyright © 2010. All Rights Reserved.