KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > cache > CacheKey


1 package info.magnolia.cms.cache;
2
3 import info.magnolia.cms.core.Path;
4
5 import java.io.Serializable JavaDoc;
6
7 import javax.servlet.http.HttpServletRequest JavaDoc;
8
9
10 /**
11  * @author Fabrizio Giustina
12  * @version $Revision: 6341 $ ($Author: philipp $)
13  */

14 public class CacheKey implements Serializable JavaDoc {
15
16     /**
17      * Stable serialVersionUID.
18      */

19     private static final long serialVersionUID = 222L;
20
21     private String JavaDoc key;
22
23     /**
24      * Used for special subclasses not meant to be used in general
25      */

26     public CacheKey() {
27     }
28
29     /**
30      * Contstuctor used if the key is already known
31      */

32     public CacheKey(String JavaDoc key) {
33         this.key = key;
34     }
35
36     /**
37      * The constructor used by default
38      * @param request the request from which we get the path
39      */

40     public CacheKey(HttpServletRequest JavaDoc request) {
41         key = Path.getURI(request);
42     }
43
44     /**
45      * @see java.lang.Object#equals(java.lang.Object)
46      */

47     public boolean equals(Object JavaDoc obj) {
48         return key.equals(((CacheKey) obj).key);
49     }
50
51     /**
52      * @see java.lang.Object#hashCode()
53      */

54     public int hashCode() {
55         return key.hashCode();
56     }
57
58     /**
59      * @see java.lang.Object#toString()
60      */

61     public String JavaDoc toString() {
62         // just return the key (path), as it's used for the filepath in the simple implementation
63
return key;
64     }
65
66 }
67
Popular Tags