/** * Evaluates the specified XPath expression and returns the result as a * Node. * * @param nodeName * The XPath expression to evaluate. * @param node * The node to run the expression on. * * @return The Node result. * * @throws XPathExpressionException * If there was a problem processing the specified XPath * expression. */ public static Node asNode(String nodeName, Node node) throws XPathExpressionException { return asNode(nodeName, node, xpath()); }
/** * Evaluates the specified XPath expression and returns the result as a * string. * <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 string result. * * @throws XPathExpressionException * If there was a problem processing the specified XPath * expression. */ public static String asString(String expression, Node node) throws XPathExpressionException { return evaluateAsString(expression, node, xpath()); }
/** * Evaluates the specified XPath expression and returns the result as an * Integer. * <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 Integer result. * * @throws XPathExpressionException * If there was a problem processing the specified XPath * expression. */ public static Integer asInteger(String expression, Node node) throws XPathExpressionException { return asInteger(expression, node, xpath()); }
/** * Evaluates the specified XPath expression and returns the result as a * Boolean. * <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 Boolean result. * * @throws XPathExpressionException * If there was a problem processing the specified XPath * expression. */ public static Boolean asBoolean(String expression, Node node) throws XPathExpressionException { return asBoolean(expression, node, xpath()); }
/** * Evaluates the specified XPath expression and returns the results as a * Double. * <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 Double result. * * @throws XPathExpressionException * If there was a problem processing the specified XPath * expression. */ public static Double asDouble(String expression, Node node) throws XPathExpressionException { return asDouble(expression, node, xpath()); }
/** * Evaluates the specified xpath expression, base64 decodes the data and * returns the result as a ByteBuffer. * <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 on which to evaluate the expression. * * @return A ByteBuffer of base64 decoded data from the result of evaluating * the specified Xpath expression. * * @throws XPathExpressionException * If there are any problems evaluating the Xpath expression. */ public static ByteBuffer asByteBuffer(String expression, Node node) throws XPathExpressionException { return asByteBuffer(expression, node, xpath()); }
/** * Evaluates the specified XPath expression and returns the result as a * Float. * <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 Float result. * * @throws XPathExpressionException * If there was a problem processing the specified XPath * expression. */ public static Float asFloat(String expression, Node node) throws XPathExpressionException { return asFloat(expression, node, xpath()); }
/** * 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()); }
/** * Evaluates the specified XPath expression and returns the result as a * Byte. * <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 Byte result. * * @throws XPathExpressionException * If there was a problem processing the specified XPath * expression. */ public static Byte asByte(String expression, Node node) throws XPathExpressionException { return asByte(expression, node, xpath()); }
/** * Evaluates the specified XPath expression and returns the result as a * Date. Assumes that the node's text is formatted as an ISO 8601 date, as * specified by xs:dateTime. * <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 Date result. * * @throws XPathExpressionException * If there was a problem processing the specified XPath * expression. */ public static Date asDate(String expression, Node node) throws XPathExpressionException { return asDate(expression, node, xpath()); }
@Override public AmazonServiceException unmarshall(Node in) throws Exception { XPath xpath = xpath(); String errorCode = parseErrorCode(in, xpath); String message = asString("Response/Errors/Error/Message", in, xpath); String requestId = asString("Response/RequestID", in, xpath); String errorType = asString("Response/Errors/Error/Type", in, xpath); Constructor<? extends AmazonServiceException> constructor = exceptionClass.getConstructor(String.class); AmazonServiceException ase = constructor.newInstance(message); ase.setErrorCode(errorCode); ase.setRequestId(requestId); if (errorType == null) { ase.setErrorType(ErrorType.Unknown); } else if (errorType.equalsIgnoreCase("server")) { ase.setErrorType(ErrorType.Service); } else if (errorType.equalsIgnoreCase("client")) { ase.setErrorType(ErrorType.Client); } return ase; }
/** * @see com.amazonaws.transform.Unmarshaller#unmarshall(java.lang.Object) */ public AmazonServiceException unmarshall(Node in) throws Exception { XPath xpath = xpath(); String errorCode = parseErrorCode(in, xpath); String errorType = asString("ErrorResponse/Error/Type", in, xpath); String requestId = asString("ErrorResponse/RequestId", in, xpath); String message = asString("ErrorResponse/Error/Message", in, xpath); AmazonServiceException ase = newException(message); ase.setErrorCode(errorCode); ase.setRequestId(requestId); if (errorType == null) { ase.setErrorType(ErrorType.Unknown); } else if (errorType.equalsIgnoreCase("Receiver")) { ase.setErrorType(ErrorType.Service); } else if (errorType.equalsIgnoreCase("Sender")) { ase.setErrorType(ErrorType.Client); } return ase; }
/** * @param nodeName the node name. * @param node the node. * @return the Node. * @throws XPathExpressionException */ public static Node asNode(String nodeName, Node node) throws XPathExpressionException { if (node == null) return null; return (Node) xpath().evaluate(nodeName, node, XPathConstants.NODE); }
/** * Evaluates the specified XPath expression and returns the result as a * Node. * * @param nodeName * The XPath expression to evaluate. * @param node * The node to run the expression on. * * @return The Node result. * * @throws XPathExpressionException * If there was a problem processing the specified XPath * expression. */ public static Node asNode(String nodeName, Node node) throws XPathExpressionException { return asNode(nodeName, node, xpath()); }
/** * Evaluates the specified XPath expression and returns the result as a * Boolean. * <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 Boolean result. * * @throws XPathExpressionException * If there was a problem processing the specified XPath * expression. */ public static Boolean asBoolean(String expression, Node node) throws XPathExpressionException { return asBoolean(expression, node, xpath()); }
/** * Evaluates the specified XPath expression and returns the results as a * Double. * <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 Double result. * * @throws XPathExpressionException * If there was a problem processing the specified XPath * expression. */ public static Double asDouble(String expression, Node node) throws XPathExpressionException { return asDouble(expression, node, xpath()); }
/** * 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()); }
/** * Evaluates the specified xpath expression, base64 decodes the data and * returns the result as a ByteBuffer. * <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 on which to evaluate the expression. * * @return A ByteBuffer of base64 decoded data from the result of evaluating * the specified Xpath expression. * * @throws XPathExpressionException * If there are any problems evaluating the Xpath expression. */ public static ByteBuffer asByteBuffer(String expression, Node node) throws XPathExpressionException { return asByteBuffer(expression, node, xpath()); }
@Override public AmazonServiceException unmarshall(Node in) throws Exception { XPath xpath = xpath(); String errorCode = parseErrorCode(in, xpath); String message = asString("Response/Errors/Error/Message", in, xpath); String requestId = asString("Response/RequestID", in, xpath); String errorType = asString("Response/Errors/Error/Type", in, xpath); Constructor<? extends AmazonServiceException> constructor = exceptionClass.getConstructor(String.class); AmazonServiceException ase = constructor.newInstance(message); ase.setErrorCode(errorCode); ase.setRequestId(requestId); if (errorType == null) { ase.setErrorType(ErrorType.Unknown); } else if (errorType.equalsIgnoreCase("server")) { ase.setErrorType(ErrorType.Service); } else if (errorType.equalsIgnoreCase("client")) { ase.setErrorType(ErrorType.Client); } return ase; }
/** * @see com.amazonaws.transform.Unmarshaller#unmarshall(java.lang.Object) */ public AmazonServiceException unmarshall(Node in) throws Exception { XPath xpath = xpath(); String errorCode = parseErrorCode(in, xpath); String errorType = asString("ErrorResponse/Error/Type", in, xpath); String requestId = asString("ErrorResponse/RequestId", in, xpath); String message = asString("ErrorResponse/Error/Message", in, xpath); AmazonServiceException ase = newException(message); ase.setErrorCode(errorCode); ase.setRequestId(requestId); if (errorType == null) { ase.setErrorType(ErrorType.Unknown); } else if (errorType.equalsIgnoreCase("Receiver")) { ase.setErrorType(ErrorType.Service); } else if (errorType.equalsIgnoreCase("Sender")) { ase.setErrorType(ErrorType.Client); } return ase; }