01: /*
02: * Created on 15 Jul 2007
03: */
04: package uk.org.ponder.rsf.state;
05:
06: import uk.org.ponder.util.ObstinateMap;
07:
08: /** An adaptor from the RSF "TokenStateHolder" interface for those who would
09: * prefer a JDK map. The supplied keys must be Strings.
10: * @author Antranig Basman (antranig@caret.cam.ac.uk)
11: *
12: */
13:
14: public class TSHMap extends ObstinateMap {
15: private TokenStateHolder tsh;
16:
17: public TSHMap(TokenStateHolder tsh) {
18: this .tsh = tsh;
19: }
20:
21: public boolean containsKey(Object key) {
22: return get(key) != null;
23: }
24:
25: public Object get(Object key) {
26: return tsh.getTokenState((String) key);
27: }
28:
29: public Object put(Object key, Object value) {
30: Object togo = get(key);
31: tsh.putTokenState((String) key, value);
32: return togo;
33: }
34:
35: public Object remove(Object key) {
36: Object togo = get(key);
37: tsh.clearTokenState((String) key);
38: return togo;
39: }
40: }
|