Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id D9C89200B4A for ; Wed, 20 Jul 2016 19:20:09 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id D82C6160A96; Wed, 20 Jul 2016 17:20:09 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 2CE49160A64 for ; Wed, 20 Jul 2016 19:20:09 +0200 (CEST) Received: (qmail 38049 invoked by uid 500); 20 Jul 2016 17:20:08 -0000 Mailing-List: contact commits-help@brooklyn.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.apache.org Delivered-To: mailing list commits@brooklyn.apache.org Received: (qmail 38023 invoked by uid 99); 20 Jul 2016 17:20:08 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Jul 2016 17:20:08 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3C2E3E08E8; Wed, 20 Jul 2016 17:20:08 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aledsage@apache.org To: commits@brooklyn.apache.org Date: Wed, 20 Jul 2016 17:20:09 -0000 Message-Id: <6537155e49914a059287b1f0bf098abb@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [02/11] brooklyn-server git commit: Extend XmlUtil#xpath signature archived-at: Wed, 20 Jul 2016 17:20:10 -0000 Extend XmlUtil#xpath signature Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/c7c8db5d Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/c7c8db5d Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/c7c8db5d Branch: refs/heads/master Commit: c7c8db5d3ca541651d8243aa198b32804844bca3 Parents: fa578d5 Author: Valentin Aitken Authored: Mon Jul 18 20:39:23 2016 +0300 Committer: Ivana Yovcheva Committed: Tue Jul 19 11:05:25 2016 +0300 ---------------------------------------------------------------------- .../org/apache/brooklyn/util/core/xstream/XmlUtil.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c7c8db5d/core/src/main/java/org/apache/brooklyn/util/core/xstream/XmlUtil.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/util/core/xstream/XmlUtil.java b/core/src/main/java/org/apache/brooklyn/util/core/xstream/XmlUtil.java index 9f914fa..82b4867 100644 --- a/core/src/main/java/org/apache/brooklyn/util/core/xstream/XmlUtil.java +++ b/core/src/main/java/org/apache/brooklyn/util/core/xstream/XmlUtil.java @@ -21,9 +21,11 @@ package org.apache.brooklyn.util.core.xstream; import java.io.ByteArrayInputStream; import java.io.IOException; +import javax.xml.namespace.QName; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; +import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpression; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; @@ -56,14 +58,18 @@ public class XmlUtil { } } - public static Object xpath(String xml, String xpath) { + public static String xpath(String xml, String xpath) { + return (String) xpath(xml, xpath, XPathConstants.STRING); + } + + public static Object xpath(String xml, String xpath, QName returnType) { try { DocumentBuilder builder = SharedDocumentBuilder.get(); Document doc = builder.parse(new ByteArrayInputStream(xml.getBytes())); XPathFactory xPathfactory = XPathFactory.newInstance(); XPathExpression expr = xPathfactory.newXPath().compile(xpath); - return expr.evaluate(doc); + return expr.evaluate(doc, returnType); } catch (ParserConfigurationException e) { throw Exceptions.propagate(e);