jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r792498 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/id/ main/java/org/apache/jackrabbit/core/journal/ main/java/org/apache/jackrabbit/core/persistence/bundle/util/ main/java/org/apache/jackrabbit/core/pe...
Date Thu, 09 Jul 2009 11:05:11 GMT
Author: jukka
Date: Thu Jul  9 11:05:11 2009
New Revision: 792498

URL: http://svn.apache.org/viewvc?rev=792498&view=rev
Log:
JCR-1232: Merge UUID to NodeId

Implement NodeId.getRawBytes() and NodeId.compareTo(NodeId) so we can remove even more calls
to Node.getUUID().

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/NodeId.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/PersistenceManagerIteratorTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/NodeId.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/NodeId.java?rev=792498&r1=792497&r2=792498&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/NodeId.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/NodeId.java
Thu Jul  9 11:05:11 2009
@@ -22,7 +22,7 @@
  * Node identifier. An instance of this class identifies a node using its UUID.
  * Once created a node identifier instance is immutable.
  */
-public class NodeId extends ItemId {
+public class NodeId extends ItemId implements Comparable<NodeId> {
 
     /** Serial version UID of this class. */
     static final long serialVersionUID = 7380115476447060008L;
@@ -95,6 +95,27 @@
         return new NodeId(new UUID(s));
     }
 
+    /**
+     * Returns a (new) array containing the raw bytes that make up this UUID.
+     *
+     * @return raw bytes of the UUID
+     */
+    public byte[] getRawBytes() {
+        return uuid.getRawBytes();
+    }
+
+    //----------------------------------------------------------< Comparable >
+
+    /**
+     * Compares this node id to the given other identifier.
+     *
+     * @param that the other identifier for the comparison
+     * @return result of comparison
+     */
+    public int compareTo(NodeId that) {
+        return uuid.compareTo(that.uuid);
+    }
+
     //-------------------------------------------< java.lang.Object overrides >
     /**
      * {@inheritDoc}
@@ -126,4 +147,5 @@
     public int hashCode() {
         return hashCode;
     }
+
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java?rev=792498&r1=792497&r2=792498&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java
Thu Jul  9 11:05:11 2009
@@ -129,7 +129,7 @@
                 writeInt(index);
             } else {
                 writeByte(UUID_LITERAL);
-                write(nodeId.getUUID().getRawBytes());
+                write(nodeId.getRawBytes());
             }
         }
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java?rev=792498&r1=792497&r2=792498&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ItemStateBinding.java
Thu Jul  9 11:05:11 2009
@@ -312,7 +312,7 @@
             out.writeBoolean(false);
         } else {
             out.writeBoolean(true);
-            out.write(UUID.fromString(id).getRawBytes());
+            out.write(new NodeId(id).getRawBytes());
         }
     }
 
@@ -377,7 +377,7 @@
             out.writeBoolean(false);
         } else {
             out.writeBoolean(true);
-            out.write(id.getUUID().getRawBytes());
+            out.write(id.getRawBytes());
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java?rev=792498&r1=792497&r2=792498&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java
Thu Jul  9 11:05:11 2009
@@ -80,7 +80,7 @@
         if (state.getParentId() == null) {
             out.write(NULL_UUID_PLACEHOLDER_BYTES);
         } else {
-            out.write(state.getParentId().getUUID().getRawBytes());
+            out.write(state.getParentId().getRawBytes());
         }
         // definitionId
         out.writeUTF(state.getDefinitionId().toString());
@@ -105,7 +105,7 @@
         for (Iterator<ChildNodeEntry> iter = collChildren.iterator(); iter.hasNext();)
{
             ChildNodeEntry entry = iter.next();
             out.writeUTF(entry.getName().toString());   // name
-            out.write(entry.getId().getUUID().getRawBytes());    // uuid
+            out.write(entry.getId().getRawBytes());    // uuid
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/PersistenceManagerIteratorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/PersistenceManagerIteratorTest.java?rev=792498&r1=792497&r2=792498&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/PersistenceManagerIteratorTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/PersistenceManagerIteratorTest.java
Thu Jul  9 11:05:11 2009
@@ -94,7 +94,7 @@
                         first = id;
                     }
                     if (after != null) {
-                        assertFalse(id.getUUID().compareTo(after.getUUID()) == 0);
+                        assertFalse(id.compareTo(after) == 0);
                     }
                     after = id;
                 }
@@ -111,7 +111,7 @@
                     while (it.hasNext()) {
                         NodeId id = it.next();
                         log("    " + id);
-                        assertFalse(id.getUUID().compareTo(after.getUUID()) == 0);
+                        assertFalse(id.compareTo(after) == 0);
                         after = id;
                     }
                 }
@@ -122,7 +122,7 @@
                     log(" bigger than: " + after);
                     for (NodeId id : apm.getAllNodeIds(after, 2)) {
                         log("    " + id);
-                        assertFalse(id.getUUID().compareTo(after.getUUID()) == 0);
+                        assertFalse(id.compareTo(after) == 0);
                         after = id;
                     }
                 }



Mime
View raw message