jaroslav@597: /* jaroslav@597: * Copyright (c) 1995, 2004, Oracle and/or its affiliates. All rights reserved. jaroslav@597: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jaroslav@597: * jaroslav@597: * This code is free software; you can redistribute it and/or modify it jaroslav@597: * under the terms of the GNU General Public License version 2 only, as jaroslav@597: * published by the Free Software Foundation. Oracle designates this jaroslav@597: * particular file as subject to the "Classpath" exception as provided jaroslav@597: * by Oracle in the LICENSE file that accompanied this code. jaroslav@597: * jaroslav@597: * This code is distributed in the hope that it will be useful, but WITHOUT jaroslav@597: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jaroslav@597: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jaroslav@597: * version 2 for more details (a copy is included in the LICENSE file that jaroslav@597: * accompanied this code). jaroslav@597: * jaroslav@597: * You should have received a copy of the GNU General Public License version jaroslav@597: * 2 along with this work; if not, write to the Free Software Foundation, jaroslav@597: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jaroslav@597: * jaroslav@597: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA jaroslav@597: * or visit www.oracle.com if you need additional information or have any jaroslav@597: * questions. jaroslav@597: */ jaroslav@597: jaroslav@597: package java.util; jaroslav@597: jaroslav@597: /** jaroslav@597: * The Dictionary class is the abstract parent of any jaroslav@597: * class, such as Hashtable, which maps keys to values. jaroslav@597: * Every key and every value is an object. In any one Dictionary jaroslav@597: * object, every key is associated with at most one value. Given a jaroslav@597: * Dictionary and a key, the associated element can be looked up. jaroslav@597: * Any non-null object can be used as a key and as a value. jaroslav@597: *

jaroslav@597: * As a rule, the equals method should be used by jaroslav@597: * implementations of this class to decide if two keys are the same. jaroslav@597: *

jaroslav@597: * NOTE: This class is obsolete. New implementations should jaroslav@597: * implement the Map interface, rather than extending this class. jaroslav@597: * jaroslav@597: * @author unascribed jaroslav@597: * @see java.util.Map jaroslav@597: * @see java.lang.Object#equals(java.lang.Object) jaroslav@597: * @see java.lang.Object#hashCode() jaroslav@597: * @see java.util.Hashtable jaroslav@597: * @since JDK1.0 jaroslav@597: */ jaroslav@597: public abstract jaroslav@597: class Dictionary { jaroslav@597: /** jaroslav@597: * Sole constructor. (For invocation by subclass constructors, typically jaroslav@597: * implicit.) jaroslav@597: */ jaroslav@597: public Dictionary() { jaroslav@597: } jaroslav@597: jaroslav@597: /** jaroslav@597: * Returns the number of entries (distinct keys) in this dictionary. jaroslav@597: * jaroslav@597: * @return the number of keys in this dictionary. jaroslav@597: */ jaroslav@597: abstract public int size(); jaroslav@597: jaroslav@597: /** jaroslav@597: * Tests if this dictionary maps no keys to value. The general contract jaroslav@597: * for the isEmpty method is that the result is true if and only jaroslav@597: * if this dictionary contains no entries. jaroslav@597: * jaroslav@597: * @return true if this dictionary maps no keys to values; jaroslav@597: * false otherwise. jaroslav@597: */ jaroslav@597: abstract public boolean isEmpty(); jaroslav@597: jaroslav@597: /** jaroslav@597: * Returns an enumeration of the keys in this dictionary. The general jaroslav@597: * contract for the keys method is that an Enumeration object jaroslav@597: * is returned that will generate all the keys for which this dictionary jaroslav@597: * contains entries. jaroslav@597: * jaroslav@597: * @return an enumeration of the keys in this dictionary. jaroslav@597: * @see java.util.Dictionary#elements() jaroslav@597: * @see java.util.Enumeration jaroslav@597: */ jaroslav@597: abstract public Enumeration keys(); jaroslav@597: jaroslav@597: /** jaroslav@597: * Returns an enumeration of the values in this dictionary. The general jaroslav@597: * contract for the elements method is that an jaroslav@597: * Enumeration is returned that will generate all the elements jaroslav@597: * contained in entries in this dictionary. jaroslav@597: * jaroslav@597: * @return an enumeration of the values in this dictionary. jaroslav@597: * @see java.util.Dictionary#keys() jaroslav@597: * @see java.util.Enumeration jaroslav@597: */ jaroslav@597: abstract public Enumeration elements(); jaroslav@597: jaroslav@597: /** jaroslav@597: * Returns the value to which the key is mapped in this dictionary. jaroslav@597: * The general contract for the isEmpty method is that if this jaroslav@597: * dictionary contains an entry for the specified key, the associated jaroslav@597: * value is returned; otherwise, null is returned. jaroslav@597: * jaroslav@597: * @return the value to which the key is mapped in this dictionary; jaroslav@597: * @param key a key in this dictionary. jaroslav@597: * null if the key is not mapped to any value in jaroslav@597: * this dictionary. jaroslav@597: * @exception NullPointerException if the key is null. jaroslav@597: * @see java.util.Dictionary#put(java.lang.Object, java.lang.Object) jaroslav@597: */ jaroslav@597: abstract public V get(Object key); jaroslav@597: jaroslav@597: /** jaroslav@597: * Maps the specified key to the specified jaroslav@597: * value in this dictionary. Neither the key nor the jaroslav@597: * value can be null. jaroslav@597: *

jaroslav@597: * If this dictionary already contains an entry for the specified jaroslav@597: * key, the value already in this dictionary for that jaroslav@597: * key is returned, after modifying the entry to contain the jaroslav@597: * new element.

If this dictionary does not already have an entry jaroslav@597: * for the specified key, an entry is created for the jaroslav@597: * specified key and value, and null is jaroslav@597: * returned. jaroslav@597: *

jaroslav@597: * The value can be retrieved by calling the jaroslav@597: * get method with a key that is equal to jaroslav@597: * the original key. jaroslav@597: * jaroslav@597: * @param key the hashtable key. jaroslav@597: * @param value the value. jaroslav@597: * @return the previous value to which the key was mapped jaroslav@597: * in this dictionary, or null if the key did not jaroslav@597: * have a previous mapping. jaroslav@597: * @exception NullPointerException if the key or jaroslav@597: * value is null. jaroslav@597: * @see java.lang.Object#equals(java.lang.Object) jaroslav@597: * @see java.util.Dictionary#get(java.lang.Object) jaroslav@597: */ jaroslav@597: abstract public V put(K key, V value); jaroslav@597: jaroslav@597: /** jaroslav@597: * Removes the key (and its corresponding jaroslav@597: * value) from this dictionary. This method does nothing jaroslav@597: * if the key is not in this dictionary. jaroslav@597: * jaroslav@597: * @param key the key that needs to be removed. jaroslav@597: * @return the value to which the key had been mapped in this jaroslav@597: * dictionary, or null if the key did not have a jaroslav@597: * mapping. jaroslav@597: * @exception NullPointerException if key is null. jaroslav@597: */ jaroslav@597: abstract public V remove(Object key); jaroslav@597: }