View Javadoc

1   /*
2    *  XNap - A P2P framework and client.
3    *
4    *  See the file AUTHORS for copyright information.
5    *
6    *  This program is free software; you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation.
9    *
10   *  This program is distributed in the hope that it will be useful,
11   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   *  GNU General Public License for more details.
14   *
15   *  You should have received a copy of the GNU General Public License
16   *  along with this program; if not, write to the Free Software
17   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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      //--- Constant(s) ---
35  
36      //--- Data field(s) ---
37  
38      //--- Constructor(s) ---
39  
40      public MultiHashtable()
41      {
42      }
43  
44      //--- Method(s) ---
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 }