jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r793046 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id: ItemId.java NodeId.java PropertyId.java
Date Fri, 10 Jul 2009 17:21:53 GMT
Author: jukka
Date: Fri Jul 10 17:21:53 2009
New Revision: 793046

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

Make NodeId extend UUID.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/ItemId.java
    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/id/PropertyId.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/ItemId.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/ItemId.java?rev=793046&r1=793045&r2=793046&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/ItemId.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/ItemId.java
Fri Jul 10 17:21:53 2009
@@ -19,24 +19,23 @@
 import java.io.Serializable;
 
 /**
- * <code>ItemId</code> serves as the base class for the concrete classes
- * <code>PropertyId</code> and <code>NodeId</code> who uniquely identify
- * nodes and properties in a workspace.
+ * Node or property identifier. All content items in a Jackrabbit repository
+ * have an identifier that uniquely identifies the item in a workspace.
+ * <p>
+ * This interface is implemented by both the concrete node and property
+ * identifier classes in order to allow client code to determine whether
+ * an identifier refers to a node or a property.
  */
-public abstract class ItemId implements Serializable {
-
-    /** Serialization UID of this class. */
-    static final long serialVersionUID = -5138008726453328226L;
+public interface ItemId extends Serializable {
 
     /**
-     * Returns <code>true</code> if this id denotes a <code>Node</code>.
+     * Checks whether this identifier denotes a node item.
      *
-     * @return <code>true</code> if this id denotes a <code>Node</code>,
-     *         <code>false</code> if it denotes a <code>Property</code>
+     * @return <code>true</code> if this identifier denotes a node,
+     *         <code>false</code> if a property
      * @see PropertyId
      * @see NodeId
      */
-    public abstract boolean denotesNode();
+    boolean denotesNode();
 
 }
-

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=793046&r1=793045&r2=793046&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
Fri Jul 10 17:21:53 2009
@@ -22,16 +22,12 @@
  * 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 implements Comparable<NodeId> {
+public class NodeId extends UUID implements ItemId {
 
-    /** Serial version UID of this class. */
-    static final long serialVersionUID = 7380115476447060008L;
-
-    /** UUID of the identified node */
-    private final UUID uuid;
-
-    /** the precalculated hashcode */
-    private final int hashCode;
+    /**
+     * The serial version UID.
+     */
+    private static final long serialVersionUID = 7348217305215708805L;
 
     /**
      * Creates a node identifier instance for the identified node.
@@ -39,11 +35,7 @@
      * @param uuid node UUID
      */
     public NodeId(UUID uuid) {
-        if (uuid == null) {
-            throw new IllegalArgumentException("uuid can not be null");
-        }
-        this.uuid = uuid;
-        this.hashCode = uuid.hashCode();
+        super(uuid.getMostSignificantBits(), uuid.getLeastSignificantBits());
     }
 
     /**
@@ -53,15 +45,15 @@
      * @throws IllegalArgumentException if the UUID string is invalid
      */
     public NodeId(String uuid) throws IllegalArgumentException {
-        this(new UUID(uuid));
+        super(uuid);
     }
 
     public NodeId(byte[] bytes) {
-        this(new UUID(bytes));
+        super(bytes);
     }
 
     public NodeId(long msb, long lsb) {
-        this(new UUID(msb, lsb));
+        super(msb, lsb);
     }
 
     /**
@@ -81,7 +73,7 @@
      * @return node UUID
      */
     public UUID getUUID() {
-        return uuid;
+        return this;
     }
 
     /**
@@ -100,78 +92,7 @@
         if (s == null) {
             throw new IllegalArgumentException("invalid NodeId literal");
         }
-        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();
-    }
-
-    /**
-     * Returns the most significant bits of the UUID.
-     *
-     * @return most significant 64 bits
-     */
-    public long getMostSignificantBits() {
-        return uuid.getMostSignificantBits();
-    }
-
-    /**
-     * Returns the least significant bits of the UUID.
-     *
-     * @return least significant 64 bits
-     */
-    public long getLeastSignificantBits() {
-        return uuid.getLeastSignificantBits();
-    }
-
-    //----------------------------------------------------------< 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}
-     */
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj instanceof NodeId) {
-            return uuid.equals(((NodeId) obj).uuid);
-        }
-        return false;
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * Returns the same as <code>this.getUUID().toString()</code>
-     */
-    public String toString() {
-        return uuid.toString();
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * Returns the same as <code>this.getUUID().hashCode()</code>
-     */
-    public int hashCode() {
-        return hashCode;
+        return new NodeId(s);
     }
 
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/PropertyId.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/PropertyId.java?rev=793046&r1=793045&r2=793046&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/PropertyId.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/id/PropertyId.java
Fri Jul 10 17:21:53 2009
@@ -24,7 +24,7 @@
  * property using the UUID of the parent node and the name of
  * the property. Once created a property identifier instance is immutable.
  */
-public class PropertyId extends ItemId {
+public class PropertyId implements ItemId {
 
     /** Serial version UID of this class. */
     static final long serialVersionUID = 1118783735407446009L;



Mime
View raw message