1 38 39 40 package org.jahia.services.cache; 41 42 import java.util.Map ; 43 import java.util.HashMap ; 44 import java.util.Date ; 45 import java.io.Serializable ; 46 47 48 58 public class CacheEntry implements Serializable { 59 60 61 public static final String MODE_NORMAL = "normal"; 62 63 64 public static final String MODE_DEBUG = "debug"; 65 66 67 public static final String MODE_EDIT = "edit"; 68 69 70 71 private Object object; 72 73 74 75 protected int hits = 0; 76 77 78 protected String operationMode = ""; 81 82 protected Map properties = new HashMap (); 83 84 85 protected Date expirationDate; 86 87 88 protected long lastAccessedTimeMillis; 89 90 91 protected long creationTimeMillis; 92 93 94 96 public CacheEntry () { 97 creationTimeMillis = System.currentTimeMillis(); 98 } 99 100 101 105 public CacheEntry (final Object entryObj) { 106 object = entryObj; 107 creationTimeMillis = System.currentTimeMillis(); 108 } 109 110 111 115 public Object getObject () { 116 return object; 117 } 118 119 120 124 public void setObject (final Object object) { 125 this.object = object; 126 } 127 128 129 139 public void setProperty (final String key, final Object value) { 140 if (key == null) 141 return; 142 properties.put (key, value); 143 } 144 145 146 158 public Object getProperty (final String key) { 159 return properties.get (key); 160 } 161 162 163 171 public boolean containsKey (final String key) { 172 if (key == null) 173 return false; 174 return properties.containsKey (key); 175 } 176 177 178 182 public Map getExtendedProperties () { 183 return properties; 184 } 185 186 187 192 public void setExtendedProperties (final Map newProperties) { 193 if (newProperties == null) 194 return; 195 properties = newProperties; 196 } 197 198 199 204 final public int getHits () { 205 return hits; 206 } 207 208 209 211 final public void resetHits () { 212 hits = 0; 213 } 214 215 216 218 final public void incrementHits () { 219 hits++; 220 } 221 222 223 231 final public String getOperationMode () { 232 return this.operationMode; 233 } 234 235 236 244 final public void setOperationMode (final String opMode) { 245 this.operationMode = opMode; 246 } 247 248 249 253 final public Date getExpirationDate () { 254 return expirationDate; 255 } 256 257 258 262 final public void setExpirationDate (Date expirationDate) { 263 this.expirationDate = expirationDate; 264 } 265 266 267 269 final public void setLastAccessedTimeNow () { 270 lastAccessedTimeMillis = System.currentTimeMillis(); 271 } 273 public long getLastAccessedTimeMillis() { 274 return lastAccessedTimeMillis; 275 } 276 277 278 282 public long getCreationTimeMillis() 283 { 284 return creationTimeMillis; 285 } 286 287 } 288 | Popular Tags |