1/*
2 *  Licensed to the Apache Software Foundation (ASF) under one or more
3 *  contributor license agreements.  See the NOTICE file distributed with
4 *  this work for additional information regarding copyright ownership.
5 *  The ASF licenses this file to You under the Apache License, Version 2.0
6 *  (the "License"); you may not use this file except in compliance with
7 *  the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 */
17
18package java.util;
19
20/**
21 * <strong>Note: Do not use this class since it is obsolete. Please use the
22 * {@link Map} interface for new implementations.</strong>
23 * <p>
24 * Dictionary is an abstract class which is the superclass of all classes that
25 * associate keys with values, such as {@code Hashtable}.
26 *
27 * @see Hashtable
28 * @since Android 1.0
29 */
30public abstract class Dictionary<K,V> {
31
32    /**
33     * Constructs a new instance of this class.
34     *
35     * @since Android 1.0
36     */
37    public Dictionary() {
38        super();
39    }
40
41    /**
42     * Returns an enumeration on the elements of this dictionary.
43     *
44     * @return an enumeration of the values of this dictionary.
45     * @see #keys
46     * @see #size
47     * @see Enumeration
48     * @since Android 1.0
49     */
50    public abstract Enumeration<V> elements();
51
52    /**
53     * Returns the value which is associated with {@code key}.
54     *
55     * @param key
56     *            the key of the value returned.
57     * @return the value associated with {@code key}, or {@code null} if the
58     *         specified key does not exist.
59     * @see #put
60     * @since Android 1.0
61     */
62    public abstract V get(Object key);
63
64    /**
65     * Returns true if this dictionary has no key/value pairs.
66     *
67     * @return {@code true} if this dictionary has no key/value pairs,
68     *         {@code false} otherwise.
69     * @see #size
70     * @since Android 1.0
71     */
72    public abstract boolean isEmpty();
73
74    /**
75     * Returns an enumeration on the keys of this dictionary.
76     *
77     * @return an enumeration of the keys of this dictionary.
78     * @see #elements
79     * @see #size
80     * @see Enumeration
81     * @since Android 1.0
82     */
83    public abstract Enumeration<K> keys();
84
85    /**
86     * Associate {@code key} with {@code value} in this dictionary. If {@code
87     * key} exists in the dictionary before this call, the old value in the
88     * dictionary is replaced by {@code value}.
89     *
90     * @param key
91     *            the key to add.
92     * @param value
93     *            the value to add.
94     * @return the old value previously associated with {@code key} or {@code
95     *         null} if {@code key} is new to the dictionary.
96     * @see #elements
97     * @see #get
98     * @see #keys
99     * @since Android 1.0
100     */
101    public abstract V put(K key, V value);
102
103    /**
104     * Removes the key/value pair with the specified {@code key} from this
105     * dictionary.
106     *
107     * @param key
108     *            the key to remove.
109     * @return the associated value before the deletion or {@code null} if
110     *         {@code key} was not known to this dictionary.
111     * @see #get
112     * @see #put
113     * @since Android 1.0
114     */
115    public abstract V remove(Object key);
116
117    /**
118     * Returns the number of key/value pairs in this dictionary.
119     *
120     * @return the number of key/value pairs in this dictionary.
121     * @see #elements
122     * @see #keys
123     * @since Android 1.0
124     */
125    public abstract int size();
126}
127