1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.util;
21
22 import java.util.Collection;
23 import java.util.Enumeration;
24 import java.util.Hashtable;
25 import java.util.LinkedList;
26 import java.util.List;
27 import java.util.Map;
28
29 /***
30 * Provides a 1:n Hashtable. This implementation is not complete.
31 */
32 public class MultiHashtable extends Hashtable {
33
34
35
36
37
38
39
40 public MultiHashtable()
41 {
42 }
43
44
45
46 public boolean contains(Object value)
47 {
48 error();
49
50 return false;
51 }
52
53 public boolean containsValue(Object value)
54 {
55 return contains(value);
56 }
57
58 public Enumeration elements()
59 {
60 error();
61
62 return null;
63 }
64
65 public List getList(Object key)
66 {
67 List l = (List)get(key);
68 if (l == null) {
69 l = new LinkedList();
70 super.put(key, l);
71 }
72 return l;
73 }
74
75 /***
76 * @return always null
77 */
78 public Object put(Object key, Object value)
79 {
80 getList(key).add(value);
81 return null;
82 }
83
84 public void putAll(Map t)
85 {
86 error();
87 }
88
89 public Collection values()
90 {
91 error();
92 return null;
93 }
94
95 private void error()
96 {
97 throw new UnsupportedOperationException();
98 }
99
100 }