jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1468338 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ oak-cor...
Date Tue, 16 Apr 2013 09:39:20 GMT
Author: jukka
Date: Tue Apr 16 09:39:19 2013
New Revision: 1468338

URL: http://svn.apache.org/r1468338
Log:
OAK-776: NodeState convenience accessors

Add NodeState.getBoolean(String) and NodeBuilder.hasProperty(String)

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/ContentMirrorStoreStrategy.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyNodeState.java
    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/plugins/nodetype/RegistrationEditor.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditor.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MergeDiff.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHook.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeState.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/NodeState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ReadOnlyBuilder.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/ContentMirrorStoreStrategyTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java
    jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexUpdate.java
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexUpdate.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java?rev=1468338&r1=1468337&r2=1468338&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
Tue Apr 16 09:39:19 2013
@@ -568,7 +568,7 @@ public class TreeImpl implements Tree {
      *         {@code false} otherwise.
      */
     private boolean hasOrderableChildren() {
-        return internalGetProperty(OAK_CHILD_ORDER) != null;
+        return nodeBuilder.hasProperty(OAK_CHILD_ORDER);
     }
 
     /**
@@ -611,8 +611,7 @@ public class TreeImpl implements Tree {
      * of the children as returned by {@link NodeBuilder#getChildNodeNames()}.
      */
     private void ensureChildOrderProperty() {
-        PropertyState childOrder = nodeBuilder.getProperty(OAK_CHILD_ORDER);
-        if (childOrder == null) {
+        if (!nodeBuilder.hasProperty(OAK_CHILD_ORDER)) {
             nodeBuilder.setProperty(
                     MultiStringPropertyState.stringProperty(OAK_CHILD_ORDER, nodeBuilder.getChildNodeNames()));
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/ContentMirrorStoreStrategy.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/ContentMirrorStoreStrategy.java?rev=1468338&r1=1468337&r2=1468338&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/ContentMirrorStoreStrategy.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/ContentMirrorStoreStrategy.java
Tue Apr 16 09:39:19 2013
@@ -25,8 +25,6 @@ import java.util.Set;
 import java.util.TreeMap;
 
 import org.apache.jackrabbit.oak.api.CommitFailedException;
-import org.apache.jackrabbit.oak.api.PropertyState;
-import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.query.Filter;
@@ -115,7 +113,7 @@ public class ContentMirrorStoreStrategy 
         // finally prune the index node
         pruneNode(child);
         if (child.getChildNodeCount() == 0
-                && child.getProperty("match") == null) {
+                && !child.hasProperty("match")) {
             index.removeNode(key);
         }
     }
@@ -127,7 +125,7 @@ public class ContentMirrorStoreStrategy 
         for (String name : parent.getChildNodeNames()) {
             NodeBuilder segment = parent.child(name);
             if (segment.getChildNodeCount() == 0
-                    && segment.getProperty("match") == null) {
+                    && !segment.hasProperty("match")) {
                 parent.removeNode(name);
             }
         }
@@ -201,11 +199,6 @@ public class ContentMirrorStoreStrategy 
         }
         return count;
     }
-    
-    static boolean matches(NodeState state) {
-        PropertyState ps = state.getProperty("match");
-        return ps != null && !ps.isArray() && ps.getValue(Type.BOOLEAN);
-    }
 
     /**
      * An iterator over paths within an index node.
@@ -274,7 +267,7 @@ public class ContentMirrorStoreStrategy 
                     nodeIterators.addLast(node.getChildNodeEntries().iterator());
                     parentPath = currentPath;
 
-                    if (matches(node)) {
+                    if (node.getBoolean("match")) {
                         return;
                     }
                     

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyNodeState.java?rev=1468338&r1=1468337&r2=1468338&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyNodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/EmptyNodeState.java
Tue Apr 16 09:39:19 2013
@@ -66,6 +66,11 @@ public final class EmptyNodeState implem
         return null;
     }
 
+    @Override
+    public boolean getBoolean(String name) {
+        return false;
+    }
+
     @Override @Nonnull
     public Iterable<? extends PropertyState> getProperties() {
         return Collections.emptyList();

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=1468338&r1=1468337&r2=1468338&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
Tue Apr 16 09:39:19 2013
@@ -424,6 +424,11 @@ public class MemoryNodeBuilder implement
     }
 
     @Override
+    public boolean hasProperty(String name) {
+        return read().hasProperty(name);
+    }
+
+    @Override
     public PropertyState getProperty(String name) {
         return read().getProperty(name);
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/RegistrationEditor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/RegistrationEditor.java?rev=1468338&r1=1468337&r2=1468338&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/RegistrationEditor.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/RegistrationEditor.java
Tue Apr 16 09:39:19 2013
@@ -109,7 +109,7 @@ class RegistrationEditor extends Default
      */
     private void mergeSupertypes(NodeBuilder types, NodeBuilder type)
             throws CommitFailedException {
-        if (type.getProperty(OAK_SUPERTYPES) == null) {
+        if (!type.hasProperty(OAK_SUPERTYPES)) {
             List<String> empty = Collections.emptyList();
             type.setProperty(OAK_SUPERTYPES, empty, NAMES);
 
@@ -275,8 +275,7 @@ class RegistrationEditor extends Default
             definitions = definitions.child(escapedName);
 
             // - jcr:mandatory (BOOLEAN) protected mandatory
-            PropertyState mandatory = definition.getProperty(JCR_MANDATORY);
-            if (mandatory != null && mandatory.getValue(BOOLEAN)) {
+            if (definition.getBoolean(JCR_MANDATORY)) {
                 addNameToList(type, OAK_MANDATORY_PROPERTIES, propertyName);
             }
         } else {
@@ -296,8 +295,7 @@ class RegistrationEditor extends Default
         }
 
         // - jcr:multiple (BOOLEAN) protected mandatory
-        PropertyState multiple = definition.getProperty(JCR_MULTIPLE);
-        if (multiple != null && multiple.getValue(BOOLEAN)) {
+        if (definition.getBoolean(JCR_MULTIPLE)) {
             if ("BINARY".equals(key)) {
                 key = "BINARIES";
             } else {
@@ -324,8 +322,7 @@ class RegistrationEditor extends Default
             definitions = definitions.child(childNodeName);
 
             // - jcr:mandatory (BOOLEAN) protected mandatory
-            PropertyState mandatory = definition.getProperty(JCR_MANDATORY);
-            if (mandatory != null && mandatory.getValue(BOOLEAN)) {
+            if (definition.getBoolean(JCR_MANDATORY)) {
                 addNameToList(type, OAK_MANDATORY_CHILD_NODES, childNodeName);
             }
         } else {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditor.java?rev=1468338&r1=1468337&r2=1468338&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditor.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditor.java
Tue Apr 16 09:39:19 2013
@@ -24,7 +24,6 @@ import static org.apache.jackrabbit.JcrC
 import static org.apache.jackrabbit.JcrConstants.JCR_REQUIREDTYPE;
 import static org.apache.jackrabbit.JcrConstants.JCR_VALUECONSTRAINTS;
 import static org.apache.jackrabbit.oak.api.CommitFailedException.CONSTRAINT;
-import static org.apache.jackrabbit.oak.api.Type.BOOLEAN;
 import static org.apache.jackrabbit.oak.api.Type.NAME;
 import static org.apache.jackrabbit.oak.api.Type.NAMES;
 import static org.apache.jackrabbit.oak.api.Type.STRING;
@@ -244,10 +243,10 @@ class TypeEditor extends DefaultEditor {
             if (!type.exists()) {
                 throw constraintViolation(
                         6, "Primary node type " + name + " does not exist");
-            } else if (getBoolean(type, JCR_ISMIXIN)) {
+            } else if (type.getBoolean(JCR_ISMIXIN)) {
                 throw constraintViolation(
                         7, "Can not use mixin type " + name + " as primary");
-            } else if (getBoolean(type, JCR_IS_ABSTRACT)) {
+            } else if (type.getBoolean(JCR_IS_ABSTRACT)) {
                 throw constraintViolation(
                         8, "Can not use abstract type " + name + " as primary");
             }
@@ -265,10 +264,10 @@ class TypeEditor extends DefaultEditor {
                 if (!type.exists()) {
                     throw constraintViolation(
                             9, "Mixin node type " + name + " does not exist");
-                } else if (!getBoolean(type, JCR_ISMIXIN)) {
+                } else if (!type.getBoolean(JCR_ISMIXIN)) {
                     throw constraintViolation(
                             10, "Can not use primary type " + name + " as mixin");
-                } else if (getBoolean(type, JCR_IS_ABSTRACT)) {
+                } else if (type.getBoolean(JCR_IS_ABSTRACT)) {
                     throw constraintViolation(
                             11, "Can not use abstract type " + name + " as mixin");
                 }
@@ -280,11 +279,4 @@ class TypeEditor extends DefaultEditor {
         effective = new EffectiveType(list);
     }
 
-    private boolean getBoolean(NodeState node, String name) {
-        PropertyState property = node.getProperty(name);
-        return property != null
-                && property.getType() == BOOLEAN
-                && property.getValue(BOOLEAN);
-    }
-
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MergeDiff.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MergeDiff.java?rev=1468338&r1=1468337&r2=1468338&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MergeDiff.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MergeDiff.java
Tue Apr 16 09:39:19 2013
@@ -31,8 +31,7 @@ class MergeDiff implements NodeStateDiff
 
     @Override
     public void propertyAdded(PropertyState after) {
-        PropertyState other = builder.getProperty(after.getName());
-        if (other == null) {
+        if (!builder.hasProperty(after.getName())) {
             builder.setProperty(after);
         }
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java?rev=1468338&r1=1468337&r2=1468338&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java
Tue Apr 16 09:39:19 2013
@@ -113,7 +113,7 @@ class ReadWriteVersionManager extends Re
         for (Iterator<String> it = PathUtils.elements(relPath).iterator(); it.hasNext();
) {
             String name = it.next();
             node = node.child(name);
-            if (node.getProperty(JCR_PRIMARYTYPE) == null) {
+            if (!node.hasProperty(JCR_PRIMARYTYPE)) {
                 String nt;
                 if (it.hasNext()) {
                     nt = REP_VERSIONSTORAGE;
@@ -154,7 +154,7 @@ class ReadWriteVersionManager extends Re
                     IdentifierManager.generateUUID(), Type.STRING);
             frozenNode.setProperty(JCR_PRIMARYTYPE, NT_FROZENNODE, Type.NAME);
             Iterable<String> mixinTypes;
-            if (versionable.getProperty(JCR_MIXINTYPES) != null) {
+            if (versionable.hasProperty(JCR_MIXINTYPES)) {
                 mixinTypes = versionable.getProperty(JCR_MIXINTYPES).getValue(Type.NAMES);
             } else {
                 mixinTypes = Collections.emptyList();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java?rev=1468338&r1=1468337&r2=1468338&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java
Tue Apr 16 09:39:19 2013
@@ -75,7 +75,7 @@ public class VersionablePathHook impleme
                     && nodeAfter.isVersionable(versionManager)) {
                 NodeBuilder vhBuilder = versionManager.getOrCreateVersionHistory(nodeAfter.builder);
 
-                if (vhBuilder.getProperty(JcrConstants.JCR_MIXINTYPES) == null) {
+                if (!vhBuilder.hasProperty(JcrConstants.JCR_MIXINTYPES)) {
                     vhBuilder.setProperty(
                             JcrConstants.JCR_MIXINTYPES,
                             ImmutableSet.of(MIX_REP_VERSIONABLE_PATHS),

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHook.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHook.java?rev=1468338&r1=1468337&r2=1468338&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHook.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHook.java
Tue Apr 16 09:39:19 2013
@@ -87,7 +87,7 @@ public class PermissionHook implements P
     @Nonnull
     private NodeBuilder getPermissionRoot(NodeBuilder rootBuilder) {
         NodeBuilder permissionStore = rootBuilder.child(JCR_SYSTEM).child(REP_PERMISSION_STORE);
-        if (permissionStore.getProperty(JCR_PRIMARYTYPE) == null) {
+        if (!permissionStore.hasProperty(JCR_PRIMARYTYPE)) {
             permissionStore.setProperty(JCR_PRIMARYTYPE, NT_REP_PERMISSION_STORE, Type.NAME);
         }
         NodeBuilder permissionRoot;
@@ -337,7 +337,7 @@ public class PermissionHook implements P
 
         private void writeTo(NodeBuilder permissionRoot) {
             NodeBuilder principalRoot = permissionRoot.child(principalName);
-            if (principalRoot.getProperty(JCR_PRIMARYTYPE) == null) {
+            if (!principalRoot.hasProperty(JCR_PRIMARYTYPE)) {
                 principalRoot.setProperty(JCR_PRIMARYTYPE, NT_REP_PERMISSION_STORE, Type.NAME);
             }
             NodeBuilder entry = principalRoot.child(nodeName)

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeState.java?rev=1468338&r1=1468337&r2=1468338&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeState.java
Tue Apr 16 09:39:19 2013
@@ -16,12 +16,15 @@
  */
 package org.apache.jackrabbit.oak.spi.state;
 
+import static org.apache.jackrabbit.oak.api.Type.BOOLEAN;
+
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
 
 import com.google.common.base.Function;
 import com.google.common.collect.Iterables;
+
 import org.apache.jackrabbit.oak.api.PropertyState;
 
 /**
@@ -45,6 +48,13 @@ public abstract class AbstractNodeState 
     }
 
     @Override
+    public boolean getBoolean(String name) {
+        PropertyState property = getProperty(name);
+        return property != null
+                && property.getType() == BOOLEAN
+                && property.getValue(BOOLEAN);
+    }
+    @Override
     public PropertyState getProperty(String name) {
         for (PropertyState property : getProperties()) {
             if (name.equals(property.getName())) {

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=1468338&r1=1468337&r2=1468338&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
Tue Apr 16 09:39:19 2013
@@ -143,6 +143,17 @@ public interface NodeBuilder {
     Iterable<? extends PropertyState> getProperties();
 
     /**
+     * Checks whether the named property exists. The implementation is
+     * equivalent to {@code getProperty(name) != null}, but may be optimized
+     * to avoid having to load the property value.
+     *
+     * @param name property name
+     * @return {@code true} if the named property exists,
+     *         {@code false} otherwise
+     */
+    boolean hasProperty(String name);
+
+    /**
      * Returns the current state of the named property, or {@code null}
      * if the property is not set.
      *

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeState.java?rev=1468338&r1=1468337&r2=1468338&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeState.java
Tue Apr 16 09:39:19 2013
@@ -151,7 +151,22 @@ public interface NodeState {
      * @return named property, or {@code null} if not found
      */
     @CheckForNull
-    PropertyState getProperty(String name);
+    PropertyState getProperty(@Nonnull String name);
+
+    /**
+     * Returns the boolean value of the named property. The implementation
+     * is equivalent to the following code, but may be optimized.
+     * <pre>
+     * PropertyState property = state.getProperty(name);
+     * return property != null
+     *     && property.getType() == Type.BOOLEAN
+     *     && property.getValue(Type.BOOLEAN);
+     * </pre>
+     *
+     * @param name property name
+     * @return boolean value of the named property, or {@code false}
+     */
+    boolean getBoolean(@Nonnull String name);
 
     /**
      * Returns the number of properties of this node.

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=1468338&r1=1468337&r2=1468338&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
Tue Apr 16 09:39:19 2013
@@ -103,6 +103,11 @@ public class ReadOnlyBuilder implements 
     }
 
     @Override
+    public boolean hasProperty(String name) {
+        return state.hasProperty(name);
+    }
+
+    @Override
     public PropertyState getProperty(String name) {
         return state.getProperty(name);
     }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerTest.java?rev=1468338&r1=1468337&r2=1468338&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerTest.java
Tue Apr 16 09:39:19 2013
@@ -129,7 +129,7 @@ public class IndexHookManagerTest {
         checkPathExists(ns, ":index");
         PropertyState ps = ns.getProperty(REINDEX_PROPERTY_NAME);
         assertNotNull(ps);
-        assertFalse(ps.getValue(Type.BOOLEAN).booleanValue());
+        assertFalse(ps.getValue(Type.BOOLEAN));
 
         // next, lookup
         Property2IndexLookup lookup = new Property2IndexLookup(indexed);
@@ -168,7 +168,7 @@ public class IndexHookManagerTest {
         checkPathExists(ns, ":index");
         PropertyState ps = ns.getProperty(REINDEX_PROPERTY_NAME);
         assertNotNull(ps);
-        assertFalse(ps.getValue(Type.BOOLEAN).booleanValue());
+        assertFalse(ps.getValue(Type.BOOLEAN));
 
         // next, lookup
         Property2IndexLookup lookup = new Property2IndexLookup(indexed);
@@ -208,7 +208,7 @@ public class IndexHookManagerTest {
         checkPathExists(ns, ":index");
         PropertyState ps = ns.getProperty(REINDEX_PROPERTY_NAME);
         assertNotNull(ps);
-        assertFalse(ps.getValue(Type.BOOLEAN).booleanValue());
+        assertFalse(ps.getValue(Type.BOOLEAN));
 
         // next, lookup
         Property2IndexLookup lookup = new Property2IndexLookup(indexed);

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/ContentMirrorStoreStrategyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/ContentMirrorStoreStrategyTest.java?rev=1468338&r1=1468337&r2=1468338&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/ContentMirrorStoreStrategyTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/strategy/ContentMirrorStoreStrategyTest.java
Tue Apr 16 09:39:19 2013
@@ -97,7 +97,7 @@ public class ContentMirrorStoreStrategyT
             check = check.child(p);
         }
         if (checkMatch) {
-            Assert.assertNotNull(check.getProperty("match"));
+            Assert.assertTrue(check.hasProperty("match"));
         }
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java?rev=1468338&r1=1468337&r2=1468338&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java
Tue Apr 16 09:39:19 2013
@@ -52,9 +52,9 @@ public class MemoryNodeBuilderTest {
         NodeBuilder childA = root.child("x");
         NodeBuilder childB = root.child("x");
 
-        assertNull(childA.getProperty("test"));
+        assertFalse(childA.hasProperty("test"));
         childB.setProperty("test", "foo");
-        assertNotNull(childA.getProperty("test"));
+        assertTrue(childA.hasProperty("test"));
     }
 
     @Test
@@ -79,8 +79,8 @@ public class MemoryNodeBuilderTest {
         childB.setProperty("test", "foo");
 
         childA.removeProperty("test");
-        assertNull(childA.getProperty("test"));
-        assertNull(childB.getProperty("test"));
+        assertFalse(childA.hasProperty("test"));
+        assertFalse(childB.hasProperty("test"));
 
         childA.setProperty("test", "bar");
         assertEquals("bar", childA.getProperty("test").getValue(STRING));

Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexUpdate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexUpdate.java?rev=1468338&r1=1468337&r2=1468338&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexUpdate.java
(original)
+++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexUpdate.java
Tue Apr 16 09:39:19 2013
@@ -119,9 +119,8 @@ class LuceneIndexUpdate implements Close
     }
 
     boolean getAndResetReindexFlag() {
-        boolean reindex = index.getProperty(REINDEX_PROPERTY_NAME) != null
-                && index.getProperty(REINDEX_PROPERTY_NAME).getValue(
-                        Type.BOOLEAN);
+        PropertyState property = index.getProperty(REINDEX_PROPERTY_NAME);
+        boolean reindex = property != null && property.getValue(Type.BOOLEAN);
         index.setProperty(REINDEX_PROPERTY_NAME, false);
         return reindex;
     }

Modified: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexUpdate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexUpdate.java?rev=1468338&r1=1468337&r2=1468338&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexUpdate.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexUpdate.java
Tue Apr 16 09:39:19 2013
@@ -80,9 +80,8 @@ public class SolrIndexUpdate implements 
     }
 
     boolean getAndResetReindexFlag() {
-        boolean reindex = index.getProperty("reindex") != null
-                && index.getProperty("reindex").getValue(
-                Type.BOOLEAN);
+        boolean reindex = index.hasProperty("reindex")
+                && index.getProperty("reindex").getValue(Type.BOOLEAN);
         index.setProperty("reindex", false);
         return reindex;
     }



Mime
View raw message