org.tinyjee.maven.dim.utils
Interface XPathEvaluator

All Known Implementing Classes:
XPathEvaluatorImplementation

public interface XPathEvaluator

Defines a simple data access interface that may be used to evaluate XPath expressions against the loaded XML document.


Method Summary
 List<Node> asList(NodeList nodeList)
          Converts the given NodeList to a java list of Node instances.
 List<Node> findNodes(String xpathExpression)
          Finds all DOM nodes that match the given XPath expression.
 String findText(String xpathExpression)
          Searches the loaded document for the text content of the first node matched by the given XPath expression.
 XPathEvaluator newEvaluator(Node node)
          Creates a new dependent evaluator that resolves nodes relative to the given node.
 String serialize(Node node)
          Serializes the given DOM node to XML.
 

Method Detail

findText

String findText(String xpathExpression)
Searches the loaded document for the text content of the first node matched by the given XPath expression.

Parameters:
xpathExpression - The xpath expression used to select the text content. E.g. "/html/head/title"
Returns:
The first matched text content or 'null' if not found.

findNodes

List<Node> findNodes(String xpathExpression)
Finds all DOM nodes that match the given XPath expression.

Parameters:
xpathExpression - The xpath expression used to select nodes, E.g. //table
Returns:
A list of all matched DOM nodes. If no nodes were matched, an empty list is returned instead.

serialize

String serialize(Node node)
Serializes the given DOM node to XML.

Parameters:
node - the node to serialize.
Returns:
the XML string representing the serialized node.

asList

List<Node> asList(NodeList nodeList)
Converts the given NodeList to a java list of Node instances.

Parameters:
nodeList - the node list to convert.
Returns:
a node list that uses the standard java collection framework.

newEvaluator

XPathEvaluator newEvaluator(Node node)
Creates a new dependent evaluator that resolves nodes relative to the given node.

The evaluator returned by this method shares internals like namespace resolution and xpath engine and may not be used concurrently (in multiple threads) with its creator.

Parameters:
node - the node to resolve against.
Returns:
a new evaluator that resolves nodes relative to the given node.