brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [02/11] brooklyn-server git commit: Extend XmlUtil#xpath signature
Date Wed, 20 Jul 2016 17:20:09 GMT
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 <bostko@gmail.com>
Authored: Mon Jul 18 20:39:23 2016 +0300
Committer: Ivana Yovcheva <ivana.yovcheva@gmail.com>
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);


Mime
View raw message