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.InternalStore;
19:
20: import org.geotools.feature.Feature;
21:
22: import java.util.Collection;
23: import java.util.HashMap;
24:
25: /** Simplest implementation of InternalStore, using a HashMap as storage.
26: * Does implement cache size limit.
27: * Does not handle oveflow.
28: *
29: * Used only for testing purpose.
30: *
31: * @author Christophe Rousson, SoC 2007, CRG-ULAVAL
32: *
33: */
34: public class SimpleHashMapInternalStore implements InternalStore {
35: private final HashMap buffer = new HashMap();
36:
37: public void clear() {
38: buffer.clear();
39: }
40:
41: public boolean contains(final Feature f) {
42: return contains(f.getID());
43: }
44:
45: public Feature get(final String featureId) {
46: return (Feature) buffer.get(featureId);
47: }
48:
49: public Collection getAll() {
50: return buffer.values();
51: }
52:
53: public void put(final Feature f) {
54: buffer.put(f.getID(), f);
55: }
56:
57: public void remove(final String featureId) {
58: buffer.remove(featureId);
59: }
60:
61: /* (non-Javadoc)
62: * @see org.geotools.caching.InternalStore#contains(java.lang.String)
63: */
64: public boolean contains(String featureId) {
65: return buffer.containsKey(featureId);
66: }
67: }
|