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 Byte |
asByte(String expression,
Node node)
Evaluates the specified XPath expression and returns the result as a
Byte.
|
static ByteBuffer |
asByteBuffer(String expression,
Node node)
Evaluates the specified xpath expression, base64 decodes the data and
returns the result as a ByteBuffer.
|
static Date |
asDate(String expression,
Node node)
Evaluates the specified XPath expression and returns the result as a
Date.
|
static Double |
asDouble(String expression,
Node node)
Evaluates the specified XPath expression and returns the results as a
Double.
|
static Float |
asFloat(String expression,
Node node)
Evaluates the specified XPath expression and returns the result as a
Float.
|
static Integer |
asInteger(String expression,
Node node)
Evaluates the specified XPath expression and returns the result as an
Integer.
|
static Long |
asLong(String expression,
Node node)
Evaluates the specified XPath expression and returns the result as a
Long.
|
static Node |
asNode(String nodeName,
Node node) |
static String |
asString(String expression,
Node node)
Evaluates the specified XPath expression and returns the result as a
string.
|
static Document |
documentFrom(InputStream is)
InputStream to Document.
|
static Document |
documentFrom(String xml)
Xml string to Document.
|
static Document |
documentFrom(URL url)
URL to Document,
|
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() |
public static Document documentFrom(InputStream is) throws SAXException, IOException, ParserConfigurationException
is
- the input stream.SAXException
IOException
ParserConfigurationException
public static Document documentFrom(String xml) throws SAXException, IOException, ParserConfigurationException
xml
- the xml string.SAXException
IOException
ParserConfigurationException
public static Document documentFrom(URL url) throws SAXException, IOException, ParserConfigurationException
url
- the URL.SAXException
IOException
ParserConfigurationException
public static Double asDouble(String expression, Node node) throws XPathExpressionException
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) throws XPathExpressionException
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) throws XPathExpressionException
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) throws XPathExpressionException
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) throws XPathExpressionException
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) throws XPathExpressionException
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) throws XPathExpressionException
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) throws XPathExpressionException
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 ByteBuffer asByteBuffer(String expression, Node node) throws XPathExpressionException
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 boolean isEmpty(Node node)
node
- The node to test.public static int nodeLength(NodeList list)
list
- The node list to measure.public static Node asNode(String nodeName, Node node) throws XPathExpressionException
nodeName
- the node name.node
- the node.XPathExpressionException
public static XPath xpath()
Copyright © 2017. All rights reserved.