activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/6] activemq-artemis git commit: Remove Java < 1.5 support from XMLUtil.getTextContent
Date Tue, 22 Dec 2015 02:47:29 GMT
Remove Java < 1.5 support from XMLUtil.getTextContent


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/a5eb04a2
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/a5eb04a2
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/a5eb04a2

Branch: refs/heads/master
Commit: a5eb04a2baddae2c047e36dc5575088c784e5b1e
Parents: 93a53e1
Author: Ville Skyttä <ville.skytta@iki.fi>
Authored: Mon Dec 21 23:31:49 2015 +0200
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Mon Dec 21 21:47:15 2015 -0500

----------------------------------------------------------------------
 .../core/client/ActiveMQClientLogger.java       |  1 +
 .../apache/activemq/artemis/utils/XMLUtil.java  | 58 +-------------------
 2 files changed, 2 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a5eb04a2/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java
index f881191..e67891d 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java
@@ -386,6 +386,7 @@ public interface ActiveMQClientLogger extends BasicLogger {
    @Message(id = 214017, value = "Caught unexpected Throwable", format = Message.Format.MESSAGE_FORMAT)
    void caughtunexpectedThrowable(@Cause Throwable t);
 
+   @Deprecated
    @LogMessage(level = Logger.Level.ERROR)
    @Message(id = 214018, value = "Failed to invoke getTextContent() on node {0}", format
= Message.Format.MESSAGE_FORMAT)
    void errorOnXMLTransform(@Cause Throwable t, Node n);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a5eb04a2/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XMLUtil.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XMLUtil.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XMLUtil.java
index 5634207..bd96a71 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XMLUtil.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XMLUtil.java
@@ -26,7 +26,6 @@ import javax.xml.validation.Validator;
 import java.io.InputStreamReader;
 import java.io.Reader;
 import java.io.StringReader;
-import java.lang.reflect.Method;
 import java.net.URL;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
@@ -145,16 +144,9 @@ public final class XMLUtil {
       return sb.toString();
    }
 
-   private static final Object[] EMPTY_ARRAY = new Object[0];
-
    /**
-    * This metod is here because Node.getTextContent() is not available in JDK 1.4 and I
would like
-    * to have an uniform access to this functionality.
-    * <p>
     * Note: if the content is another element or set of elements, it returns a string representation
     * of the hierarchy.
-    * <p>
-    * TODO implementation of this method is a hack. Implement it properly.
     */
    public static String getTextContent(final Node n) {
       if (n.hasChildNodes()) {
@@ -173,55 +165,7 @@ public final class XMLUtil {
          }
       }
 
-      Method[] methods = Node.class.getMethods();
-
-      for (Method getTextContext : methods) {
-         if ("getTextContent".equals(getTextContext.getName())) {
-            try {
-               return (String) getTextContext.invoke(n, XMLUtil.EMPTY_ARRAY);
-            }
-            catch (Exception e) {
-               ActiveMQClientLogger.LOGGER.errorOnXMLTransform(e, n);
-               return null;
-            }
-         }
-      }
-
-      String textContent = null;
-
-      if (n.hasChildNodes()) {
-         NodeList nl = n.getChildNodes();
-         for (int i = 0; i < nl.getLength(); i++) {
-            Node c = nl.item(i);
-            if (c.getNodeType() == Node.TEXT_NODE) {
-               textContent = n.getNodeValue();
-               if (textContent == null) {
-                  // TODO This is a hack. Get rid of it and implement this properly
-                  String s = c.toString();
-                  int idx = s.indexOf("#text:");
-                  if (idx != -1) {
-                     textContent = s.substring(idx + 6).trim();
-                     if (textContent.endsWith("]")) {
-                        textContent = textContent.substring(0, textContent.length() - 1);
-                     }
-                  }
-               }
-               if (textContent == null) {
-                  break;
-               }
-            }
-         }
-
-         // TODO This is a hack. Get rid of it and implement this properly
-         String s = n.toString();
-         int i = s.indexOf('>');
-         int i2 = s.indexOf("</");
-         if (i != -1 && i2 != -1) {
-            textContent = s.substring(i + 1, i2);
-         }
-      }
-
-      return textContent;
+      return n.getTextContent();
    }
 
    public static void assertEquivalent(final Node node, final Node node2) {


Mime
View raw message