public class XpathUtils extends Object
Constructor and Description |
---|
XpathUtils() |
Modifier and Type | Method and Description |
---|---|
static Boolean |
asBoolean(String expression,
Node node)
Evaluates the specified XPath expression and returns the result as a
Boolean.
|
static Boolean |
asBoolean(String expression,
Node node,
XPath xpath)
Same as
asBoolean(String, Node) but allows an xpath to be passed
in explicitly for reuse. |
static Byte |
asByte(String expression,
Node node)
Evaluates the specified XPath expression and returns the result as a
Byte.
|
static Byte |
asByte(String expression,
Node node,
XPath xpath)
Same as
asByte(String, Node) but allows an xpath to be passed
in explicitly for reuse. |
static ByteBuffer |
asByteBuffer(String expression,
Node node)
Evaluates the specified xpath expression, base64 decodes the data and
returns the result as a ByteBuffer.
|
static ByteBuffer |
asByteBuffer(String expression,
Node node,
XPath xpath)
Same as
asByteBuffer(String, Node) but allows an xpath to be
passed in explicitly for reuse. |
static Date |
asDate(String expression,
Node node)
Evaluates the specified XPath expression and returns the result as a
Date.
|
static Date |
asDate(String expression,
Node node,
XPath xpath)
Same as
asDate(String, Node) but allows an xpath to be passed
in explicitly for reuse. |
static Double |
asDouble(String expression,
Node node)
Evaluates the specified XPath expression and returns the results as a
Double.
|
static Double |
asDouble(String expression,
Node node,
XPath xpath)
Same as
asDouble(String, Node) but allows an xpath to be passed
in explicitly for reuse. |
static Float |
asFloat(String expression,
Node node)
Evaluates the specified XPath expression and returns the result as a
Float.
|
static Float |
asFloat(String expression,
Node node,
XPath xpath)
Same as
asFloat(String, Node) but allows an xpath to be passed
in explicitly for reuse. |
static Integer |
asInteger(String expression,
Node node)
Evaluates the specified XPath expression and returns the result as an
Integer.
|
static Integer |
asInteger(String expression,
Node node,
XPath xpath)
Same as
asInteger(String, Node) but allows an xpath to be passed
in explicitly for reuse. |
static Long |
asLong(String expression,
Node node)
Evaluates the specified XPath expression and returns the result as a
Long.
|
static Long |
asLong(String expression,
Node node,
XPath xpath)
Same as
asLong(String, Node) but allows an xpath to be passed
in explicitly for reuse. |
static Node |
asNode(String nodeName,
Node node)
Evaluates the specified XPath expression and returns the result as a
Node.
|
static Node |
asNode(String nodeName,
Node node,
XPath xpath)
Same as
asNode(String, Node) but allows an xpath to be
passed in explicitly for reuse. |
static String |
asString(String expression,
Node node)
Evaluates the specified XPath expression and returns the result as a
string.
|
static String |
asString(String expression,
Node node,
XPath xpath)
Same as
asString(String, Node) but allows an xpath to be passed
in explicitly for reuse. |
static Document |
documentFrom(InputStream is)
This method closes the given input stream upon completion.
|
static Document |
documentFrom(String xml) |
static Document |
documentFrom(URL url) |
static boolean |
isEmpty(Node node)
Returns true if the specified node is null or has no children.
|
static int |
nodeLength(NodeList list)
Returns the length of the specified node list.
|
static XPath |
xpath()
Returns a new instance of XPath, which is not thread safe and not
reentrant.
|
public static XPath xpath()
public static Document documentFrom(InputStream is) throws SAXException, IOException, ParserConfigurationException
public static Document documentFrom(String xml) throws SAXException, IOException, ParserConfigurationException
public static Document documentFrom(URL url) throws SAXException, IOException, ParserConfigurationException
public static Double asDouble(String expression, Node node) throws XPathExpressionException
This method can be expensive as a new xpath is instantiated per
invocation. Consider passing in the xpath explicitly via {
asDouble(String, Node, XPath)
instead. Note XPath
is
not thread-safe and not reentrant.
expression
- The XPath expression to evaluate.node
- The node to run the expression on.XPathExpressionException
- If there was a problem processing the specified XPath
expression.public static Double asDouble(String expression, Node node, XPath xpath) throws XPathExpressionException
asDouble(String, Node)
but allows an xpath to be passed
in explicitly for reuse.XPathExpressionException
public static String asString(String expression, Node node) throws XPathExpressionException
This method can be expensive as a new xpath is instantiated per
invocation. Consider passing in the xpath explicitly via {
asDouble(String, Node, XPath)
instead. Note XPath
is
not thread-safe and not reentrant.
expression
- The XPath expression to evaluate.node
- The node to run the expression on.XPathExpressionException
- If there was a problem processing the specified XPath
expression.public static String asString(String expression, Node node, XPath xpath) throws XPathExpressionException
asString(String, Node)
but allows an xpath to be passed
in explicitly for reuse.XPathExpressionException
public static Integer asInteger(String expression, Node node) throws XPathExpressionException
This method can be expensive as a new xpath is instantiated per
invocation. Consider passing in the xpath explicitly via {
asDouble(String, Node, XPath)
instead. Note XPath
is
not thread-safe and not reentrant.
expression
- The XPath expression to evaluate.node
- The node to run the expression on.XPathExpressionException
- If there was a problem processing the specified XPath
expression.public static Integer asInteger(String expression, Node node, XPath xpath) throws XPathExpressionException
asInteger(String, Node)
but allows an xpath to be passed
in explicitly for reuse.XPathExpressionException
public static Boolean asBoolean(String expression, Node node) throws XPathExpressionException
This method can be expensive as a new xpath is instantiated per
invocation. Consider passing in the xpath explicitly via {
asDouble(String, Node, XPath)
instead. Note XPath
is
not thread-safe and not reentrant.
expression
- The XPath expression to evaluate.node
- The node to run the expression on.XPathExpressionException
- If there was a problem processing the specified XPath
expression.public static Boolean asBoolean(String expression, Node node, XPath xpath) throws XPathExpressionException
asBoolean(String, Node)
but allows an xpath to be passed
in explicitly for reuse.XPathExpressionException
public static Float asFloat(String expression, Node node) throws XPathExpressionException
This method can be expensive as a new xpath is instantiated per
invocation. Consider passing in the xpath explicitly via {
asDouble(String, Node, XPath)
instead. Note XPath
is
not thread-safe and not reentrant.
expression
- The XPath expression to evaluate.node
- The node to run the expression on.XPathExpressionException
- If there was a problem processing the specified XPath
expression.public static Float asFloat(String expression, Node node, XPath xpath) throws XPathExpressionException
asFloat(String, Node)
but allows an xpath to be passed
in explicitly for reuse.XPathExpressionException
public static Long asLong(String expression, Node node) throws XPathExpressionException
This method can be expensive as a new xpath is instantiated per
invocation. Consider passing in the xpath explicitly via {
asDouble(String, Node, XPath)
instead. Note XPath
is
not thread-safe and not reentrant.
expression
- The XPath expression to evaluate.node
- The node to run the expression on.XPathExpressionException
- If there was a problem processing the specified XPath
expression.public static Long asLong(String expression, Node node, XPath xpath) throws XPathExpressionException
asLong(String, Node)
but allows an xpath to be passed
in explicitly for reuse.XPathExpressionException
public static Byte asByte(String expression, Node node) throws XPathExpressionException
This method can be expensive as a new xpath is instantiated per
invocation. Consider passing in the xpath explicitly via {
asDouble(String, Node, XPath)
instead. Note XPath
is
not thread-safe and not reentrant.
expression
- The XPath expression to evaluate.node
- The node to run the expression on.XPathExpressionException
- If there was a problem processing the specified XPath
expression.public static Byte asByte(String expression, Node node, XPath xpath) throws XPathExpressionException
asByte(String, Node)
but allows an xpath to be passed
in explicitly for reuse.XPathExpressionException
public static Date asDate(String expression, Node node) throws XPathExpressionException
This method can be expensive as a new xpath is instantiated per
invocation. Consider passing in the xpath explicitly via {
asDouble(String, Node, XPath)
instead. Note XPath
is
not thread-safe and not reentrant.
expression
- The XPath expression to evaluate.node
- The node to run the expression on.XPathExpressionException
- If there was a problem processing the specified XPath
expression.public static Date asDate(String expression, Node node, XPath xpath) throws XPathExpressionException
asDate(String, Node)
but allows an xpath to be passed
in explicitly for reuse.XPathExpressionException
public static ByteBuffer asByteBuffer(String expression, Node node) throws XPathExpressionException
This method can be expensive as a new xpath is instantiated per
invocation. Consider passing in the xpath explicitly via {
asDouble(String, Node, XPath)
instead. Note XPath
is
not thread-safe and not reentrant.
expression
- The Xpath expression to evaluate.node
- The node on which to evaluate the expression.XPathExpressionException
- If there are any problems evaluating the Xpath expression.public static ByteBuffer asByteBuffer(String expression, Node node, XPath xpath) throws XPathExpressionException
asByteBuffer(String, Node)
but allows an xpath to be
passed in explicitly for reuse.XPathExpressionException
public static boolean isEmpty(Node node)
node
- The node to test.public static Node asNode(String nodeName, Node node) throws XPathExpressionException
nodeName
- The XPath expression to evaluate.node
- The node to run the expression on.XPathExpressionException
- If there was a problem processing the specified XPath
expression.public static Node asNode(String nodeName, Node node, XPath xpath) throws XPathExpressionException
asNode(String, Node)
but allows an xpath to be
passed in explicitly for reuse.XPathExpressionException
public static int nodeLength(NodeList list)
list
- The node list to measure.Copyright © 2013 Amazon Web Services, Inc. All Rights Reserved.