jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1469360 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: plugins/memory/MemoryNodeBuilder.java spi/state/NodeBuilder.java spi/state/ReadOnlyBuilder.java
Date Thu, 18 Apr 2013 15:04:56 GMT
Author: jukka
Date: Thu Apr 18 15:04:55 2013
New Revision: 1469360

URL: http://svn.apache.org/r1469360
Log:
OAK-781: Clarify / fix effects of MISSING_NODE as base state of NodeBuilder

Add exists(), getChild() and addChild() methods to NodeBuilder

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeBuilder.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ReadOnlyBuilder.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java?rev=1469360&r1=1469359&r2=1469360&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java
Thu Apr 18 15:04:55 2013
@@ -191,7 +191,8 @@ public class MemoryNodeBuilder implement
      * Determine whether this child exists at its direct parent.
      * @return {@code true} iff this child exists at its direct parent.
      */
-    private boolean exists() {
+    @Override // TODO: Check that the implementation matches NodeBuilder.exists()
+    public boolean exists() {
         if (isRoot()) {
             return true;
         } else if (parent.writeState == null) {
@@ -502,6 +503,18 @@ public class MemoryNodeBuilder implement
         return builder;
     }
 
+    @Override @Nonnull
+    public NodeBuilder getChild(@Nonnull String name) {
+        throw new UnsupportedOperationException(); // TODO
+    }
+
+    @Override @Nonnull
+    public NodeBuilder addChild(@Nonnull String name) {
+        // TODO: better implementation?
+        setNode(name, EMPTY_NODE);
+        return child(name);
+    }
+
     /**
      * The <em>mutable</em> state being built. Instances of this class
      * are never passed beyond the containing {@code MemoryNodeBuilder},

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeBuilder.java?rev=1469360&r1=1469359&r2=1469360&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeBuilder.java
Thu Apr 18 15:04:55 2013
@@ -47,6 +47,13 @@ public interface NodeBuilder {
     NodeState getBaseState();
 
     /**
+     * Checks whether this builder represents a node that exists.
+     *
+     * @return {@code true} if the node exists, {@code false} otherwise
+     */
+    boolean exists();
+
+    /**
      * Check whether this builder represents a new node, which is not present in the base
state.
      * @return  {@code true} for a new node
      */
@@ -277,4 +284,28 @@ public interface NodeBuilder {
     @Nonnull
     NodeBuilder child(@Nonnull String name);
 
+    /**
+     * Returns a builder for constructing changes to the named child node.
+     * If the named child node does not already exist, the returned builder
+     * will refer to a non-existent node and trying to modify it will cause
+     * {@link IllegalStateException}s to be thrown.
+     *
+     * @since Oak 0.7
+     * @param name name of the child node
+     * @return child builder, possibly non-existent
+     */
+    @Nonnull
+    NodeBuilder getChild(@Nonnull String name);
+
+    /**
+     * Adds the named child node and returns a builder for modifying it.
+     * Possible previous content in the named subtree is removed.
+     *
+     * @since Oak 0.7
+     * @param name name of the child node
+     * @return child builder
+     */
+    @Nonnull
+    NodeBuilder addChild(@Nonnull String name);
+
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ReadOnlyBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ReadOnlyBuilder.java?rev=1469360&r1=1469359&r2=1469360&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ReadOnlyBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ReadOnlyBuilder.java
Thu Apr 18 15:04:55 2013
@@ -39,6 +39,11 @@ public class ReadOnlyBuilder implements 
     }
 
     @Override
+    public boolean exists() {
+        return state.exists();
+    }
+
+    @Override
     public boolean isNew() {
         return false;
     }
@@ -158,4 +163,14 @@ public class ReadOnlyBuilder implements 
         }
     }
 
+    @Override @Nonnull
+    public NodeBuilder getChild(@Nonnull String name) {
+        return new ReadOnlyBuilder(state.getChildNode(name));
+    }
+
+    @Override @Nonnull
+    public NodeBuilder addChild(@Nonnull String name) {
+        throw unsupported();
+    }
+
 }



Mime
View raw message