You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by eh...@apache.org on 2007/04/09 08:49:47 UTC

svn commit: r526661 - in /incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket: protocol/http/FilePageStore.java util/lang/Objects.java

Author: ehillenius
Date: Sun Apr  8 23:49:46 2007
New Revision: 526661

URL: http://svn.apache.org/viewvc?view=rev&rev=526661
Log:
hashCode implementation that matches equals

Modified:
    incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/protocol/http/FilePageStore.java
    incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/util/lang/Objects.java

Modified: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/protocol/http/FilePageStore.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/protocol/http/FilePageStore.java?view=diff&rev=526661&r1=526660&r2=526661
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/protocol/http/FilePageStore.java (original)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/protocol/http/FilePageStore.java Sun Apr  8 23:49:46 2007
@@ -336,7 +336,9 @@
 		 */
 		public int hashCode()
 		{
-			return sessionId.hashCode() + id + versionNumber;
+			// TODO with Java 5, replace by .valueOf usage
+			return Objects.hashCode(new Object[] { new Integer(id), new Integer(versionNumber),
+					new Integer(ajaxVersionNumber), pageMap, sessionId });
 		}
 
 		/**

Modified: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/util/lang/Objects.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/util/lang/Objects.java?view=diff&rev=526661&r1=526660&r2=526661
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/util/lang/Objects.java (original)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/util/lang/Objects.java Sun Apr  8 23:49:46 2007
@@ -1183,6 +1183,29 @@
 	}
 
 	/**
+	 * returns hashcode of the objects by calling obj.hashcode(). safe to use
+	 * when obj is null.
+	 * 
+	 * @param obj
+	 * @return hashcode of the object or 0 if obj is null
+	 */
+	// TODO when on Java 5, we can use Object... obj
+	public static int hashCode(final Object[] obj)
+	{
+		if (obj == null || obj.length == 0)
+		{
+			return 0;
+		}
+		int result = 37;
+		int len = obj.length;
+		for (int i = obj.length - 1; i > -1; i--)
+		{
+			result = 37 * result + (obj[i] != null ? obj[i].hashCode() : 0);
+		}
+		return result;
+	}
+
+	/**
 	 * Evaluates the given object as a String and trims it if the trim flag is
 	 * true.
 	 *