jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1220418 - in /jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy: ChildNodeAttic.java NodeEntry.java
Date Sun, 18 Dec 2011 14:58:03 GMT
Author: mduerig
Date: Sun Dec 18 14:58:03 2011
New Revision: 1220418

URL: http://svn.apache.org/viewvc?rev=1220418&view=rev
Log:
Microkernel based Jackrabbit prototype (WIP)
refactor: simplify ChildNodeAttic

Modified:
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeAttic.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeAttic.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeAttic.java?rev=1220418&r1=1220417&r2=1220418&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeAttic.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeAttic.java
Sun Dec 18 14:58:03 2011
@@ -20,8 +20,8 @@ import org.apache.jackrabbit.spi.Name;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.HashSet;
-import java.util.Set;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * {@code ChildNodeAttic}...
@@ -29,29 +29,19 @@ import java.util.Set;
 class ChildNodeAttic {
     private static final Logger log = LoggerFactory.getLogger(ChildNodeAttic.class);
 
-    private final Set<NodeEntry> attic = new HashSet<NodeEntry>();
+    private final Map<Name, NodeEntry> attic = new HashMap<Name, NodeEntry>();
 
     boolean isEmpty() {
         return attic.isEmpty();
     }
 
     boolean contains(Name name) {
-        for (NodeEntry ne : attic) {
-            if (ne.matches(name)) {
-                return true;
-            }
-        }
-        return false;
+        return attic.containsKey(name);
     }
 
     boolean contains(Name name, String uniqueId) {
-        for (NodeEntry ne : attic) {
-            if (uniqueId != null && uniqueId.equals(ne.getUniqueID()) || ne.matches(name))
{
-                return true;
-            }
-        }
-        // not found
-        return false;
+        NodeEntry nodeEntry = attic.get(name);
+        return nodeEntry != null && uniqueId.equals(nodeEntry.getUniqueID());
     }
 
     /**
@@ -59,13 +49,7 @@ class ChildNodeAttic {
      * @return
      */
     NodeEntry get(Name name) {
-        for (NodeEntry ne : attic) {
-            if (ne.matches(name)) {
-                return ne;
-            }
-        }
-        // not found
-        return null;
+        return attic.get(name);
     }
 
     /**
@@ -79,7 +63,7 @@ class ChildNodeAttic {
             log.error(e.getMessage(), e);
             throw e;
         }
-        for (NodeEntry ne : attic) {
+        for (NodeEntry ne : attic.values()) {
             if (uniqueId.equals(ne.getUniqueID())) {
                 return ne;
             }
@@ -89,11 +73,11 @@ class ChildNodeAttic {
     }
 
     void add(NodeEntry movedEntry) {
-        attic.add(movedEntry);
+        attic.put(movedEntry.getName(true), movedEntry);
     }
 
-    boolean remove(NodeEntry movedEntry) {
-        return attic.remove(movedEntry);
+    void remove(NodeEntry movedEntry) {
+        attic.remove(movedEntry.getName(true));
     }
 
 }
\ No newline at end of file

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java?rev=1220418&r1=1220417&r2=1220418&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
Sun Dec 18 14:58:03 2011
@@ -1122,7 +1122,7 @@ public class NodeEntry extends Hierarchy
     }
 
 
-    private Name getName(boolean wspName) {
+    Name getName(boolean wspName) {
         if (wspName && revertInfo != null) {
             return revertInfo.oldName;
         } else {
@@ -1536,7 +1536,7 @@ public class NodeEntry extends Hierarchy
         }
 
         private boolean isMoved() {
-            return oldParent != getParent() || !getName().equals(oldName);
+            return oldParent != parent || !oldName.equals(name);
         }
 
         private void dispose() {



Mime
View raw message