1 16 package org.apache.cocoon.caching; 17 18 import java.io.Serializable ; 19 31 public final class ComponentCacheKey 32 implements Serializable { 33 34 public static final int ComponentType_Generator = 1; 35 public static final int ComponentType_Transformer = 3; 36 public static final int ComponentType_Serializer = 5; 37 public static final int ComponentType_Reader = 7; 38 39 private static final String [] COMPONENTS = { "X", "G", "X", "T", "X", "S", "X", "R" }; 42 43 44 private final int type; 45 46 private final String identifier; 47 48 private final Serializable key; 49 50 private final int hashCode; 51 52 private final boolean cachePoint; 53 54 57 public ComponentCacheKey(int componentType, 58 String componentIdentifier, 59 Serializable cacheKey) { 60 this(componentType, componentIdentifier, cacheKey, false); 61 } 62 63 66 public ComponentCacheKey(int componentType, 67 String componentIdentifier, 68 Serializable cacheKey, 69 boolean cachePoint) { 70 this.type = componentType; 71 this.identifier = componentIdentifier; 72 this.key = cacheKey; 73 74 this.cachePoint = cachePoint; 75 this.hashCode = this.type + 76 (this.identifier.length() << 3) + 77 this.key.hashCode(); 78 } 79 80 83 public boolean equals(Object object) { 84 if (object instanceof ComponentCacheKey) { 85 ComponentCacheKey ccp = (ComponentCacheKey)object; 86 if (this.type == ccp.type 87 && this.identifier.equals(ccp.identifier) 88 && this.key.equals(ccp.key)) { 89 return true; 90 } 91 } 92 return false; 93 } 94 95 98 public int hashCode() { 99 return this.hashCode; 100 } 101 102 private String toString; 103 104 108 public String toString() { 109 if (this.toString == null) { 110 toString = COMPONENTS[this.type] + '-' + this.identifier + '-' + this.key.toString(); 111 } 112 return toString; 113 } 114 115 118 public boolean isCachePoint() { 119 return cachePoint; 120 } 121 } 122 | Popular Tags |