ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1293952 - in /webservices/commons/trunk/modules/axiom/modules: axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/
Date Sun, 26 Feb 2012 23:00:52 GMT
Author: veithen
Date: Sun Feb 26 23:00:51 2012
New Revision: 1293952

URL: http://svn.apache.org/viewvc?rev=1293952&view=rev
Log:
(a+b).trim() != a.trim()+b.trim().

Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java?rev=1293952&r1=1293951&r2=1293952&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
Sun Feb 26 23:00:51 2012
@@ -1035,38 +1035,14 @@ public class ElementImpl extends ParentN
     }
 
     public QName getTextAsQName() {
-        String childText = getTrimmedText();
-        if (childText != null) {
-            return resolveQName(childText);
-        }
-        return null;
+        String childText = getText().trim();
+        return childText.length() == 0 ? null : resolveQName(childText);
     }
 
     public void writeTextTo(Writer out, boolean cache) throws IOException {
         OMElementImplUtil.writeTextTo(this, out, cache);
     }
 
-    public String getTrimmedText() {
-        String childText = null;
-        OMNode child = this.getFirstOMChild();
-        OMText textNode;
-
-        while (child != null) {
-            if (child.getType() == OMNode.TEXT_NODE) {
-                textNode = (OMText) child;
-                String textValue = textNode.getText();
-                if (textValue != null &&
-                        !"".equals(textValue.trim())) {
-                    if (childText == null) childText = "";
-                    childText += textValue.trim();
-                }
-            }
-            child = child.getNextOMSibling();
-        }
-
-        return childText;
-    }
-
     /**
      * Removes an attribute from the element.
      *

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java?rev=1293952&r1=1293951&r2=1293952&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
Sun Feb 26 23:00:51 2012
@@ -876,58 +876,14 @@ public class OMElementImpl extends OMNod
     }
 
     public QName getTextAsQName() {
-        String childText = getTrimmedText();
-        if (childText != null) {
-            return resolveQName(childText);
-        }
-        return null;
+        String childText = getText().trim();
+        return childText.length() == 0 ? null : resolveQName(childText);
     }
 
     public void writeTextTo(Writer out, boolean cache) throws IOException {
         OMElementImplUtil.writeTextTo(this, out, cache);
     }
 
-    /**
-     * Returns the concatination string of TRIMMED values of all OMText  child nodes of this
-     * element. This is included purely to improve usability.
-     */
-    public String getTrimmedText() {
-        String childText = null;
-        StringBuffer buffer = null;
-        OMNode child = this.getFirstOMChild();
-
-        while (child != null) {
-            if (child.getType() == OMNode.TEXT_NODE) {
-                OMText textNode = (OMText) child;
-                String textValue = textNode.getText();
-                if (textValue != null && textValue.length() != 0) {
-                    if (childText == null) {
-                        // This is the first non empty text node. Just save the string.
-                        childText = textValue.trim();
-                    } else {
-                        // We've already seen a non empty text node before. Concatenate using
-                        // a StringBuffer.
-                        if (buffer == null) {
-                            // This is the first text node we need to append. Initialize
the
-                            // StringBuffer.
-                            buffer = new StringBuffer(childText);
-                        }
-                        buffer.append(textValue.trim());
-                    }
-                }
-            }
-            child = child.getNextOMSibling();
-        }
-
-        if (childText == null) {
-            return null;
-        } else if (buffer != null) {
-            return buffer.toString();
-        } else {
-            return childText;
-        }
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////////////////////////
 

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java?rev=1293952&r1=1293951&r2=1293952&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
Sun Feb 26 23:00:51 2012
@@ -798,11 +798,6 @@ public class OMSourcedElementImpl extend
         return super.getNextOMSiblingIfAvailable();
     }
 
-    public String getTrimmedText() {
-        forceExpand();
-        return super.getTrimmedText();
-    }
-
     OMNamespace handleNamespace(QName qname) {
         forceExpand();
         return super.handleNamespace(qname);



Mime
View raw message