KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > whirlycott > cache > impl > AbstractMapBackedCache


1 /*
2 Copyright 2004 Philip Jacob <phil@whirlycott.com>
3                     Seth Fitzsimmons <seth@note.amherst.edu>
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9     http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 */

17
18 package com.whirlycott.cache.impl;
19
20 import java.util.Collection JavaDoc;
21 import java.util.Map JavaDoc;
22 import java.util.Set JavaDoc;
23
24 import com.whirlycott.cache.ManagedCache;
25
26 /**
27  * This is an abstract class for help in developing a cache backend using an
28  * implementation of java.util.Map.
29  *
30  * @author Phil Jacob
31  */

32 public abstract class AbstractMapBackedCache implements ManagedCache {
33
34     /** Underlying Map to store cached objects in. */
35     protected Map JavaDoc c;
36     
37     public void destroy() {
38         c.clear();
39         c = null;
40     }
41
42     public abstract void setMostlyRead(final boolean _mostlyRead);
43     
44     public int size() {
45         return c.size();
46     }
47
48     public void clear() {
49         c.clear();
50     }
51
52     public boolean isEmpty() {
53         return c.isEmpty();
54     }
55
56     public boolean containsKey(final Object JavaDoc key) {
57         return c.containsKey(key);
58     }
59
60     public boolean containsValue(final Object JavaDoc value) {
61         return c.containsValue(value);
62     }
63
64     public Collection JavaDoc values() {
65         return c.values();
66     }
67
68     public void putAll(final Map JavaDoc t) {
69         c.putAll(t);
70     }
71
72     public Set JavaDoc entrySet() {
73         return c.entrySet();
74     }
75
76     public Set JavaDoc keySet() {
77         return c.keySet();
78     }
79
80     public Object JavaDoc get(final Object JavaDoc key) {
81         return c.get(key);
82     }
83
84     public Object JavaDoc remove(final Object JavaDoc key) {
85         return c.remove(key);
86     }
87
88     public Object JavaDoc put(final Object JavaDoc key, final Object JavaDoc value) {
89         return c.put(key, value);
90     }
91     
92     public void store(final Object JavaDoc key, final Object JavaDoc value) {
93         c.put(key, value);
94     }
95     
96     public Object JavaDoc retrieve(final Object JavaDoc key) {
97         return c.get(key);
98     }
99
100 }
101
Popular Tags