ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1698245 - in /webservices/axiom/trunk: aspects/core-aspects/src/main/java/org/apache/axiom/core/ aspects/dom-aspects/src/main/java/org/apache/axiom/dom/ aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/ implementations/axio...
Date Thu, 27 Aug 2015 23:26:13 GMT
Author: veithen
Date: Thu Aug 27 23:26:12 2015
New Revision: 1698245

URL: http://svn.apache.org/r1698245
Log:
Start to converge the clone code in LLOM and DOOM.

Added:
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/ClonePolicy.java
  (with props)
Modified:
    webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/Policies.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/Policies.java
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentFragmentImpl.java
    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/ElementImpl.java
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareAttribute.java
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareElement.java
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSUnawareAttribute.java
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSUnawareElement.java
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamespaceDeclaration.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

Added: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/ClonePolicy.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/ClonePolicy.java?rev=1698245&view=auto
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/ClonePolicy.java
(added)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/ClonePolicy.java
Thu Aug 27 23:26:12 2015
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.core;
+
+/**
+ * Defines how an object model tree is to be cloned.
+ */
+public interface ClonePolicy {
+    boolean repairNamespaces();
+    boolean cloneAttributes();
+    boolean cloneChildren(int nodeType);
+}

Propchange: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/ClonePolicy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/Policies.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/Policies.java?rev=1698245&r1=1698244&r2=1698245&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/Policies.java
(original)
+++ webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/Policies.java
Thu Aug 27 23:26:12 2015
@@ -19,8 +19,10 @@
 package org.apache.axiom.dom;
 
 import org.apache.axiom.core.AttributeMatcher;
+import org.apache.axiom.core.ClonePolicy;
 import org.apache.axiom.core.CoreAttribute;
 import org.apache.axiom.core.CoreDocument;
+import org.apache.axiom.core.CoreNode;
 import org.apache.axiom.core.CoreParentNode;
 import org.apache.axiom.core.DetachPolicy;
 import org.apache.axiom.core.NSAwareAttributeMatcher;
@@ -92,4 +94,32 @@ public final class Policies {
             return isForeignDocument ? Action.REJECT : Action.MOVE;
         }
     };
+
+    public static final ClonePolicy DEEP_CLONE = new ClonePolicy() {
+        public boolean repairNamespaces() {
+            return false;
+        }
+
+        public boolean cloneAttributes() {
+            return true;
+        }
+
+        public boolean cloneChildren(int nodeType) {
+            return true;
+        }
+    };
+
+    public static final ClonePolicy SHALLOW_CLONE = new ClonePolicy() {
+        public boolean repairNamespaces() {
+            return false;
+        }
+
+        public boolean cloneAttributes() {
+            return true;
+        }
+
+        public boolean cloneChildren(int nodeType) {
+            return nodeType == CoreNode.NS_UNAWARE_ATTRIBUTE_NODE || nodeType == CoreNode.NS_AWARE_ATTRIBUTE_NODE;
+        }
+    };
 }

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/Policies.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/Policies.java?rev=1698245&r1=1698244&r2=1698245&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/Policies.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/Policies.java
Thu Aug 27 23:26:12 2015
@@ -19,6 +19,7 @@
 package org.apache.axiom.om.impl.common;
 
 import org.apache.axiom.core.AttributeMatcher;
+import org.apache.axiom.core.ClonePolicy;
 import org.apache.axiom.core.CoreDocument;
 import org.apache.axiom.core.CoreParentNode;
 import org.apache.axiom.core.DetachPolicy;
@@ -54,4 +55,18 @@ public final class Policies {
             return isForeignModel ? Action.CLONE : Action.MOVE;
         }
     };
+    
+    public static final ClonePolicy CLONE_POLICY = new ClonePolicy() {
+        public boolean repairNamespaces() {
+            return true;
+        }
+
+        public boolean cloneAttributes() {
+            return true;
+        }
+
+        public boolean cloneChildren(int nodeType) {
+            return true;
+        }
+    };
 }

Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java?rev=1698245&r1=1698244&r2=1698245&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java
(original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java
Thu Aug 27 23:26:12 2015
@@ -18,6 +18,7 @@
  */
 package org.apache.axiom.om.impl.dom;
 
+import org.apache.axiom.core.ClonePolicy;
 import org.apache.axiom.dom.DOMChildNode;
 import org.apache.axiom.om.OMCloneOptions;
 import org.apache.axiom.om.OMFactory;
@@ -28,7 +29,7 @@ public abstract class ChildNode extends
         super(factory);
     }
 
-    final NodeImpl clone(OMCloneOptions options, ParentNode targetParent, boolean deep, boolean
namespaceRepairing) {
+    final NodeImpl clone(OMCloneOptions options, ParentNode targetParent, ClonePolicy policy)
{
         beforeClone(options);
         ChildNode clone = createClone();
         if (targetParent != null) {

Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentFragmentImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentFragmentImpl.java?rev=1698245&r1=1698244&r2=1698245&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentFragmentImpl.java
(original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentFragmentImpl.java
Thu Aug 27 23:26:12 2015
@@ -19,6 +19,7 @@
 
 package org.apache.axiom.om.impl.dom;
 
+import org.apache.axiom.core.ClonePolicy;
 import org.apache.axiom.core.NodeFactory;
 import org.apache.axiom.dom.DOMDocumentFragment;
 import org.apache.axiom.om.OMCloneOptions;
@@ -34,7 +35,7 @@ public class DocumentFragmentImpl extend
         return (NodeFactory)getOMFactory();
     }
 
-    ParentNode shallowClone(OMCloneOptions options, ParentNode targetParent, boolean namespaceRepairing)
{
+    ParentNode shallowClone(OMCloneOptions options, ParentNode targetParent, ClonePolicy
policy) {
         return new DocumentFragmentImpl(getOMFactory());
     }
 }

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=1698245&r1=1698244&r2=1698245&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
Thu Aug 27 23:26:12 2015
@@ -21,6 +21,7 @@ package org.apache.axiom.om.impl.dom;
 
 import static org.apache.axiom.dom.DOMExceptionTranslator.newDOMException;
 
+import org.apache.axiom.core.ClonePolicy;
 import org.apache.axiom.core.CoreChildNode;
 import org.apache.axiom.core.CoreModelException;
 import org.apache.axiom.core.NodeMigrationPolicy;
@@ -289,7 +290,7 @@ public class DocumentImpl extends Parent
         throw new UnsupportedOperationException("TODO");
     }
 
-    ParentNode shallowClone(OMCloneOptions options, ParentNode targetParent, boolean namespaceRepairing)
{
+    ParentNode shallowClone(OMCloneOptions options, ParentNode targetParent, ClonePolicy
policy) {
         DocumentImpl clone;
         if (options.isPreserveModel()) {
             clone = createClone(options);

Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java?rev=1698245&r1=1698244&r2=1698245&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
(original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
Thu Aug 27 23:26:12 2015
@@ -21,6 +21,7 @@ package org.apache.axiom.om.impl.dom;
 
 import static org.apache.axiom.dom.DOMExceptionTranslator.newDOMException;
 
+import org.apache.axiom.core.ClonePolicy;
 import org.apache.axiom.core.NodeMigrationException;
 import org.apache.axiom.core.NodeMigrationPolicy;
 import org.apache.axiom.dom.DOMAttribute;
@@ -62,14 +63,14 @@ public abstract class ElementImpl extend
         return prefix;
     }
 
-    final ParentNode shallowClone(OMCloneOptions options, ParentNode targetParent, boolean
namespaceRepairing) {
-        ElementImpl clone = createClone(options, targetParent, namespaceRepairing);
+    final ParentNode shallowClone(OMCloneOptions options, ParentNode targetParent, ClonePolicy
policy) {
+        ElementImpl clone = createClone(options, targetParent, policy);
         NamedNodeMap attributes = getAttributes();
         for (int i=0, l=attributes.getLength(); i<l; i++) {
             AttrImpl attr = (AttrImpl)attributes.item(i);
-            AttrImpl clonedAttr = (AttrImpl)attr.clone(options, null, true, false);
+            AttrImpl clonedAttr = (AttrImpl)attr.clone(options, null, policy);
             clonedAttr.coreSetSpecified(attr.coreGetSpecified());
-            if (namespaceRepairing && attr instanceof NSAwareAttribute) {
+            if (policy.repairNamespaces() && attr instanceof NSAwareAttribute) {
                 NSAwareAttribute nsAwareAttr = (NSAwareAttribute)attr;
                 String namespaceURI = nsAwareAttr.coreGetNamespaceURI();
                 if (namespaceURI.length() != 0) {
@@ -85,7 +86,7 @@ public abstract class ElementImpl extend
         return clone;
     }
 
-    abstract ElementImpl createClone(OMCloneOptions options, ParentNode targetParent, boolean
namespaceRepairing);
+    abstract ElementImpl createClone(OMCloneOptions options, ParentNode targetParent, ClonePolicy
policy);
     
     /*
      * DOM-Level 3 methods

Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareAttribute.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareAttribute.java?rev=1698245&r1=1698244&r2=1698245&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareAttribute.java
(original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareAttribute.java
Thu Aug 27 23:26:12 2015
@@ -18,6 +18,7 @@
  */
 package org.apache.axiom.om.impl.dom;
 
+import org.apache.axiom.core.ClonePolicy;
 import org.apache.axiom.dom.DOMNSAwareAttribute;
 import org.apache.axiom.om.OMCloneOptions;
 import org.apache.axiom.om.OMConstants;
@@ -56,7 +57,7 @@ public final class NSAwareAttribute exte
     }
 
     @Override
-    final ParentNode shallowClone(OMCloneOptions options, ParentNode targetParent, boolean
namespaceRepairing) {
+    final ParentNode shallowClone(OMCloneOptions options, ParentNode targetParent, ClonePolicy
policy) {
         // Note: targetParent is always null here
         return new NSAwareAttribute(getLocalName(), getNamespace(), coreGetType(), getOMFactory());
     }

Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareElement.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareElement.java?rev=1698245&r1=1698244&r2=1698245&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareElement.java
(original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareElement.java
Thu Aug 27 23:26:12 2015
@@ -21,6 +21,7 @@ package org.apache.axiom.om.impl.dom;
 
 import java.util.Iterator;
 
+import org.apache.axiom.core.ClonePolicy;
 import org.apache.axiom.dom.DOMConfigurationImpl;
 import org.apache.axiom.dom.DOMNSAwareElement;
 import org.apache.axiom.om.OMCloneOptions;
@@ -71,8 +72,8 @@ public class NSAwareElement extends Elem
     }
 
     @Override
-    final ElementImpl createClone(OMCloneOptions options, ParentNode targetParent, boolean
namespaceRepairing) {
-        return (ElementImpl)shallowCloneWithoutAttributes(options, targetParent, namespaceRepairing);
+    final ElementImpl createClone(OMCloneOptions options, ParentNode targetParent, ClonePolicy
policy) {
+        return (ElementImpl)shallowCloneWithoutAttributes(options, targetParent, policy.repairNamespaces());
     }
 
     public void setLineNumber(int lineNumber) {

Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSUnawareAttribute.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSUnawareAttribute.java?rev=1698245&r1=1698244&r2=1698245&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSUnawareAttribute.java
(original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSUnawareAttribute.java
Thu Aug 27 23:26:12 2015
@@ -18,6 +18,7 @@
  */
 package org.apache.axiom.om.impl.dom;
 
+import org.apache.axiom.core.ClonePolicy;
 import org.apache.axiom.core.NodeFactory;
 import org.apache.axiom.dom.DOMNSUnawareAttribute;
 import org.apache.axiom.om.OMCloneOptions;
@@ -34,7 +35,7 @@ public class NSUnawareAttribute extends
 
     @Override
     ParentNode shallowClone(OMCloneOptions options, ParentNode targetParent,
-            boolean namespaceRepairing) {
+            ClonePolicy policy) {
         // TODO Auto-generated method stub
         throw new UnsupportedOperationException();
     }

Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSUnawareElement.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSUnawareElement.java?rev=1698245&r1=1698244&r2=1698245&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSUnawareElement.java
(original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSUnawareElement.java
Thu Aug 27 23:26:12 2015
@@ -18,6 +18,7 @@
  */
 package org.apache.axiom.om.impl.dom;
 
+import org.apache.axiom.core.ClonePolicy;
 import org.apache.axiom.core.NodeFactory;
 import org.apache.axiom.dom.DOMNSUnawareElement;
 import org.apache.axiom.om.OMCloneOptions;
@@ -37,7 +38,7 @@ public class NSUnawareElement extends El
     }
 
     @Override
-    ElementImpl createClone(OMCloneOptions options, ParentNode targetParent, boolean namespaceRepairing)
{
+    ElementImpl createClone(OMCloneOptions options, ParentNode targetParent, ClonePolicy
policy) {
         // TODO
         throw new UnsupportedOperationException();
     }

Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamespaceDeclaration.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamespaceDeclaration.java?rev=1698245&r1=1698244&r2=1698245&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamespaceDeclaration.java
(original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamespaceDeclaration.java
Thu Aug 27 23:26:12 2015
@@ -18,6 +18,7 @@
  */
 package org.apache.axiom.om.impl.dom;
 
+import org.apache.axiom.core.ClonePolicy;
 import org.apache.axiom.dom.DOMNamespaceDeclaration;
 import org.apache.axiom.om.OMCloneOptions;
 import org.apache.axiom.om.OMFactory;
@@ -36,7 +37,7 @@ public final class NamespaceDeclaration
     }
 
     @Override
-    final ParentNode shallowClone(OMCloneOptions options, ParentNode targetParent, boolean
namespaceRepairing) {
+    final ParentNode shallowClone(OMCloneOptions options, ParentNode targetParent, ClonePolicy
policy) {
         NamespaceDeclaration clone = new NamespaceDeclaration(getOMFactory());
         // TODO: this is ugly, but we are expected to create a shallow clone and can't copy
the value;
         //       this will be fixed when the clone code is moved to om-aspects

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=1698245&r1=1698244&r2=1698245&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
Thu Aug 27 23:26:12 2015
@@ -21,8 +21,10 @@ package org.apache.axiom.om.impl.dom;
 
 import static org.apache.axiom.dom.DOMExceptionTranslator.newDOMException;
 
+import org.apache.axiom.core.ClonePolicy;
 import org.apache.axiom.core.CoreChildNode;
 import org.apache.axiom.dom.DOMNode;
+import org.apache.axiom.dom.Policies;
 import org.apache.axiom.om.OMCloneOptions;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMInformationItem;
@@ -60,7 +62,7 @@ public abstract class NodeImpl implement
         OMCloneOptions options = new OMCloneOptions();
         // This is not specified by the API, but it's compatible with versions before 1.2.14
         options.setPreserveModel(true);
-        NodeImpl clone = clone(options, null, getNodeType() == Node.ATTRIBUTE_NODE ? true
: deep, false);
+        NodeImpl clone = clone(options, null, deep ? Policies.DEEP_CLONE : Policies.SHALLOW_CLONE);
         if (!(clone instanceof DocumentImpl)) {
             clone.coreSetOwnerDocument(ownerDocument());
         }
@@ -339,8 +341,8 @@ public abstract class NodeImpl implement
     public abstract OMXMLParserWrapper getBuilder();
     
     public final OMInformationItem clone(OMCloneOptions options) {
-        return (OMInformationItem)clone(options, null, true, true);
+        return (OMInformationItem)clone(options, null, org.apache.axiom.om.impl.common.Policies.CLONE_POLICY);
     }
 
-    abstract NodeImpl clone(OMCloneOptions options, ParentNode targetParent, boolean deep,
boolean namespaceRepairing);
+    abstract NodeImpl clone(OMCloneOptions options, ParentNode targetParent, ClonePolicy
policy);
 }

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=1698245&r1=1698244&r2=1698245&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
Thu Aug 27 23:26:12 2015
@@ -21,6 +21,7 @@ package org.apache.axiom.om.impl.dom;
 
 import static org.apache.axiom.dom.DOMExceptionTranslator.newDOMException;
 
+import org.apache.axiom.core.ClonePolicy;
 import org.apache.axiom.core.CoreChildNode;
 import org.apache.axiom.core.CoreDocumentFragment;
 import org.apache.axiom.dom.DOMParentNode;
@@ -149,15 +150,15 @@ public abstract class ParentNode extends
         return false;
     }
 
-    final NodeImpl clone(OMCloneOptions options, ParentNode targetParent, boolean deep, boolean
namespaceRepairing) {
-        ParentNode clone = shallowClone(options, targetParent, namespaceRepairing);
-        if (deep) {
+    final NodeImpl clone(OMCloneOptions options, ParentNode targetParent, ClonePolicy policy)
{
+        ParentNode clone = shallowClone(options, targetParent, policy);
+        if (policy.cloneChildren(coreGetNodeType())) {
             for (Node child = getFirstChild(); child != null; child = child.getNextSibling())
{
-                ((NodeImpl)child).clone(options, clone, true, namespaceRepairing);
+                ((NodeImpl)child).clone(options, clone, policy);
             }
         }
         return clone;
     }
     
-    abstract ParentNode shallowClone(OMCloneOptions options, ParentNode targetParent, boolean
namespaceRepairing);
+    abstract ParentNode shallowClone(OMCloneOptions options, ParentNode targetParent, ClonePolicy
policy);
 }



Mime
View raw message