public class XPathBrowser extends Object
XPathExpressionCache. This is a lot faster than recompiling the expressions every time.
Note, you should use the XPathBrowserFactory for creating instances.
Note, this class does not support namespaces currently. TODO: check here for potential solution
http://blog.davber.com/2006/09/17/xpath-with-namespaces-in-java/| Modifier and Type | Method and Description |
|---|---|
XPathBrowser |
browse(Node node) |
XPathBrowser |
browseFirst(String expression) |
Iterator<XPathBrowser> |
browseMatching(Node n,
String expr) |
Iterable<XPathBrowser> |
browseMatching(String expr) |
Iterable<XPathBrowser> |
browseSubNodes() |
Object |
eval(String expr,
Node node,
QName resultType)
Efficient xpath expression evaluator that uses the
XPathExpressionCache. |
Optional<BigDecimal> |
getBigDecimal(Locale locale,
Node n,
String expr) |
Optional<BigDecimal> |
getBigDecimal(Locale locale,
String expr) |
Optional<BigInteger> |
getBigInteger(Node n,
String expr) |
Optional<BigInteger> |
getBigInteger(String expr) |
boolean |
getBoolean() |
boolean |
getBoolean(Node n,
String expr)
Evaluate expression to a boolean value.
|
boolean |
getBoolean(String expr)
Evaluate expression to a boolean value.
|
Optional<Double> |
getDouble() |
Optional<Double> |
getDouble(Node n,
String expr)
Evaluate expression to a double value.
|
Optional<Double> |
getDouble(String expr)
Evaluate expression to a double value.
|
Optional<Node> |
getFirstNode(Node n,
String expr) |
Optional<Node> |
getFirstNode(String expr) |
Optional<Integer> |
getInt() |
Optional<Integer> |
getInt(Node n,
String expr)
Evaluate expression to a int value.
|
Optional<Integer> |
getInt(String expr)
Evaluate expression to a int value.
|
Optional<Long> |
getLong() |
Optional<Long> |
getLong(Node n,
String expr)
Evaluate expression to a long value.
|
Optional<Long> |
getLong(String expr)
Evaluate expression to a long value.
|
Optional<String> |
getNodeAttribute(String key) |
NodeList |
getNodeList(Node n,
String expr)
Evaluate an expression that should result in a Node set (relative to the provided node).
|
NodeList |
getNodeList(String expr)
Evaluate an expression that should result in a Node set (relative to the root).
|
Optional<Number> |
getNumber(Locale locale,
Node n,
String expr) |
Optional<Number> |
getNumber(Locale locale,
String expr) |
Optional<String> |
getString() |
Optional<String> |
getString(Node n,
String expr)
Evaluate an expression that should result in a String (relative to the provided node).
|
Optional<String> |
getString(String expr)
Evaluate an expression that should result in a String (relative to the root).
|
String[] |
getStringValues(Node n,
String expr)
Get array of values that match specified expression.
|
String[] |
getStringValues(String expr)
Get array of values that match specified expression.
|
Node |
getSubNode(Node parent,
String name)
Get a named sub node from the parent.
|
Node |
node() |
Map<String,String> |
nodeAttributes() |
java.util.stream.Stream<XPathBrowser> |
streamMatching(String expr) |
java.util.stream.Stream<XPathBrowser> |
streamSubNodes() |
public Object eval(String expr, Node node, QName resultType)
XPathExpressionCache.
Use this if none of the other methods do what you need.expr - exprnode - noderesultType - typepublic boolean getBoolean(Node n, String expr)
n - node from which the (relative) expression is evaluated.expr - xpath expression.public boolean getBoolean(String expr)
expr - xpath expression.public boolean getBoolean()
public Optional<Double> getDouble(Node n, String expr)
n - node from which the (relative) expression is evaluated.expr - xpath expression.public Optional<Double> getDouble(String expr)
expr - xpath expression.public Optional<Integer> getInt(Node n, String expr)
n - node from which the (relative) expression is evaluated.expr - xpath expression.public Optional<Integer> getInt(String expr)
expr - xpath expression.public Optional<BigDecimal> getBigDecimal(Locale locale, String expr)
public Optional<BigDecimal> getBigDecimal(Locale locale, Node n, String expr)
public Optional<BigInteger> getBigInteger(String expr)
public Optional<BigInteger> getBigInteger(Node n, String expr)
public Optional<Long> getLong(Node n, String expr)
n - node from which the (relative) expression is evaluated.expr - xpath expression.public Optional<Long> getLong(String expr)
expr - xpath expression.public Optional<String> getString(Node n, String expr)
n - node from which the (relative) expression is evaluated.expr - xpath expression.public Optional<String> getString(String expr)
expr - xpath expression.public Optional<Node> getFirstNode(String expr)
expr - expressionIllegalArgumentException - if the node does not existpublic Optional<Node> getFirstNode(Node n, String expr)
n - nodeexpr - expressionIllegalArgumentException - if the node does not existpublic NodeList getNodeList(Node n, String expr)
n - node from which the (relative) expression is evaluated.expr - expr xpath expression.public NodeList getNodeList(String expr)
expr - xpath expression.public String[] getStringValues(Node n, String expr)
n - node from which the (relative) expression is evaluated.expr - xpath expression.public String[] getStringValues(String expr)
expr - xpath expression.public Node getSubNode(Node parent, String name)
parent - parent nodename - namepublic Node node()
public XPathBrowser browse(Node node)
public XPathBrowser browseFirst(String expression)
public java.util.stream.Stream<XPathBrowser> streamSubNodes()
public java.util.stream.Stream<XPathBrowser> streamMatching(String expr)
public Iterable<XPathBrowser> browseSubNodes()
public Iterable<XPathBrowser> browseMatching(String expr)
public Iterator<XPathBrowser> browseMatching(Node n, String expr)
Copyright © 2017 Inbot. All Rights Reserved.