public Long unmarshall(Node in) throws Exception { return XpathUtils.asLong(".", in); }
/** * Evaluates the specified XPath expression and returns the result as a * Long. * <p> * This method can be expensive as a new xpath is instantiated per * invocation. Consider passing in the xpath explicitly via { * {@link #asDouble(String, Node, XPath)} instead. Note {@link XPath} is * not thread-safe and not reentrant. * * @param expression * The XPath expression to evaluate. * @param node * The node to run the expression on. * * @return The Long result. * * @throws XPathExpressionException * If there was a problem processing the specified XPath * expression. */ public static Long asLong(String expression, Node node) throws XPathExpressionException { return asLong(expression, node, xpath()); }
public Long unmarshall(Node in) throws Exception { return XpathUtils.asLong(".", in); }
/** * Evaluates the specified XPath expression and returns the result as a * Long. * <p> * This method can be expensive as a new xpath is instantiated per * invocation. Consider passing in the xpath explicitly via { * {@link #asDouble(String, Node, XPath)} instead. Note {@link XPath} is * not thread-safe and not reentrant. * * @param expression * The XPath expression to evaluate. * @param node * The node to run the expression on. * * @return The Long result. * * @throws XPathExpressionException * If there was a problem processing the specified XPath * expression. */ public static Long asLong(String expression, Node node) throws XPathExpressionException { return asLong(expression, node, xpath()); }
public Long unmarshall(Node in) throws Exception { return XpathUtils.asLong(".", in); }
/** * Evaluates the specified XPath expression and returns the result as a * Long. * <p> * This method can be expensive as a new xpath is instantiated per * invocation. Consider passing in the xpath explicitly via { * {@link #asDouble(String, Node, XPath)} instead. Note {@link XPath} is * not thread-safe and not reentrant. * * @param expression * The XPath expression to evaluate. * @param node * The node to run the expression on. * * @return The Long result. * * @throws XPathExpressionException * If there was a problem processing the specified XPath * expression. */ public static Long asLong(String expression, Node node) throws XPathExpressionException { return asLong(expression, node, xpath()); }
/** * Tests that we return null when a specified expression doesn't evaluate * anything (instead of passing that null/empty value to a parser and * getting an error in the parser). */ @Test public void testMissingNodes() throws Exception { Document document = XpathUtils.documentFrom(DOCUMENT); assertNull(XpathUtils.asDouble("non-existant-node/name", document)); assertNull(XpathUtils.asLong("non-existant-node/name", document)); assertNull(XpathUtils.asInteger("non-existant-node/name", document)); assertNull(XpathUtils.asDate("non-existant-node/name", document)); assertNull(XpathUtils.asFloat("non-existant-node/name", document)); assertNull(XpathUtils.asString("non-existant-node/name", document)); }