01: /**
02: * Objective Database Abstraction Layer (ODAL)
03: * Copyright (c) 2004, The ODAL Development Group
04: * All rights reserved.
05: * For definition of the ODAL Development Group please refer to LICENCE.txt file
06: *
07: * Distributable under LGPL license.
08: * See terms of license at gnu.org.
09: */package com.completex.objective.components.ocache.impl;
10:
11: import com.completex.objective.components.ocache.OdalCache;
12:
13: import java.util.Hashtable;
14:
15: /**
16: * Primitive OdalCache implementation based on Hashtable. It is suitable rather for tests than
17: * for production application.
18: *
19: * @author Gennady Krizhevsky
20: */
21: public class PrimitiveCacheImpl implements OdalCache {
22:
23: private String name;
24: private Hashtable hashtable = new Hashtable();
25:
26: public PrimitiveCacheImpl(String name) {
27: this .name = name;
28: }
29:
30: public Object get(Object key) {
31: return hashtable.get(key);
32: }
33:
34: public Object put(Object key, Object object) {
35: if (object != null) {
36: return hashtable.put(key, object);
37: }
38: return null;
39: }
40:
41: public Object remove(Object key) {
42: return hashtable.remove(key);
43: }
44:
45: public String getName() {
46: return name;
47: }
48:
49: public void clear() {
50: hashtable.clear();
51: }
52:
53: public String toString() {
54: return "{PrimitiveCacheImpl:" + getName() + "} = "
55: + hashtable.toString();
56: }
57:
58: }
|