public final class AstNodeXPathQuery<T> extends Object
| Modifier and Type | Method and Description |
|---|---|
static <E> AstNodeXPathQuery<E> |
create(String xpath)
Creates a compiled XPath query, which can be evaluated multiple times on different AstNode.
|
List<T> |
selectNodes(AstNode astNode)
Evaluate the XPath query on the given AstNode and returns all matching elements.
|
T |
selectSingleNode(AstNode astNode)
Evaluate the XPath query on the given AstNode and returns the first result, or null if there was no result.
|
public T selectSingleNode(AstNode astNode)
In the following case, AstNodeXpathQuery.create('/a/b').selectSingleNode(node) would return the AstNode of B2.
A1
|__ C1
| |__ B1
|__ B2
|__ B3
astNode - The AstNode on which to evaluate the query against to.public List<T> selectNodes(AstNode astNode)
In the following case, AstNodeXpathQuery.create('/a/b').selectNodes(node) would return the AstNode of B2 and B3, in that order.
A1
|__ C1
| |__ B1
|__ B2
|__ B3
astNode - The AstNode on which to evaluate the query against to.public static <E> AstNodeXPathQuery<E> create(String xpath)
xpath - The query to compileCopyright © 2010–2015 SonarSource. All rights reserved.