ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1611822 - in /webservices/axiom/trunk: aspects/core-aspects/src/main/java/org/apache/axiom/core/ aspects/dom-aspects/src/main/java/org/apache/axiom/dom/ modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/ modules/axiom...
Date Fri, 18 Jul 2014 21:56:53 GMT
Author: veithen
Date: Fri Jul 18 21:56:52 2014
New Revision: 1611822

URL: http://svn.apache.org/r1611822
Log:
Unify the detach code.

Modified:
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreChildNodeSupport.aj
    webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMParentNodeSupport.aj
    webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMNodeSupport.aj
    webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java
    webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
    webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
    webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
    webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.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/OMNodeImpl.java

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreChildNodeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreChildNodeSupport.aj?rev=1611822&r1=1611821&r2=1611822&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreChildNodeSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreChildNodeSupport.aj
Fri Jul 18 21:56:52 2014
@@ -166,7 +166,8 @@ public aspect CoreChildNodeSupport {
         CoreParentNode parent = coreGetParent();
         if (parent != null) {
             // TODO: ugly hack
-            if (this instanceof CoreParentNode) {
+            if (this instanceof CoreParentNode &&
+                    ((CoreParentNode)this).getState() == CoreParentNode.INCOMPLETE) {
                 ((CoreParentNode)this).build();
             }
             

Modified: webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMParentNodeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMParentNodeSupport.aj?rev=1611822&r1=1611821&r2=1611822&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMParentNodeSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMParentNodeSupport.aj
Fri Jul 18 21:56:52 2014
@@ -18,9 +18,22 @@
  */
 package org.apache.axiom.dom;
 
+import static org.apache.axiom.dom.DOMExceptionUtil.newDOMException;
+
 import org.apache.axiom.core.CoreChildNode;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Node;
 
 public aspect DOMParentNodeSupport {
+    public final Node DOMParentNode.removeChild(Node oldChild) throws DOMException {
+        if (oldChild.getParentNode() == this) {
+            ((CoreChildNode)oldChild).coreDetach(coreGetOwnerDocument(true));
+            return oldChild;
+        } else {
+            throw newDOMException(DOMException.NOT_FOUND_ERR);
+        }
+    }
+
     public void DOMParentNode.normalize(DOMConfigurationImpl config) {
         CoreChildNode child = coreGetFirstChild();
         while (child != null) {

Modified: webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMNodeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMNodeSupport.aj?rev=1611822&r1=1611821&r2=1611822&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMNodeSupport.aj
(original)
+++ webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMNodeSupport.aj
Fri Jul 18 21:56:52 2014
@@ -58,4 +58,13 @@ public aspect OMNodeSupport {
         }
         coreInsertSiblingBefore(parent.prepareNewChild(sibling));
     }
+    
+    public OMNode INode.detach() {
+        if (!coreHasParent()) {
+            throw new OMException(
+                    "Nodes that don't have a parent can not be detached");
+        }
+        coreDetach(null);
+        return this;
+    }
 }

Modified: webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java?rev=1611822&r1=1611821&r2=1611822&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java
(original)
+++ webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java
Fri Jul 18 21:56:52 2014
@@ -25,11 +25,12 @@ import org.apache.axiom.dom.DOMChildNode
 import org.apache.axiom.om.OMCloneOptions;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Element;
 
-public abstract class ChildNode extends NodeImpl implements DOMChildNode {
+public abstract class ChildNode extends NodeImpl implements DOMChildNode, OMNode {
     public ChildNode(OMFactory factory) {
         super(factory);
     }

Modified: webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java?rev=1611822&r1=1611821&r2=1611822&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
(original)
+++ webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
Fri Jul 18 21:56:52 2014
@@ -452,7 +452,7 @@ public class DocumentImpl extends RootNo
         if (node instanceof NodeImpl) {
             NodeImpl childNode = (NodeImpl)node;
             if (childNode instanceof CoreChildNode && ((CoreChildNode)childNode).coreHasParent())
{
-                childNode.detach();
+                ((OMNode)childNode).detach();
             }
             childNode.coreSetOwnerDocument(this);
             if (node instanceof AttrImpl) {

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=1611822&r1=1611821&r2=1611822&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
Fri Jul 18 21:56:52 2014
@@ -920,13 +920,6 @@ public class ElementImpl extends ParentN
         }
     }
 
-    OMNode detach(boolean useDomSemantics) {
-        if (getState() == INCOMPLETE) {
-            build();
-        }
-        return super.detach(useDomSemantics);
-    }
-
     public final void build() {
         defaultBuild();
     }

Modified: webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java?rev=1611822&r1=1611821&r2=1611822&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
(original)
+++ webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
Fri Jul 18 21:56:52 2014
@@ -456,40 +456,6 @@ public abstract class NodeImpl extends I
         }
     }
 
-    public OMNode detach() throws OMException {
-        return detach(false);
-    }
-    
-    OMNode detach(boolean useDomSemantics) {
-        ParentNode parentNode = parentNode();
-        if (parentNode == null) {
-            throw new OMException("Parent level elements cannot be detached");
-        } else {
-            NodeImpl previousSibling = internalGetPreviousSibling();
-            NodeImpl nextSibling = internalGetNextSibling();
-            if (previousSibling == null) { // This is the first child
-                if (nextSibling != null) {
-                    parentNode.coreSetFirstChild((CoreChildNode)nextSibling);
-                } else {
-                    parentNode.coreSetFirstChild(null);
-                    parentNode.coreSetLastChild(null);
-                }
-            } else {
-                previousSibling.setNextOMSibling((OMNode)nextSibling);
-            }
-            if (nextSibling != null) {
-                nextSibling.setPreviousOMSibling((OMNode)previousSibling);
-                internalSetNextSibling(null);
-            }
-            if (parentNode != null && parentNode.coreGetLastKnownChild() == this)
{
-                parentNode.coreSetLastChild((CoreChildNode)previousSibling);
-            }
-            setParent(null, useDomSemantics);
-            internalSetPreviousSibling(null);
-        }
-        return (OMNode)this;
-    }
-
     public abstract OMXMLParserWrapper getBuilder();
     
     public abstract void setComplete(boolean state);

Modified: webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java?rev=1611822&r1=1611821&r2=1611822&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
(original)
+++ webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
Fri Jul 18 21:56:52 2014
@@ -326,16 +326,6 @@ public abstract class ParentNode extends
         return oldChild;
     }
 
-    /** Removes the given child from the DOM Tree. */
-    public final Node removeChild(Node oldChild) throws DOMException {
-        if (oldChild.getParentNode() == this) {
-            ((NodeImpl)oldChild).detach(true);
-            return oldChild;
-        } else {
-            throw newDOMException(DOMException.NOT_FOUND_ERR);
-        }
-    }
-
     /**
      * Checks if the given node is an ancestor (or identical) to this node.
      * 

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=1611822&r1=1611821&r2=1611822&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
Fri Jul 18 21:56:52 2014
@@ -477,19 +477,6 @@ public class OMElementImpl extends OMNod
         return addAttribute(new OMAttributeImpl(localName, namespace, value, getOMFactory()));
     }
 
-    /**
-     * Removes this information item and its children, from the model completely.
-     *
-     * @throws OMException
-     */
-    public OMNode detach() throws OMException {
-        if (getState() == INCOMPLETE) {
-            build();
-        }
-        super.detach();
-        return this;
-    }
-
     public void build() throws OMException {
         /**
          * builder is null. Meaning this is a programatical created element but it has children
which are not completed

Modified: webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNodeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNodeImpl.java?rev=1611822&r1=1611821&r2=1611822&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNodeImpl.java
(original)
+++ webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNodeImpl.java
Fri Jul 18 21:56:52 2014
@@ -22,11 +22,9 @@ package org.apache.axiom.om.impl.llom;
 import org.apache.axiom.core.CoreParentNode;
 import org.apache.axiom.om.OMCloneOptions;
 import org.apache.axiom.om.OMContainer;
-import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMInformationItem;
 import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.impl.common.INode;
 
 /** Class OMNodeImpl */
 public abstract class OMNodeImpl extends OMSerializableImpl implements OMNode {
@@ -74,39 +72,6 @@ public abstract class OMNodeImpl extends
     }
 
     /**
-     * Removes this information item and its children, from the model completely.
-     *
-     * @throws OMException
-     */
-    public OMNode detach() throws OMException {
-        CoreParentNode parent = coreGetParent();
-        if (parent == null) {
-            throw new OMException(
-                    "Nodes that don't have a parent can not be detached");
-        }
-        // Note that we don't need to force creation of the next sibling because the
-        // builder will always add new nodes to the end of list of children of the
-        // document or element being built.
-        INode nextSibling = (INode)getNextOMSiblingIfAvailable();
-        INode previousSibling = (INode)coreGetPreviousSibling();
-        if (previousSibling == null) {
-            parent.coreSetFirstChild(nextSibling);
-        } else {
-            previousSibling.coreSetNextSibling(nextSibling);
-        }
-        if (nextSibling == null) {
-            parent.coreSetLastChild(previousSibling);
-        } else {
-            nextSibling.coreSetPreviousSibling(previousSibling);
-        }
-
-        coreSetPreviousSibling(null);
-        coreSetNextSibling(null);
-        internalUnsetParent(null);
-        return this;
-    }
-
-    /**
      * Method setPreviousOMSibling.
      *
      * @param previousSibling



Mime
View raw message