001/* Dictionary.java -- an abstract (and essentially worthless) 002 class which is Hashtable's superclass 003 Copyright (C) 1998, 2001, 2002, 2004 Free Software Foundation, Inc. 004 005This file is part of GNU Classpath. 006 007GNU Classpath is free software; you can redistribute it and/or modify 008it under the terms of the GNU General Public License as published by 009the Free Software Foundation; either version 2, or (at your option) 010any later version. 011 012GNU Classpath is distributed in the hope that it will be useful, but 013WITHOUT ANY WARRANTY; without even the implied warranty of 014MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015General Public License for more details. 016 017You should have received a copy of the GNU General Public License 018along with GNU Classpath; see the file COPYING. If not, write to the 019Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02002110-1301 USA. 021 022Linking this library statically or dynamically with other modules is 023making a combined work based on this library. Thus, the terms and 024conditions of the GNU General Public License cover the whole 025combination. 026 027As a special exception, the copyright holders of this library give you 028permission to link this library with independent modules to produce an 029executable, regardless of the license terms of these independent 030modules, and to copy and distribute the resulting executable under 031terms of your choice, provided that you also meet, for each linked 032independent module, the terms and conditions of the license of that 033module. An independent module is a module which is not derived from 034or based on this library. If you modify this library, you may extend 035this exception to your version of the library, but you are not 036obligated to do so. If you do not wish to do so, delete this 037exception statement from your version. */ 038 039 040package java.util; 041 042/** 043 * A Dictionary maps keys to values; <i>how</i> it does that is 044 * implementation-specific. 045 * 046 * This is an abstract class which has really gone by the wayside. 047 * People at Javasoft are probably embarrassed by it. At this point, 048 * it might as well be an interface rather than a class, but it remains 049 * this poor, laughable skeleton for the sake of backwards compatibility. 050 * At any rate, this was what came before the {@link Map} interface 051 * in the Collections framework. 052 * 053 * @author Jon Zeppieri 054 * @author Eric Blake (ebb9@email.byu.edu) 055 * @see Map 056 * @see Hashtable 057 * @since 1.0 058 * @status updated to 1.4 059 */ 060public abstract class Dictionary<K, V> 061{ 062 // WARNING: Dictionary is a CORE class in the bootstrap cycle. See the 063 // comments in vm/reference/java/lang/Runtime for implications of this fact. 064 065 /** 066 * Sole constructor (often called implicitly). 067 */ 068 public Dictionary() 069 { 070 } 071 072 /** 073 * Returns an Enumeration of the values in this Dictionary. 074 * 075 * @return an Enumeration of the values 076 * @see #keys() 077 */ 078 public abstract Enumeration<V> elements(); 079 080 /** 081 * Returns the value associated with the supplied key, or null 082 * if no such value exists. Since Dictionaries are not allowed null keys 083 * or elements, a null result always means the key is not present. 084 * 085 * @param key the key to use to fetch the value 086 * @return the mapped value 087 * @throws NullPointerException if key is null 088 * @see #put(Object, Object) 089 */ 090 public abstract V get(Object key); 091 092 /** 093 * Returns true when there are no elements in this Dictionary. 094 * 095 * @return <code>size() == 0</code> 096 */ 097 public abstract boolean isEmpty(); 098 099 /** 100 * Returns an Enumeration of the keys in this Dictionary 101 * 102 * @return an Enumeration of the keys 103 * @see #elements() 104 */ 105 public abstract Enumeration<K> keys(); 106 107 /** 108 * Inserts a new value into this Dictionary, located by the 109 * supplied key. Dictionary does not support null keys or values, so 110 * a null return can safely be interpreted as adding a new key. 111 * 112 * @param key the key which locates the value 113 * @param value the value to put into the Dictionary 114 * @return the previous value of the key, or null if there was none 115 * @throws NullPointerException if key or value is null 116 * @see #get(Object) 117 */ 118 public abstract V put(K key, V value); 119 120 /** 121 * Removes from the Dictionary the value located by the given key. A null 122 * return safely means that the key was not mapped in the Dictionary. 123 * 124 * @param key the key used to locate the value to be removed 125 * @return the value associated with the removed key 126 * @throws NullPointerException if key is null 127 */ 128 public abstract V remove(Object key); 129 130 /** 131 * Returns the number of values currently in this Dictionary. 132 * 133 * @return the number of keys in the Dictionary 134 */ 135 public abstract int size(); 136} // class Dictionary