1 |
/* Dictionary.java -- an abstract (and essentially worthless) |
/* Dictionary.java -- an abstract (and essentially worthless) |
2 |
class which is Hashtable's superclass |
class which is Hashtable's superclass |
3 |
Copyright (C) 1998 Free Software Foundation, Inc. |
Copyright (C) 1998, 2001 Free Software Foundation, Inc. |
4 |
|
|
5 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
6 |
|
|
35 |
* This is an abstract class which has really gone by the wayside. |
* This is an abstract class which has really gone by the wayside. |
36 |
* People at Javasoft are probably embarrassed by it. At this point, |
* People at Javasoft are probably embarrassed by it. At this point, |
37 |
* it might as well be an interface rather than a class, but it remains |
* it might as well be an interface rather than a class, but it remains |
38 |
* this poor, laugable skeleton for the sake of backwards compatibility. |
* this poor, laughable skeleton for the sake of backwards compatibility. |
39 |
* At any rate, this was what came before the <pre>Map</pre> interface |
* At any rate, this was what came before the <pre>Map</pre> interface |
40 |
* in the Collections framework. |
* in the Collections framework. |
41 |
* |
* |
42 |
* @author Jon Zeppieri |
* @author Jon Zeppieri |
43 |
|
* @author Eric Blake <ebb9@email.byu.edu> |
44 |
|
* @see Map |
45 |
|
* @see Hashtable |
46 |
|
* @since 1.0 |
47 |
|
* @status updated to 1.4 |
48 |
*/ |
*/ |
49 |
public abstract class Dictionary extends Object |
public abstract class Dictionary extends Object |
50 |
{ |
{ |
51 |
/** returns an Enumeration of the values in this Dictionary */ |
/** |
52 |
|
* Sole constructor (often called implicitly). |
53 |
|
*/ |
54 |
|
public Dictionary() |
55 |
|
{ |
56 |
|
} |
57 |
|
|
58 |
|
/** |
59 |
|
* Returns an Enumeration of the values in this Dictionary. |
60 |
|
* |
61 |
|
* @return an Enumeration of the values |
62 |
|
* @see #keys() |
63 |
|
*/ |
64 |
public abstract Enumeration elements(); |
public abstract Enumeration elements(); |
65 |
|
|
66 |
/** |
/** |
67 |
* returns the value associated with the supplied key, or null |
* Returns the value associated with the supplied key, or null |
68 |
* if no such value exists |
* if no such value exists. Since Dictionaries are not allowed null keys |
69 |
|
* or elements, a null result always means the key is not present. |
70 |
* |
* |
71 |
* @param key the key to use to fetch the value |
* @param key the key to use to fetch the value |
72 |
|
* @return the mapped value |
73 |
|
* @throws NullPointerException if key is null |
74 |
|
* @see #put(Object, Object) |
75 |
*/ |
*/ |
76 |
public abstract Object get(Object key); |
public abstract Object get(Object key); |
77 |
|
|
78 |
/** returns true IFF there are no elements in this Dictionary (size() == 0) */ |
/** |
79 |
|
* Returns true when there are no elements in this Dictionary. |
80 |
|
* |
81 |
|
* @return <code>size() == 0</code> |
82 |
|
*/ |
83 |
public abstract boolean isEmpty(); |
public abstract boolean isEmpty(); |
84 |
|
|
85 |
/** returns an Enumeration of the keys in this Dictionary */ |
/** |
86 |
|
* Returns an Enumeration of the keys in this Dictionary |
87 |
|
* |
88 |
|
* @return an Enumeration of the keys |
89 |
|
* @see #elements() |
90 |
|
*/ |
91 |
public abstract Enumeration keys(); |
public abstract Enumeration keys(); |
92 |
|
|
93 |
/** |
/** |
94 |
* inserts a new value into this Dictionary, located by the |
* Inserts a new value into this Dictionary, located by the |
95 |
* supllied key; note: Dictionary's subclasses (all 1 of them) |
* supplied key. Dictionary does not support null keys or values, so |
96 |
* do not support null keys or values (I can only assume this |
* a null return can safely be interpreted as adding a new key. |
|
* would have been more general) |
|
97 |
* |
* |
98 |
* @param key the key which locates the value |
* @param key the key which locates the value |
99 |
* @param value the value to put into the Dictionary |
* @param value the value to put into the Dictionary |
100 |
|
* @return the previous value of the key, or null if there was none |
101 |
|
* @throws NullPointerException if key or value is null |
102 |
|
* @see #get(Object) |
103 |
*/ |
*/ |
104 |
public abstract Object put(Object key, Object value); |
public abstract Object put(Object key, Object value); |
105 |
|
|
106 |
/** |
/** |
107 |
* removes fro the Dictionary the value located by the given key |
* Removes from the Dictionary the value located by the given key. A null |
108 |
|
* return safely means that the key was not mapped in the Dictionary. |
109 |
* |
* |
110 |
* @param key the key used to locate the value to be removed |
* @param key the key used to locate the value to be removed |
111 |
|
* @return the value associated with the removed key |
112 |
|
* @throws NullPointerException if key is null |
113 |
*/ |
*/ |
114 |
public abstract Object remove(Object key); |
public abstract Object remove(Object key); |
115 |
|
|
116 |
/** returns the number of values currently in this Dictionary */ |
/** |
117 |
|
* Returns the number of values currently in this Dictionary. |
118 |
|
* |
119 |
|
* @return the number of keys in the Dictionary |
120 |
|
*/ |
121 |
public abstract int size(); |
public abstract int size(); |
122 |
} |
} |