01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.caching.impl;
17:
18: import org.geotools.caching.CacheEntry;
19:
20: import org.geotools.feature.Feature;
21:
22: public class SimpleFeatureCacheEntry implements CacheEntry {
23: final private Feature feature;
24: private int hits;
25: private long creationTime;
26: private long lastAccessTime;
27:
28: public SimpleFeatureCacheEntry(Feature f) {
29: this .feature = f;
30: hits = 0;
31: creationTime = System.currentTimeMillis();
32: lastAccessTime = creationTime;
33: }
34:
35: public long getCost() {
36: return -1;
37: }
38:
39: public long getCreationTime() {
40: return creationTime;
41: }
42:
43: public long getExpirationTime() {
44: return -1;
45: }
46:
47: public int getHits() {
48: return hits;
49: }
50:
51: public long getLastAccessTime() {
52: return lastAccessTime;
53: }
54:
55: public long getLastUpdateTime() {
56: return -1;
57: }
58:
59: public long getVersion() {
60: return -1;
61: }
62:
63: public boolean isValid() {
64: return true;
65: }
66:
67: public Object getKey() {
68: return feature.getID();
69: }
70:
71: public Object getValue() {
72: hits++;
73: lastAccessTime = System.currentTimeMillis();
74:
75: return feature;
76: }
77:
78: public Object setValue(Object arg0) {
79: throw new UnsupportedOperationException();
80: }
81:
82: public boolean equals(Object o) {
83: return feature.equals(o);
84: }
85:
86: public int hashCode() {
87: return feature.hashCode();
88: }
89: }
|