Author: veithen
Date: Mon Jul  7 18:49:16 2014
New Revision: 1608546

URL: http://svn.apache.org/r1608546
Log:
Duplicate code elimination.

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

Modified: 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMElementSupport.aj
URL: 
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMElementSupport.aj?rev=1608546&r1=1608545&r2=1608546&view=diff
==============================================================================
--- 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMElementSupport.aj
 (original)
+++ 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMElementSupport.aj
 Mon Jul  7 18:49:16 2014
@@ -27,6 +27,7 @@ import java.util.Iterator;
 import java.util.Map;
 
 import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
@@ -37,7 +38,6 @@ import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMSourcedElement;
 import org.apache.axiom.om.OMText;
-import org.apache.axiom.om.impl.OMNodeEx;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.util.namespace.MapBasedNamespaceContext;
 import org.apache.axiom.util.stax.XMLStreamReaderUtils;
@@ -101,6 +101,12 @@ public aspect OMElementSupport {
         }
     }
     
+    // Note: must not be final because it is (incorrectly) overridden in the 
SOAPFaultCode implementation for SOAP 1.2
+    public QName OMElement.getTextAsQName() {
+        String childText = getText().trim();
+        return childText.length() == 0 ? null : resolveQName(childText);
+    }
+
     public Reader OMElement.getTextAsStream(boolean cache) {
         // If the element is not an OMSourcedElement and has not more than one 
child, then the most
         // efficient way to get the Reader is to build a StringReader
@@ -148,6 +154,30 @@ public aspect OMElementSupport {
         }
     }
     
+    public final void OMElement.setText(String text) {
+        // Remove all existing children
+        OMNode child;
+        while ((child = getFirstOMChild()) != null) {
+            child.detach();
+        }
+        // Add a new text node
+        if (text != null && text.length() > 0) {
+            getOMFactory().createOMText(this, text);
+        }
+    }
+
+    public final void OMElement.setText(QName qname) {
+        // Remove all existing children
+        OMNode child;
+        while ((child = getFirstOMChild()) != null) {
+            child.detach();
+        }
+        // Add a new text node
+        if (qname != null) {
+            getOMFactory().createOMText(this, qname);
+        }
+    }
+
     public void IElement.discard() {
         if (getState() == CoreParentNode.INCOMPLETE && getBuilder() != null) {
             ((StAXOMBuilder)getBuilder()).discard((OMContainer)this);

Modified: 
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
URL: 
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java?rev=1608546&r1=1608545&r2=1608546&view=diff
==============================================================================
--- 
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
 (original)
+++ 
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
 Mon Jul  7 18:49:16 2014
@@ -747,11 +747,6 @@ public class ElementImpl extends ParentN
                  || namespace != null && 
name.getNamespaceURI().equals(namespace.getNamespaceURI()));
     }
 
-    public QName getTextAsQName() {
-        String childText = getText().trim();
-        return childText.length() == 0 ? null : resolveQName(childText);
-    }
-
     public void removeAttribute(OMAttribute attr) {
         if (attr.getOwner() != this) {
             throw new OMException("The attribute is not owned by this 
element");
@@ -784,35 +779,6 @@ public class ElementImpl extends ParentN
         internalSetNamespace(namespace);
     }
 
-    /**
-     * Creates a text node with the given value and adds it to the element.
-     *
-     * @see org.apache.axiom.om.OMElement#setText(String)
-     */
-    public void setText(String text) {
-        // Remove all existing children
-        OMNode child;
-        while ((child = getFirstOMChild()) != null) {
-            child.detach();
-        }
-        // Add a new text node
-        if (text != null && text.length() > 0) {
-            getOMFactory().createOMText(this, text);
-        }
-    }
-
-    public void setText(QName qname) {
-        // Remove all existing children
-        OMNode child;
-        while ((child = getFirstOMChild()) != null) {
-            child.detach();
-        }
-        // Add a new text node
-        if (qname != null) {
-            getOMFactory().createOMText(this, qname);
-        }
-    }
-
     public void internalSerialize(Serializer serializer,
                                      OMOutputFormat format, boolean cache) 
throws OutputException {
 

Modified: 
webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
URL: 
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java?rev=1608546&r1=1608545&r2=1608546&view=diff
==============================================================================
--- 
webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
 (original)
+++ 
webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
 Mon Jul  7 18:49:16 2014
@@ -550,35 +550,6 @@ public class OMElementImpl extends OMNod
         coreSetState(DISCARDED);
     }
 
-    public void setText(String text) {
-        // Remove all existing children
-        OMNode child;
-        while ((child = getFirstOMChild()) != null) {
-            child.detach();
-        }
-        // Add a new text node
-        if (text != null && text.length() > 0) {
-            getOMFactory().createOMText(this, text);
-        }
-    }
-
-    public void setText(QName qname) {
-        // Remove all existing children
-        OMNode child;
-        while ((child = getFirstOMChild()) != null) {
-            child.detach();
-        }
-        // Add a new text node
-        if (qname != null) {
-            getOMFactory().createOMText(this, qname);
-        }
-    }
-
-    public QName getTextAsQName() {
-        String childText = getText().trim();
-        return childText.length() == 0 ? null : resolveQName(childText);
-    }
-
 
///////////////////////////////////////////////////////////////////////////////////////////////
 
//////////////////////////////////////////////////////////////////////////////////////////////
 

Modified: 
webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
URL: 
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java?rev=1608546&r1=1608545&r2=1608546&view=diff
==============================================================================
--- 
webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
 (original)
+++ 
webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
 Mon Jul  7 18:49:16 2014
@@ -483,14 +483,6 @@ public class OMSourcedElementImpl extend
         return getXMLStreamReader(false);
     }
 
-    public void setText(String text) {
-        super.setText(text);
-    }
-
-    public void setText(QName text) {
-        super.setText(text);
-    }
-
     public String getText() {
         return super.getText();
     }
@@ -499,10 +491,6 @@ public class OMSourcedElementImpl extend
         return super.getTextAsStream(cache);
     }
 
-    public QName getTextAsQName() {
-        return super.getTextAsQName();
-    }
-
     public void writeTextTo(Writer out, boolean cache) throws IOException {
         super.writeTextTo(out, cache);
     }


Reply via email to