ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1691714 - in /webservices/axiom/trunk: aspects/core-aspects/src/main/java/org/apache/axiom/core/ aspects/dom-aspects/src/main/java/org/apache/axiom/dom/ implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/
Date Sat, 18 Jul 2015 10:16:37 GMT
Author: veithen
Date: Sat Jul 18 10:16:36 2015
New Revision: 1691714

URL: http://svn.apache.org/r1691714
Log:
Reimplement the DOM getTextContent method using coreGetTextContent.

Modified:
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreParentNode.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreParentNodeSupport.aj
    webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMAttributeSupport.aj
    webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMDocumentFragmentSupport.aj
    webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMDocumentSupport.aj
    webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMElementSupport.aj
    webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMEntityReferenceSupport.aj
    webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMLeafNodeSupport.aj
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EntityReferenceImpl.java
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/LeafNode.java
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java?rev=1691714&r1=1691713&r2=1691714&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java
Sat Jul 18 10:16:36 2015
@@ -45,8 +45,6 @@ public interface CoreElement extends Cor
         REPLACED_ATTRIBUTE,
     }
     
-    enum ElementAction { SKIP, RECURSE, FAIL }
-    
     /**
      * Get the first attribute of this element.
      * 
@@ -201,6 +199,4 @@ public interface CoreElement extends Cor
     // TODO: wrong Javadoc: null vs. empty string
     // TODO: we can support default namespaces!
     String coreLookupPrefix(String namespaceURI, boolean strict);
-    
-    String coreGetTextContent(ElementAction elementAction);
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj?rev=1691714&r1=1691713&r2=1691714&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj
Sat Jul 18 10:16:36 2015
@@ -251,72 +251,4 @@ public aspect CoreElementSupport {
             return null;
         }
     }
-    
-    public final String CoreElement.coreGetTextContent(ElementAction elementAction) {
-        String textContent = null;
-        StringBuilder buffer = null;
-        int depth = 0;
-        CoreChildNode child = coreGetFirstChild();
-        boolean visited = false;
-        while (child != null) {
-            if (visited) {
-                visited = false;
-            } else if (child instanceof CoreElement) {
-                switch (elementAction) {
-                    case FAIL:
-                        return null;
-                    case RECURSE:
-                        CoreChildNode firstChild = ((CoreElement)child).coreGetFirstChild();
-                        if (firstChild != null) {
-                            child = firstChild;
-                            depth++;
-                            continue;
-                        }
-                        // Fall through
-                    case SKIP:
-                        // Just continue
-                }
-            } else {
-                String textValue;
-                if (child instanceof CoreCharacterData) {
-                    textValue = ((CoreCharacterData)child).coreGetData();
-                } else if (child instanceof CoreCDATASection) {
-                    textValue = ((CoreCDATASection)child).coreGetData();
-                } else {
-                    textValue = null;
-                }
-                if (textValue != null && textValue.length() != 0) {
-                    if (textContent == null) {
-                        // This is the first non empty text node. Just save the string.
-                        textContent = textValue;
-                    } else {
-                        // We've already seen a non empty text node before. Concatenate using
-                        // a StringBuilder.
-                        if (buffer == null) {
-                            // This is the first text node we need to append. Initialize
the
-                            // StringBuilder.
-                            buffer = new StringBuilder(textContent);
-                        }
-                        buffer.append(textValue);
-                    }
-                }
-            }
-            CoreChildNode nextSibling = child.coreGetNextSibling();
-            if (depth > 0 && nextSibling == null) {
-                depth--;
-                child = (CoreChildNode)child.coreGetParent();
-                visited = true;
-            } else {
-                child = nextSibling;
-            }
-        }
-        if (textContent == null) {
-            // We didn't see any text nodes. Return an empty string.
-            return "";
-        } else if (buffer != null) {
-            return buffer.toString();
-        } else {
-            return textContent;
-        }
-    }
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreParentNode.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreParentNode.java?rev=1691714&r1=1691713&r2=1691714&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreParentNode.java
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreParentNode.java
Sat Jul 18 10:16:36 2015
@@ -24,6 +24,8 @@ import org.apache.axiom.om.OMXMLParserWr
  * Interface for parent nodes.
  */
 public interface CoreParentNode extends CoreNode {
+    enum ElementAction { SKIP, RECURSE, FAIL }
+    
     int INCOMPLETE = 0;
     int COMPLETE = 1;
     int DISCARDED = 2;
@@ -33,4 +35,6 @@ public interface CoreParentNode extends
     int getState();
     void coreSetState(int state);
     void build();
+    
+    String coreGetTextContent(ElementAction elementAction);
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreParentNodeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreParentNodeSupport.aj?rev=1691714&r1=1691713&r2=1691714&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreParentNodeSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreParentNodeSupport.aj
Sat Jul 18 10:16:36 2015
@@ -158,4 +158,72 @@ public aspect CoreParentNodeSupport {
             coreSetState(COMPLETE);
         }
     }
+    
+    public final String CoreParentNode.coreGetTextContent(ElementAction elementAction) {
+        String textContent = null;
+        StringBuilder buffer = null;
+        int depth = 0;
+        CoreChildNode child = coreGetFirstChild();
+        boolean visited = false;
+        while (child != null) {
+            if (visited) {
+                visited = false;
+            } else if (child instanceof CoreElement) {
+                switch (elementAction) {
+                    case FAIL:
+                        return null;
+                    case RECURSE:
+                        CoreChildNode firstChild = ((CoreElement)child).coreGetFirstChild();
+                        if (firstChild != null) {
+                            child = firstChild;
+                            depth++;
+                            continue;
+                        }
+                        // Fall through
+                    case SKIP:
+                        // Just continue
+                }
+            } else {
+                String textValue;
+                if (child instanceof CoreCharacterData) {
+                    textValue = ((CoreCharacterData)child).coreGetData();
+                } else if (child instanceof CoreCDATASection) {
+                    textValue = ((CoreCDATASection)child).coreGetData();
+                } else {
+                    textValue = null;
+                }
+                if (textValue != null && textValue.length() != 0) {
+                    if (textContent == null) {
+                        // This is the first non empty text node. Just save the string.
+                        textContent = textValue;
+                    } else {
+                        // We've already seen a non empty text node before. Concatenate using
+                        // a StringBuilder.
+                        if (buffer == null) {
+                            // This is the first text node we need to append. Initialize
the
+                            // StringBuilder.
+                            buffer = new StringBuilder(textContent);
+                        }
+                        buffer.append(textValue);
+                    }
+                }
+            }
+            CoreChildNode nextSibling = child.coreGetNextSibling();
+            if (depth > 0 && nextSibling == null) {
+                depth--;
+                child = (CoreChildNode)child.coreGetParent();
+                visited = true;
+            } else {
+                child = nextSibling;
+            }
+        }
+        if (textContent == null) {
+            // We didn't see any text nodes. Return an empty string.
+            return "";
+        } else if (buffer != null) {
+            return buffer.toString();
+        } else {
+            return textContent;
+        }
+    }
 }

Modified: webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMAttributeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMAttributeSupport.aj?rev=1691714&r1=1691713&r2=1691714&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMAttributeSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMAttributeSupport.aj
Sat Jul 18 10:16:36 2015
@@ -46,4 +46,8 @@ public aspect DOMAttributeSupport {
     public final NamedNodeMap DOMAttribute.getAttributes() {
         return null;
     }
+    
+    public final String DOMAttribute.getTextContent() {
+        return getValue();
+    }
 }

Modified: webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMDocumentFragmentSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMDocumentFragmentSupport.aj?rev=1691714&r1=1691713&r2=1691714&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMDocumentFragmentSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMDocumentFragmentSupport.aj
Sat Jul 18 10:16:36 2015
@@ -71,4 +71,8 @@ public aspect DOMDocumentFragmentSupport
     public final NamedNodeMap DOMDocumentFragment.getAttributes() {
         return null;
     }
+    
+    public final String DOMDocumentFragment.getTextContent() {
+        return coreGetTextContent(ElementAction.RECURSE);
+    }
 }

Modified: webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMDocumentSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMDocumentSupport.aj?rev=1691714&r1=1691713&r2=1691714&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMDocumentSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMDocumentSupport.aj
Sat Jul 18 10:16:36 2015
@@ -67,6 +67,10 @@ public aspect DOMDocumentSupport {
         return null;
     }
 
+    public final String DOMDocument.getTextContent() throws DOMException {
+        return null;
+    }
+
     public final Element DOMDocument.getDocumentElement() {
         return (Element)coreGetDocumentElement();
     }

Modified: webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMElementSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMElementSupport.aj?rev=1691714&r1=1691713&r2=1691714&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMElementSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMElementSupport.aj
Sat Jul 18 10:16:36 2015
@@ -185,4 +185,8 @@ public aspect DOMElementSupport {
             coreRemoveAttribute(Policies.DOM2_ATTRIBUTE_MATCHER, namespaceURI == null ? ""
: namespaceURI, localName);
         }
     }
+    
+    public final String DOMElement.getTextContent() {
+        return coreGetTextContent(ElementAction.RECURSE);
+    }
 }

Modified: webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMEntityReferenceSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMEntityReferenceSupport.aj?rev=1691714&r1=1691713&r2=1691714&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMEntityReferenceSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMEntityReferenceSupport.aj
Sat Jul 18 10:16:36 2015
@@ -54,4 +54,8 @@ public aspect DOMEntityReferenceSupport
     public final NamedNodeMap DOMEntityReference.getAttributes() {
         return null;
     }
+
+    public final String DOMEntityReference.getTextContent() throws DOMException {
+        throw new UnsupportedOperationException();
+    }
 }

Modified: webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMLeafNodeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMLeafNodeSupport.aj?rev=1691714&r1=1691713&r2=1691714&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMLeafNodeSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMLeafNodeSupport.aj
Sat Jul 18 10:16:36 2015
@@ -81,4 +81,8 @@ public aspect DOMLeafNodeSupport {
     public final NamedNodeMap DOMLeafNode.getAttributes() {
         return null;
     }
+
+    public final String DOMLeafNode.getTextContent() {
+        return getNodeValue();
+    }
 }

Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java?rev=1691714&r1=1691713&r2=1691714&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
(original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
Sat Jul 18 10:16:36 2015
@@ -341,10 +341,6 @@ public class DocumentImpl extends RootNo
     * DOM-Level 3 methods
     */
 
-    public String getTextContent() throws DOMException {
-        return null;
-    }
-
     public void setTextContent(String textContent) throws DOMException {
         // no-op
     }

Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EntityReferenceImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EntityReferenceImpl.java?rev=1691714&r1=1691713&r2=1691714&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EntityReferenceImpl.java
(original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EntityReferenceImpl.java
Sat Jul 18 10:16:36 2015
@@ -100,12 +100,4 @@ public class EntityReferenceImpl extends
     public final Node replaceChild(Node newChild, Node oldChild) throws DOMException {
         throw newDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
     }
-
-    public String getTextContent() throws DOMException {
-        throw new UnsupportedOperationException();
-    }
-
-    void getTextContent(StringBuffer buf) {
-        throw new UnsupportedOperationException();
-    }
 }

Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/LeafNode.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/LeafNode.java?rev=1691714&r1=1691713&r2=1691714&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/LeafNode.java
(original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/LeafNode.java
Sat Jul 18 10:16:36 2015
@@ -20,21 +20,9 @@ package org.apache.axiom.om.impl.dom;
 
 import org.apache.axiom.dom.DOMLeafNode;
 import org.apache.axiom.om.OMFactory;
-import org.w3c.dom.DOMException;
 
 public abstract class LeafNode extends ChildNode implements DOMLeafNode {
     public LeafNode(OMFactory factory) {
         super(factory);
     }
-
-    public final String getTextContent() throws DOMException {
-        return getNodeValue();
-    }
-
-    final void getTextContent(StringBuffer buf) {
-        String content = getNodeValue();
-        if (content != null) {
-            buf.append(content);
-        }
-    }
 }

Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java?rev=1691714&r1=1691713&r2=1691714&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
(original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
Sat Jul 18 10:16:36 2015
@@ -88,9 +88,6 @@ public abstract class NodeImpl implement
         throw newDOMException(DOMException.NOT_SUPPORTED_ERR);
     }
 
-    // internal method taking a StringBuffer in parameter
-    abstract void getTextContent(StringBuffer buf);
-
     public void setTextContent(String textContent) throws DOMException {
         setNodeValue(textContent);  // overriden in some subclasses
     }

Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java?rev=1691714&r1=1691713&r2=1691714&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
(original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
Sat Jul 18 10:16:36 2015
@@ -163,31 +163,6 @@ public abstract class ParentNode extends
     
     abstract ParentNode shallowClone(OMCloneOptions options, ParentNode targetParent, boolean
namespaceRepairing);
 
-    public String getTextContent() throws DOMException {
-        Node child = getFirstChild();
-        if (child != null) {
-            Node next = child.getNextSibling();
-            if (next == null) {
-                return hasTextContent(child) ? ((NodeImpl)child).getTextContent() : "";
-            }
-            StringBuffer buf = new StringBuffer();
-            getTextContent(buf);
-            return buf.toString();
-        } else {
-            return "";
-        }
-    }
-
-    void getTextContent(StringBuffer buf) throws DOMException {
-        Node child = getFirstChild();
-        while (child != null) {
-            if (hasTextContent(child)) {
-                ((NodeImpl)child).getTextContent(buf);
-            }
-            child = child.getNextSibling();
-        }
-    }
-    
     // internal method returning whether to take the given node's text content
     private static boolean hasTextContent(Node child) {
         return child.getNodeType() != Node.COMMENT_NODE &&



Mime
View raw message