public class XpathUtils
extends java.lang.Object
Constructor and Description |
---|
XpathUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.Boolean |
asBoolean(java.lang.String expression,
org.w3c.dom.Node node)
Evaluates the specified XPath expression and returns the result as a
Boolean.
|
static java.lang.Byte |
asByte(java.lang.String expression,
org.w3c.dom.Node node)
Evaluates the specified XPath expression and returns the result as a
Byte.
|
static java.nio.ByteBuffer |
asByteBuffer(java.lang.String expression,
org.w3c.dom.Node node)
Evaluates the specified xpath expression, base64 decodes the data and
returns the result as a ByteBuffer.
|
static java.util.Date |
asDate(java.lang.String expression,
org.w3c.dom.Node node)
Evaluates the specified XPath expression and returns the result as a
Date.
|
static java.lang.Double |
asDouble(java.lang.String expression,
org.w3c.dom.Node node)
Evaluates the specified XPath expression and returns the results as a
Double.
|
static java.lang.Float |
asFloat(java.lang.String expression,
org.w3c.dom.Node node)
Evaluates the specified XPath expression and returns the result as a
Float.
|
static java.lang.Integer |
asInteger(java.lang.String expression,
org.w3c.dom.Node node)
Evaluates the specified XPath expression and returns the result as an
Integer.
|
static java.lang.Long |
asLong(java.lang.String expression,
org.w3c.dom.Node node)
Evaluates the specified XPath expression and returns the result as a
Long.
|
static org.w3c.dom.Node |
asNode(java.lang.String nodeName,
org.w3c.dom.Node node) |
static java.lang.String |
asString(java.lang.String expression,
org.w3c.dom.Node node)
Evaluates the specified XPath expression and returns the result as a
string.
|
static org.w3c.dom.Document |
documentFrom(java.io.InputStream is)
InputStream to Document.
|
static org.w3c.dom.Document |
documentFrom(java.lang.String xml)
Xml string to Document.
|
static org.w3c.dom.Document |
documentFrom(java.net.URL url)
URL to Document,
|
static boolean |
isEmpty(org.w3c.dom.Node node)
Returns true if the specified node is null or has no children.
|
static int |
nodeLength(org.w3c.dom.NodeList list)
Returns the length of the specified node list.
|
static javax.xml.xpath.XPath |
xpath() |
public static org.w3c.dom.Document documentFrom(java.io.InputStream is) throws org.xml.sax.SAXException, java.io.IOException, javax.xml.parsers.ParserConfigurationException
is
- the input stream.org.xml.sax.SAXException
java.io.IOException
javax.xml.parsers.ParserConfigurationException
public static org.w3c.dom.Document documentFrom(java.lang.String xml) throws org.xml.sax.SAXException, java.io.IOException, javax.xml.parsers.ParserConfigurationException
xml
- the xml string.org.xml.sax.SAXException
java.io.IOException
javax.xml.parsers.ParserConfigurationException
public static org.w3c.dom.Document documentFrom(java.net.URL url) throws org.xml.sax.SAXException, java.io.IOException, javax.xml.parsers.ParserConfigurationException
url
- the URL.org.xml.sax.SAXException
java.io.IOException
javax.xml.parsers.ParserConfigurationException
public static java.lang.Double asDouble(java.lang.String expression, org.w3c.dom.Node node) throws javax.xml.xpath.XPathExpressionException
expression
- The XPath expression to evaluate.node
- The node to run the expression on.javax.xml.xpath.XPathExpressionException
- If there was a problem processing the
specified XPath expression.public static java.lang.String asString(java.lang.String expression, org.w3c.dom.Node node) throws javax.xml.xpath.XPathExpressionException
expression
- The XPath expression to evaluate.node
- The node to run the expression on.javax.xml.xpath.XPathExpressionException
- If there was a problem processing the
specified XPath expression.public static java.lang.Integer asInteger(java.lang.String expression, org.w3c.dom.Node node) throws javax.xml.xpath.XPathExpressionException
expression
- The XPath expression to evaluate.node
- The node to run the expression on.javax.xml.xpath.XPathExpressionException
- If there was a problem processing the
specified XPath expression.public static java.lang.Boolean asBoolean(java.lang.String expression, org.w3c.dom.Node node) throws javax.xml.xpath.XPathExpressionException
expression
- The XPath expression to evaluate.node
- The node to run the expression on.javax.xml.xpath.XPathExpressionException
- If there was a problem processing the
specified XPath expression.public static java.lang.Float asFloat(java.lang.String expression, org.w3c.dom.Node node) throws javax.xml.xpath.XPathExpressionException
expression
- The XPath expression to evaluate.node
- The node to run the expression on.javax.xml.xpath.XPathExpressionException
- If there was a problem processing the
specified XPath expression.public static java.lang.Long asLong(java.lang.String expression, org.w3c.dom.Node node) throws javax.xml.xpath.XPathExpressionException
expression
- The XPath expression to evaluate.node
- The node to run the expression on.javax.xml.xpath.XPathExpressionException
- If there was a problem processing the
specified XPath expression.public static java.lang.Byte asByte(java.lang.String expression, org.w3c.dom.Node node) throws javax.xml.xpath.XPathExpressionException
expression
- The XPath expression to evaluate.node
- The node to run the expression on.javax.xml.xpath.XPathExpressionException
- If there was a problem processing the
specified XPath expression.public static java.util.Date asDate(java.lang.String expression, org.w3c.dom.Node node) throws javax.xml.xpath.XPathExpressionException
expression
- The XPath expression to evaluate.node
- The node to run the expression on.javax.xml.xpath.XPathExpressionException
- If there was a problem processing the
specified XPath expression.public static java.nio.ByteBuffer asByteBuffer(java.lang.String expression, org.w3c.dom.Node node) throws javax.xml.xpath.XPathExpressionException
expression
- The Xpath expression to evaluate.node
- The node on which to evaluate the expression.javax.xml.xpath.XPathExpressionException
- If there are any problems evaluating the
Xpath expression.public static boolean isEmpty(org.w3c.dom.Node node)
node
- The node to test.public static int nodeLength(org.w3c.dom.NodeList list)
list
- The node list to measure.public static org.w3c.dom.Node asNode(java.lang.String nodeName, org.w3c.dom.Node node) throws javax.xml.xpath.XPathExpressionException
nodeName
- the node name.node
- the node.javax.xml.xpath.XPathExpressionException
public static javax.xml.xpath.XPath xpath()