cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stevend...@apache.org
Subject svn commit: r743672 - /cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/ParameterCacheKey.java
Date Thu, 12 Feb 2009 09:43:47 GMT
Author: stevendolg
Date: Thu Feb 12 09:43:47 2009
New Revision: 743672

URL: http://svn.apache.org/viewvc?rev=743672&view=rev
Log:
COCOON3-30

Modified:
    cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/ParameterCacheKey.java

Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/ParameterCacheKey.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/ParameterCacheKey.java?rev=743672&r1=743671&r2=743672&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/ParameterCacheKey.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/ParameterCacheKey.java
Thu Feb 12 09:43:47 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.cocoon.pipeline.caching;
 
+import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -26,10 +27,23 @@
     private static final long serialVersionUID = 1L;
     private final Map<String, Object> parameters;
 
+    public ParameterCacheKey() {
+        this(new HashMap<String, Object>());
+    }
+
     public ParameterCacheKey(Map<String, Object> parameters) {
         this.parameters = parameters;
     }
 
+    public ParameterCacheKey(String name, Object value) {
+        this();
+        this.addParameter(name, value);
+    }
+
+    public void addParameter(String name, Object value) {
+        this.parameters.put(name, value);
+    }
+
     /**
      * {@inheritDoc}
      * 
@@ -41,7 +55,12 @@
             return false;
         }
 
-        return true;
+        ParameterCacheKey other = (ParameterCacheKey) obj;
+        return this.parameters != null && this.parameters.equals(other.parameters);
+    }
+
+    public long getLastModified() {
+        return -1;
     }
 
     /**
@@ -51,7 +70,13 @@
      */
     @Override
     public int hashCode() {
-        return ParameterCacheKey.class.hashCode();
+        int hashCode = ParameterCacheKey.class.hashCode();
+
+        if (this.parameters != null) {
+            hashCode = 31 * hashCode + this.parameters.hashCode();
+        }
+
+        return hashCode;
     }
 
     /**
@@ -60,15 +85,6 @@
      * @see org.apache.cocoon.pipeline.caching.CacheKey#isValid(org.apache.cocoon.pipeline.caching.CacheKey)
      */
     public boolean isValid(CacheKey cacheKey) {
-        if (!this.equals(cacheKey)) {
-            return false;
-        }
-
-        ParameterCacheKey other = (ParameterCacheKey) cacheKey;
-        return this.parameters.equals(other.parameters);
-    }
-
-    public long getLastModified() {
-        return -1;
+        return this.equals(cacheKey);
     }
 }



Mime
View raw message