java.util

Class Dictionary<K,V>

Known Direct Subclasses:
Hashtable<K,V>

public abstract class Dictionary<K,V>
extends Object

A Dictionary maps keys to values; how it does that is implementation-specific. This is an abstract class which has really gone by the wayside. People at Javasoft are probably embarrassed by it. At this point, it might as well be an interface rather than a class, but it remains this poor, laughable skeleton for the sake of backwards compatibility. At any rate, this was what came before the Map interface in the Collections framework.
Since:
1.0
See Also:
Map, Hashtable

Constructor Summary

Dictionary()
Sole constructor (often called implicitly).

Method Summary

abstract Enumeration
elements()
Returns an Enumeration of the values in this Dictionary.
abstract V
get(Object key)
Returns the value associated with the supplied key, or null if no such value exists.
abstract boolean
isEmpty()
Returns true when there are no elements in this Dictionary.
abstract Enumeration
keys()
Returns an Enumeration of the keys in this Dictionary
abstract V
put(K key, V value)
Inserts a new value into this Dictionary, located by the supplied key.
abstract V
remove(Object key)
Removes from the Dictionary the value located by the given key.
abstract int
size()
Returns the number of values currently in this Dictionary.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

Dictionary

public Dictionary()
Sole constructor (often called implicitly).

Method Details

elements

public abstract Enumeration elements()
Returns an Enumeration of the values in this Dictionary.
Returns:
an Enumeration of the values
See Also:
keys()

get

public abstract V get(Object key)
Returns the value associated with the supplied key, or null if no such value exists. Since Dictionaries are not allowed null keys or elements, a null result always means the key is not present.
Parameters:
key - the key to use to fetch the value
Returns:
the mapped value
Throws:
NullPointerException - if key is null
See Also:
put(Object, Object)

isEmpty

public abstract boolean isEmpty()
Returns true when there are no elements in this Dictionary.
Returns:
size() == 0

keys

public abstract Enumeration keys()
Returns an Enumeration of the keys in this Dictionary
Returns:
an Enumeration of the keys
See Also:
elements()

put

public abstract V put(K key,
                      V value)
Inserts a new value into this Dictionary, located by the supplied key. Dictionary does not support null keys or values, so a null return can safely be interpreted as adding a new key.
Parameters:
key - the key which locates the value
value - the value to put into the Dictionary
Returns:
the previous value of the key, or null if there was none
Throws:
NullPointerException - if key or value is null
See Also:
get(Object)

remove

public abstract V remove(Object key)
Removes from the Dictionary the value located by the given key. A null return safely means that the key was not mapped in the Dictionary.
Parameters:
key - the key used to locate the value to be removed
Returns:
the value associated with the removed key
Throws:
NullPointerException - if key is null

size

public abstract int size()
Returns the number of values currently in this Dictionary.
Returns:
the number of keys in the Dictionary

Dictionary.java -- an abstract (and essentially worthless) class which is Hashtable's superclass Copyright (C) 1998, 2001, 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.