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 1.0 29 */ 30public abstract class Dictionary<K, V> { 31 /** 32 * Constructs a new instance of this class. 33 */ 34 public Dictionary() { 35 super(); 36 } 37 38 /** 39 * Returns an enumeration on the elements of this dictionary. 40 * 41 * @return an enumeration of the values of this dictionary. 42 * @see #keys 43 * @see #size 44 * @see Enumeration 45 */ 46 public abstract Enumeration<V> elements(); 47 48 /** 49 * Returns the value which is associated with {@code key}. 50 * 51 * @param key 52 * the key of the value returned. 53 * @return the value associated with {@code key}, or {@code null} if the 54 * specified key does not exist. 55 * @see #put 56 */ 57 public abstract V get(Object key); 58 59 /** 60 * Returns true if this dictionary has no key/value pairs. 61 * 62 * @return {@code true} if this dictionary has no key/value pairs, 63 * {@code false} otherwise. 64 * @see #size 65 */ 66 public abstract boolean isEmpty(); 67 68 /** 69 * Returns an enumeration on the keys of this dictionary. 70 * 71 * @return an enumeration of the keys of this dictionary. 72 * @see #elements 73 * @see #size 74 * @see Enumeration 75 */ 76 public abstract Enumeration<K> keys(); 77 78 /** 79 * Associate {@code key} with {@code value} in this dictionary. If {@code 80 * key} exists in the dictionary before this call, the old value in the 81 * dictionary is replaced by {@code value}. 82 * 83 * @param key 84 * the key to add. 85 * @param value 86 * the value to add. 87 * @return the old value previously associated with {@code key} or {@code 88 * null} if {@code key} is new to the dictionary. 89 * @see #elements 90 * @see #get 91 * @see #keys 92 */ 93 public abstract V put(K key, V value); 94 95 /** 96 * Removes the key/value pair with the specified {@code key} from this 97 * dictionary. 98 * 99 * @param key 100 * the key to remove. 101 * @return the associated value before the deletion or {@code null} if 102 * {@code key} was not known to this dictionary. 103 * @see #get 104 * @see #put 105 */ 106 public abstract V remove(Object key); 107 108 /** 109 * Returns the number of key/value pairs in this dictionary. 110 * 111 * @return the number of key/value pairs in this dictionary. 112 * @see #elements 113 * @see #keys 114 */ 115 public abstract int size(); 116} 117