home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / java.z / Dictionary.java < prev    next >
Text File  |  1996-05-03  |  3KB  |  89 lines

  1. /*
  2.  * @(#)Dictionary.java    1.1 95/08/07
  3.  * 
  4.  * Copyright (c) 1995 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * Permission to use, copy, modify, and distribute this software and its
  7.  * documentation for NON-COMMERCIAL purposes and without fee is hereby
  8.  * granted provided that this copyright notice appears in all copies. Please
  9.  * refer to the file "copyright.html" for further important copyright and
  10.  * licensing information.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
  15.  * OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY
  16.  * LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR
  17.  * ITS DERIVATIVES.
  18.  */
  19.  
  20. package java.util;
  21.  
  22. /**
  23.  * The Dictionary class is the abstract parent of Hashtable, which maps
  24.  * keys to values. Any object can be used as a key and/or value.  
  25.  *
  26.  * @see java.util.Hashtable
  27.  * @see java.lang.Object#hashCode
  28.  * @see java.lang.Object#equals
  29.  * @version     1.1, 07 Aug 1995
  30.  */
  31. public abstract
  32. class Dictionary {
  33.     /**
  34.      * Returns the number of elements contained within the Dictionary. 
  35.      */
  36.     abstract public int size();
  37.  
  38.     /**
  39.      * Returns true if the Dictionary contains no elements.
  40.      */
  41.     abstract public boolean isEmpty();
  42.  
  43.     /**
  44.      * Returns an enumeration of the Dictionary's keys.
  45.      * @see Dictionary#elements
  46.      * @see Enumeration
  47.      */
  48.     abstract public Enumeration keys();
  49.  
  50.     /**
  51.      * Returns an enumeration of the elements. Use the Enumeration methods 
  52.      * on the returned object to fetch the elements sequentially.
  53.      * @see Dictionary#keys
  54.      * @see Enumeration
  55.      */
  56.     abstract public Enumeration elements();
  57.  
  58.     /**
  59.      * Gets the object associated with the specified key in the Dictionary.
  60.      * @param key the key in the hash table
  61.      * @returns the element for the key, or null if the key
  62.      *         is not defined in the hash table.
  63.      * @see Dictionary#put
  64.      */
  65.     abstract public Object get(Object key);
  66.  
  67.     /**
  68.      * Puts the specified element into the Dictionary, using the specified
  69.      * key.  The element may be retrieved by doing a get() with the same 
  70.      * key.  The key and the element cannot be null.
  71.      * @param key the specified hashtable key
  72.      * @param value the specified element 
  73.      * @return the old value of the key, or null if it did not have one.
  74.      * @exception NullPointerException If the value of the specified
  75.      * element is null.
  76.      * @see Dictionary#get
  77.      */
  78.     abstract public Object put(Object key, Object value);
  79.  
  80.     /**
  81.      * Removes the element corresponding to the key. Does nothing if the
  82.      * key is not present.
  83.      * @param key the key that needs to be removed
  84.      * @return the value of key, or null if the key was not found.
  85.      */
  86.     abstract public Object remove(Object key);
  87. }
  88.  
  89.