jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1326676 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel: KernelBranch.java TransientKernelNodeState.java
Date Mon, 16 Apr 2012 16:29:07 GMT
Author: mduerig
Date: Mon Apr 16 16:29:06 2012
New Revision: 1326676

URL: http://svn.apache.org/viewvc?rev=1326676&view=rev
Log:
OAK-18: Define Oak API 
simplify move and copy

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelBranch.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/TransientKernelNodeState.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelBranch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelBranch.java?rev=1326676&r1=1326675&r2=1326676&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelBranch.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelBranch.java
Mon Apr 16 16:29:06 2012
@@ -66,28 +66,25 @@ public class KernelBranch implements Bra
 
     @Override
     public void move(String sourcePath, String destPath) {
-        TransientKernelNodeState sourceParent = getTransientState(getParentPath(sourcePath));
-        String sourceName = getName(sourcePath);
-        if (sourceParent == null || !sourceParent.hasNode(sourceName)) {
+        TransientKernelNodeState sourceNode = getTransientState(sourcePath);
+        if (sourceNode == null) {
             return;
         }
-        
+
         TransientKernelNodeState destParent = getTransientState(getParentPath(destPath));
         String destName = getName(destPath);
         if (destParent == null || destParent.hasNode(destName)) {
             return;
         }
 
-        sourceParent.move(sourceName, destParent, destName);
-        jsop.append(">\"").append(sourcePath)
-                .append("\":\"").append(destPath).append('"');
+        sourceNode.move(destParent, destName);
+        jsop.append(">\"").append(sourcePath).append("\":\"").append(destPath).append('"');
     }
 
     @Override
     public void copy(String sourcePath, String destPath) {
-        TransientKernelNodeState sourceParent = getTransientState(getParentPath(sourcePath));
-        String sourceName = getName(sourcePath);
-        if (sourceParent == null || !sourceParent.hasNode(sourceName)) {
+        TransientKernelNodeState sourceNode = getTransientState(sourcePath);
+        if (sourceNode == null) {
             return;
         }
 
@@ -97,9 +94,8 @@ public class KernelBranch implements Bra
             return;
         }
 
-        sourceParent.copy(sourceName, destParent, destName);
-        jsop.append("*\"").append(sourcePath).append("\":\"")
-                .append(destPath).append('"');
+        sourceNode.copy(destParent, destName);
+        jsop.append("*\"").append(sourcePath).append("\":\"").append(destPath).append('"');
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/TransientKernelNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/TransientKernelNodeState.java?rev=1326676&r1=1326675&r2=1326676&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/TransientKernelNodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/TransientKernelNodeState.java
Mon Apr 16 16:29:06 2012
@@ -72,7 +72,7 @@ public class TransientKernelNodeState im
     private String name;
 
     /** Parent of this state */
-    private TransientNodeState parent;
+    private TransientKernelNodeState parent;
 
     /**
      * Create a new instance representing the root of a branch.
@@ -89,7 +89,7 @@ public class TransientKernelNodeState im
      * @param parent  the parent state of the state
      * @param name  name of the state
      */
-    private TransientKernelNodeState(KernelBranch branch, TransientNodeState parent, String
name) {
+    private TransientKernelNodeState(KernelBranch branch, TransientKernelNodeState parent,
String name) {
         this(branch, null, parent, name);
     }
 
@@ -101,7 +101,7 @@ public class TransientKernelNodeState im
      * @param name  name of the state
      */
     private TransientKernelNodeState(KernelBranch branch, NodeState persistedState,
-            TransientNodeState parent, String name) {
+            TransientKernelNodeState parent, String name) {
 
         this.branch = branch;
         this.persistentState = persistedState;
@@ -355,9 +355,36 @@ public class TransientKernelNodeState im
         branch.removeProperty(this, name);
     }
 
-//------------------------------------------------------------< internal >---
+    //------------------------------------------------------------< internal >---
 
-    void markNodeRemoved(String name) {
+    /**
+     * Move this node state to the parent node state at {@code destParent}
+     * with the new name {@code destName}.
+     *
+     * @param destParent  new parent for this node state
+     * @param destName  new name for this node state
+     */
+    void move(TransientKernelNodeState destParent, String destName) {
+        parent.markNodeRemoved(name);
+
+        name = destName;
+        parent = destParent;
+        destParent.addedNodes.put(destName, this);
+    }
+
+    /**
+     * Copy this node state to the parent node state at {@code destParent}
+     * with the name {@code destName}.
+     *
+     * @param destParent  parent for the copied node state
+     * @param destName  name for the copied node state
+     */
+    void copy(TransientKernelNodeState destParent, String destName) {
+        destParent.addedNodes.put(destName,
+                new TransientKernelNodeState(this, destParent, destName));
+    }
+
+    private void markNodeRemoved(String name) {
         addedNodes.remove(name);
         if (hasExistingNode(name)) {
             // Mark as removed if removing existing
@@ -365,27 +392,13 @@ public class TransientKernelNodeState im
         }
     }
 
-    void setProperty(PropertyState state) {
+    private void setProperty(PropertyState state) {
         if (hasExistingProperty(state.getName())) {
             removedProperties.add(state.getName());
         }
         addedProperties.put(state.getName(), state);
     }
 
-    void move(String name, TransientKernelNodeState destParent, String destName) {
-        TransientKernelNodeState state = getChildNode(name);
-        markNodeRemoved(name);
-
-        state.name = destName;
-        state.parent = destParent;
-        destParent.addedNodes.put(destName, state);
-    }
-
-    void copy(String name, TransientKernelNodeState destParent, String destName) {
-        destParent.addedNodes.put(destName,
-                new TransientKernelNodeState(getChildNode(name), destParent, destName));
-    }
-
     /**
      * Get a transient node state for a child node state which has
      * an existing underlying persistent node date.



Mime
View raw message