jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r761702 - /jackrabbit/commons/jcr-rmi/trunk/jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/SerialValue.java
Date Fri, 03 Apr 2009 14:48:10 GMT
Author: jukka
Date: Fri Apr  3 14:48:10 2009
New Revision: 761702

URL: http://svn.apache.org/viewvc?rev=761702&view=rev
Log:
JCRRMI-16: SerialValue should implement equals() as specified by JCR

This fixes 19 TCK test failures.

Modified:
    jackrabbit/commons/jcr-rmi/trunk/jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/SerialValue.java

Modified: jackrabbit/commons/jcr-rmi/trunk/jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/SerialValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/SerialValue.java?rev=761702&r1=761701&r2=761702&view=diff
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/SerialValue.java
(original)
+++ jackrabbit/commons/jcr-rmi/trunk/jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/SerialValue.java
Fri Apr  3 14:48:10 2009
@@ -183,4 +183,54 @@
     public int getType() {
         return type;
     }
+
+    //--------------------------------------------------------------< Object >
+
+    /**
+     * Compares values as defined in the JCR specification.
+     * <p>
+     * <strong>WARNING:</strong> This method may change the state of the value
+     * object!
+     *
+     * @param object value for comparison
+     * @return <code>true</code> if the values are equal,
+     *         <code>false</code> otherwise
+     * @see <a href="https://issues.apache.org/jira/browse/JCRRMI-16">JCRRMI-16</a>
+     */
+    public boolean equals(Object object) {
+        try {
+            return (object instanceof Value)
+                && getString().equals(((Value) object).getString());
+        } catch (RepositoryException e) {
+            return false;
+        }
+    }
+
+    /**
+     * Returns a hash code that's in line with how the {@link #equals(Object)}
+     * method is implemented.
+     *
+     * @return hash code of this value
+     */
+    public int hashCode() {
+        try {
+            return getString().hashCode();
+        } catch (RepositoryException e) {
+            return 0;
+        }
+    }
+
+    /**
+     * Returns a string representation of this value.
+     *
+     * @return value string
+     */
+    public String toString() {
+        try {
+            return getString();
+        } catch (RepositoryException e) {
+            return super.toString();
+        }
+    }
+
 }



Mime
View raw message