ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1700312 - in /webservices/axiom/trunk/aspects: core-aspects/src/main/java/org/apache/axiom/core/ om-aspects/src/main/java/org/apache/axiom/om/impl/common/
Date Mon, 31 Aug 2015 19:34:07 GMT
Author: veithen
Date: Mon Aug 31 19:34:06 2015
New Revision: 1700312

URL: http://svn.apache.org/r1700312
Log:
Further streamline the cloning infrastructure.

Modified:
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreCDATASectionSupport.aj
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreCharacterDataNodeSupport.aj
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreChildNodeSupport.aj
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreCommentSupport.aj
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreDocumentFragmentSupport.aj
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreDocumentSupport.aj
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreDocumentTypeDeclarationSupport.aj
    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/CoreEntityReferenceSupport.aj
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNamespaceDeclarationSupport.aj
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNode.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNodeSupport.aj
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreProcessingInstructionSupport.aj
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreTypedAttributeSupport.aj
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/Policies.java

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreCDATASectionSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreCDATASectionSupport.aj?rev=1700312&r1=1700311&r2=1700312&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreCDATASectionSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreCDATASectionSupport.aj
Mon Aug 31 19:34:06 2015
@@ -23,7 +23,6 @@ public aspect CoreCDATASectionSupport {
         return NodeType.CDATA_SECTION;
     }
     
-    public final <T> CoreNode CoreCDATASection.shallowClone(ClonePolicy<T> policy,
T options) {
-        return coreGetNodeFactory().createNode(CoreCDATASection.class);
+    public final <T> void CoreCDATASection.init(ClonePolicy<T> policy, T options,
CoreNode other) {
     }
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreCharacterDataNodeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreCharacterDataNodeSupport.aj?rev=1700312&r1=1700311&r2=1700312&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreCharacterDataNodeSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreCharacterDataNodeSupport.aj
Mon Aug 31 19:34:06 2015
@@ -48,10 +48,9 @@ public aspect CoreCharacterDataNodeSuppo
         this.data = data;
     }
     
-    public final <T> CoreNode CoreCharacterDataNode.shallowClone(ClonePolicy<T>
policy, T options) {
-        CoreCharacterDataNode clone = coreGetNodeFactory().createNode(CoreCharacterDataNode.class);
-        clone.data = data instanceof CharacterData ? ((CharacterData)data).clone(policy,
options) : data;
-        clone.coreSetIgnorable(coreIsIgnorable());
-        return clone;
+    public final <T> void CoreCharacterDataNode.init(ClonePolicy<T> policy, T
options, CoreNode other) {
+        CoreCharacterDataNode o = (CoreCharacterDataNode)other;
+        data = o.data instanceof CharacterData ? ((CharacterData)o.data).clone(policy, options)
: o.data;
+        coreSetIgnorable(o.coreIsIgnorable());
     }
 }

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=1700312&r1=1700311&r2=1700312&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
Mon Aug 31 19:34:06 2015
@@ -210,12 +210,6 @@ public aspect CoreChildNodeSupport {
     }
 
     public final <T> CoreNode CoreChildNode.coreClone(ClonePolicy<T> policy,
T options, CoreParentNode targetParent) {
-        CoreChildNode clone = (CoreChildNode)shallowClone(policy, options);
-        if (targetParent != null) {
-            targetParent.coreAppendChild(clone, false);
-        }
-        policy.postProcess(options, clone);
-        cloneChildrenIfNecessary(policy, options, clone);
-        return clone;
+        return internalClone(policy, options, targetParent);
     }
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreCommentSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreCommentSupport.aj?rev=1700312&r1=1700311&r2=1700312&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreCommentSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreCommentSupport.aj
Mon Aug 31 19:34:06 2015
@@ -23,7 +23,6 @@ public aspect CoreCommentSupport {
         return NodeType.COMMENT;
     }
     
-    public final <T> CoreNode CoreComment.shallowClone(ClonePolicy<T> policy,
T options) {
-        return coreGetNodeFactory().createNode(CoreComment.class);
+    public final <T> void CoreComment.init(ClonePolicy<T> policy, T options,
CoreNode other) {
     }
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreDocumentFragmentSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreDocumentFragmentSupport.aj?rev=1700312&r1=1700311&r2=1700312&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreDocumentFragmentSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreDocumentFragmentSupport.aj
Mon Aug 31 19:34:06 2015
@@ -37,7 +37,6 @@ public aspect CoreDocumentFragmentSuppor
         ownerDocument = document;
     }
     
-    public final <T> CoreNode CoreDocumentFragment.shallowClone(ClonePolicy<T>
policy, T options) {
-        return coreGetNodeFactory().createNode(CoreDocumentFragment.class);
+    public final <T> void CoreDocumentFragment.init(ClonePolicy<T> policy, T
options, CoreNode other) {
     }
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreDocumentSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreDocumentSupport.aj?rev=1700312&r1=1700311&r2=1700312&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreDocumentSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreDocumentSupport.aj
Mon Aug 31 19:34:06 2015
@@ -81,13 +81,11 @@ public aspect CoreDocumentSupport {
         this.standalone = standalone;
     }
     
-    public final <T> CoreNode CoreDocument.shallowClone(ClonePolicy<T> policy,
T options) {
-        CoreDocument clone = (CoreDocument)coreGetNodeFactory().createNode(
-                policy.preserveModel(options) ? coreGetNodeClass() : coreGetNodeType().getInterface());
-        clone.coreSetXmlVersion(coreGetXmlVersion());
-        clone.coreSetXmlEncoding(coreGetXmlEncoding());
-        clone.coreSetStandalone(coreIsStandalone());
-        clone.coreSetInputEncoding(coreGetInputEncoding());
-        return clone;
+    public final <T> void CoreDocument.init(ClonePolicy<T> policy, T options,
CoreNode other) {
+        CoreDocument o = (CoreDocument)other;
+        coreSetXmlVersion(o.coreGetXmlVersion());
+        coreSetXmlEncoding(o.coreGetXmlEncoding());
+        coreSetStandalone(o.coreIsStandalone());
+        coreSetInputEncoding(o.coreGetInputEncoding());
     }
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreDocumentTypeDeclarationSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreDocumentTypeDeclarationSupport.aj?rev=1700312&r1=1700311&r2=1700312&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreDocumentTypeDeclarationSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreDocumentTypeDeclarationSupport.aj
Mon Aug 31 19:34:06 2015
@@ -60,12 +60,11 @@ public aspect CoreDocumentTypeDeclaratio
         this.internalSubset = internalSubset;
     }
     
-    public final <T> CoreNode CoreDocumentTypeDeclaration.shallowClone(ClonePolicy<T>
policy, T options) {
-        CoreDocumentTypeDeclaration clone = coreGetNodeFactory().createNode(CoreDocumentTypeDeclaration.class);
-        clone.coreSetRootName(coreGetRootName());
-        clone.coreSetPublicId(coreGetPublicId());
-        clone.coreSetSystemId(coreGetSystemId());
-        clone.coreSetInternalSubset(coreGetInternalSubset());
-        return clone;
+    public final <T> void CoreDocumentTypeDeclaration.init(ClonePolicy<T> policy,
T options, CoreNode other) {
+        CoreDocumentTypeDeclaration o = (CoreDocumentTypeDeclaration)other;
+        coreSetRootName(o.coreGetRootName());
+        coreSetPublicId(o.coreGetPublicId());
+        coreSetSystemId(o.coreGetSystemId());
+        coreSetInternalSubset(o.coreGetInternalSubset());
     }
 }

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=1700312&r1=1700311&r2=1700312&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
Mon Aug 31 19:34:06 2015
@@ -251,19 +251,17 @@ public aspect CoreElementSupport {
         }
     }
 
-    public final <T> CoreNode CoreElement.shallowClone(ClonePolicy<T> policy,
T options) {
-        CoreElement clone = (CoreElement)coreGetNodeFactory().createNode(
-                policy.preserveModel(options) ? coreGetNodeClass() : coreGetNodeType().getInterface());
-        clone.initName(this);
-        CoreAttribute attr = coreGetFirstAttribute();
+    public final <T> void CoreElement.init(ClonePolicy<T> policy, T options,
CoreNode other) {
+        CoreElement o = (CoreElement)other;
+        initName(o);
+        CoreAttribute attr = o.coreGetFirstAttribute();
         while (attr != null) {
-            clone.internalAppendAttribute((CoreAttribute)attr.coreClone(policy, options));
+            internalAppendAttribute((CoreAttribute)attr.coreClone(policy, options));
             // TODO: needed?
 //            clonedAttr.coreSetSpecified(attr.coreGetSpecified());
             attr = attr.coreGetNextAttribute();
         }
-        clone.initAncillaryData(policy, options, this);
-        return clone;
+        initAncillaryData(policy, options, o);
     }
 
     public <T> void CoreElement.initAncillaryData(ClonePolicy<T> policy, T options,
CoreElement other) {

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreEntityReferenceSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreEntityReferenceSupport.aj?rev=1700312&r1=1700311&r2=1700312&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreEntityReferenceSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreEntityReferenceSupport.aj
Mon Aug 31 19:34:06 2015
@@ -42,10 +42,9 @@ public aspect CoreEntityReferenceSupport
         this.replacementText = replacementText;
     }
     
-    public final <T> CoreNode CoreEntityReference.shallowClone(ClonePolicy<T>
policy, T options) {
-        CoreEntityReference clone = coreGetNodeFactory().createNode(CoreEntityReference.class);
-        clone.coreSetName(coreGetName());
-        clone.coreSetReplacementText(coreGetReplacementText());
-        return clone;
+    public final <T> void CoreEntityReference.init(ClonePolicy<T> policy, T options,
CoreNode other) {
+        CoreEntityReference o = (CoreEntityReference)other;
+        coreSetName(o.coreGetName());
+        coreSetReplacementText(o.coreGetReplacementText());
     }
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNamespaceDeclarationSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNamespaceDeclarationSupport.aj?rev=1700312&r1=1700311&r2=1700312&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNamespaceDeclarationSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNamespaceDeclarationSupport.aj
Mon Aug 31 19:34:06 2015
@@ -23,10 +23,8 @@ public aspect CoreNamespaceDeclarationSu
         return NodeType.NAMESPACE_DECLARATION;
     }
     
-    public final <T> CoreNode CoreNamespaceDeclaration.shallowClone(ClonePolicy<T>
policy, T options) {
-        CoreNamespaceDeclaration clone = coreGetNodeFactory().createNode(CoreNamespaceDeclaration.class);
+    public final <T> void CoreNamespaceDeclaration.init(ClonePolicy<T> policy,
T options, CoreNode other) {
         // TODO: this is correct but bad for performance with the Axiom API
-        clone.coreSetDeclaredNamespace(coreGetDeclaredPrefix(), "");
-        return clone;
+        coreSetDeclaredNamespace(((CoreNamespaceDeclaration)other).coreGetDeclaredPrefix(),
"");
     }
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNode.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNode.java?rev=1700312&r1=1700311&r2=1700312&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNode.java
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNode.java
Mon Aug 31 19:34:06 2015
@@ -41,6 +41,6 @@ public interface CoreNode {
      */
     <T> CoreNode coreClone(ClonePolicy<T> policy, T options);
     
-    <T> CoreNode shallowClone(ClonePolicy<T> policy, T options);
+    <T> void init(ClonePolicy<T> policy, T options, CoreNode other);
     <T> void cloneChildrenIfNecessary(ClonePolicy<T> policy, T options, CoreNode
clone);
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNodeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNodeSupport.aj?rev=1700312&r1=1700311&r2=1700312&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNodeSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNodeSupport.aj
Mon Aug 31 19:34:06 2015
@@ -66,10 +66,25 @@ public aspect CoreNodeSupport {
         }
     }
     
-    public final <T> CoreNode CoreNode.coreClone(ClonePolicy<T> policy, T options)
{
+    // TODO: merge this into internalClone once it is no longer referenced elsewhere
+    public final <T> CoreNode CoreNode.shallowClone(ClonePolicy<T> policy, T
options) {
+        CoreNode clone = coreGetNodeFactory().createNode(
+                policy.preserveModel(options) ? coreGetNodeClass() : coreGetNodeType().getInterface());
+        clone.init(policy, options, this);
+        return clone;
+    }
+
+    final <T> CoreNode CoreNode.internalClone(ClonePolicy<T> policy, T options,
CoreParentNode targetParent) {
         CoreNode clone = shallowClone(policy, options);
+        if (targetParent != null) {
+            targetParent.coreAppendChild((CoreChildNode)clone, false);
+        }
         policy.postProcess(options, clone);
         cloneChildrenIfNecessary(policy, options, clone);
         return clone;
     }
+    
+    public final <T> CoreNode CoreNode.coreClone(ClonePolicy<T> policy, T options)
{
+        return internalClone(policy, options, null);
+    }
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreProcessingInstructionSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreProcessingInstructionSupport.aj?rev=1700312&r1=1700311&r2=1700312&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreProcessingInstructionSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreProcessingInstructionSupport.aj
Mon Aug 31 19:34:06 2015
@@ -33,9 +33,7 @@ public aspect CoreProcessingInstructionS
         this.target = target;
     }
     
-    public final <T> CoreNode CoreProcessingInstruction.shallowClone(ClonePolicy<T>
policy, T options) {
-        CoreProcessingInstruction clone = coreGetNodeFactory().createNode(CoreProcessingInstruction.class);
-        clone.target = target;
-        return clone;
+    public final <T> void CoreProcessingInstruction.init(ClonePolicy<T> policy,
T options, CoreNode other) {
+        target = ((CoreProcessingInstruction)other).target;
     }
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreTypedAttributeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreTypedAttributeSupport.aj?rev=1700312&r1=1700311&r2=1700312&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreTypedAttributeSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreTypedAttributeSupport.aj
Mon Aug 31 19:34:06 2015
@@ -29,11 +29,9 @@ public aspect CoreTypedAttributeSupport
         this.type = type;
     }
     
-    public final <T> CoreNode CoreTypedAttribute.shallowClone(ClonePolicy<T>
policy, T options) {
-        CoreTypedAttribute clone = (CoreTypedAttribute)coreGetNodeFactory().createNode(
-                policy.preserveModel(options) ? coreGetNodeClass() : coreGetNodeType().getInterface());
-        clone.initName(this);
-        clone.coreSetType(coreGetType());
-        return clone;
+    public final <T> void CoreTypedAttribute.init(ClonePolicy<T> policy, T options,
CoreNode other) {
+        CoreTypedAttribute o = (CoreTypedAttribute)other;
+        initName(o);
+        coreSetType(o.coreGetType());
     }
 }

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=1700312&r1=1700311&r2=1700312&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
Mon Aug 31 19:34:06 2015
@@ -62,7 +62,7 @@ public final class Policies {
     
     public static final ClonePolicy<OMCloneOptions> CLONE_POLICY = new ClonePolicy<OMCloneOptions>()
{
         public boolean preserveModel(OMCloneOptions options) {
-            return options.isPreserveModel();
+            return options != null && options.isPreserveModel();
         }
 
         public boolean repairNamespaces(OMCloneOptions options) {



Mime
View raw message