Class JaxenXPathTemplate

All Implemented Interfaces:
XPathOperations

public class JaxenXPathTemplate extends AbstractXPathTemplate
Implementation of XPathOperations that uses Jaxen.

Namespaces can be set using the namespaces property.

Since:
1.0.0
Author:
Arjen Poutsma
See Also:
  • Constructor Details

    • JaxenXPathTemplate

      public JaxenXPathTemplate()
  • Method Details

    • evaluateAsBoolean

      public boolean evaluateAsBoolean(String expression, Source context) throws XPathException
      Description copied from interface: XPathOperations
      Evaluates the given expression as a 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.

      Parameters:
      expression - the XPath expression
      context - the context starting point
      Returns:
      the result of the evaluation
      Throws:
      XPathException - in case of XPath errors
      See Also:
    • evaluateAsNode

      public Node evaluateAsNode(String expression, Source context) throws XPathException
      Description copied from interface: XPathOperations
      Evaluates the given expression as a Node. Returns the evaluation of the expression, or null if it is invalid.
      Parameters:
      expression - the XPath expression
      context - the context starting point
      Returns:
      the result of the evaluation
      Throws:
      XPathException - in case of XPath errors
      See Also:
    • evaluateAsNodeList

      public List<Node> evaluateAsNodeList(String expression, Source context) throws XPathException
      Description copied from interface: XPathOperations
      Evaluates the given expression as a list of Node objects. Returns the evaluation of the expression, or an empty list if no results are found.
      Parameters:
      expression - the XPath expression
      context - the context starting point
      Returns:
      the result of the evaluation
      Throws:
      XPathException - in case of XPath errors
      See Also:
    • evaluateAsDouble

      public double evaluateAsDouble(String expression, Source context) throws XPathException
      Description copied from interface: XPathOperations
      Evaluates the given expression as a 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.

      Parameters:
      expression - the XPath expression
      context - the context starting point
      Returns:
      the result of the evaluation
      Throws:
      XPathException - in case of XPath errors
      See Also:
    • evaluateAsString

      public String evaluateAsString(String expression, Source context) throws XPathException
      Description copied from interface: XPathOperations
      Evaluates the given expression as a 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.

      Parameters:
      expression - the XPath expression
      context - the context starting point
      Returns:
      the result of the evaluation
      Throws:
      XPathException - in case of XPath errors
      See Also:
    • evaluateAsObject

      public <T> T evaluateAsObject(String expression, Source context, NodeMapper<T> nodeMapper) throws XPathException
      Description copied from interface: XPathOperations
      Evaluates the given expression, mapping a single Node result to a Java object via a NodeMapper.
      Parameters:
      expression - the XPath expression
      context - the context 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:
    • evaluate

      public <T> List<T> evaluate(String expression, Source context, NodeMapper<T> nodeMapper) throws XPathException
      Description copied from interface: XPathOperations
      Evaluates the given expression, mapping each result Node objects to a Java object via a NodeMapper.
      Parameters:
      expression - the XPath expression
      context - the context 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: