01: /* *****************************************************************************
02: * SWFMap.java
03: * ****************************************************************************/
04:
05: /* J_LZ_COPYRIGHT_BEGIN *******************************************************
06: * Copyright 2001-2004 Laszlo Systems, Inc. All Rights Reserved. *
07: * Use is subject to license terms. *
08: * J_LZ_COPYRIGHT_END *********************************************************/
09:
10: package org.openlaszlo.utils;
11:
12: import java.util.*;
13:
14: /**
15: * A Map to retrieve and store an object based on some key. For example, could
16: * be used to store different versions of the same SWF bytecode. Not
17: * thread-safe.
18: */
19: public class VersionMap {
20:
21: Map mMap = new HashMap();
22:
23: /**
24: * Put a value based on version and key.
25: */
26: public void put(Object version, Object key, Object value) {
27: Map m = (Map) mMap.get(key);
28: if (m == null) {
29: m = new HashMap();
30: mMap.put(key, m);
31: }
32: m.put(version, value);
33: }
34:
35: /**
36: * Get value based on version and key.
37: */
38: public Object get(Object version, Object key) {
39: Map m = (Map) mMap.get(key);
40: if (m == null)
41: return null;
42: return m.get(version);
43: }
44:
45: /**
46: * @return set of keys.
47: */
48: public Set keySet() {
49: return mMap.keySet();
50: }
51:
52: /**
53: * @return map of versions.
54: */
55: public Map getVersions(Object key) {
56: return (Map) mMap.get(key);
57: }
58:
59: /**
60: * @return number of items in this map.
61: */
62: public int size() {
63: return mMap.size();
64: }
65: }
|