home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / main.bin / Dictionary.java < prev    next >
Text File  |  1997-05-20  |  5KB  |  128 lines

  1. /*
  2.  * @(#)Dictionary.java    1.7 97/01/28
  3.  * 
  4.  * Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  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
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  * CopyrightVersion 1.1_beta
  20.  * 
  21.  */
  22.  
  23. package java.util;
  24.  
  25. /**
  26.  * The <code>Dictionary</code> class is the abstract parent of any 
  27.  * class, such as <code>Hashtable</code>, which maps keys to values. 
  28.  * Any non-<code>null</code> object can be used as a key and as a value.
  29.  * <p>
  30.  * As a rule, the <code>equals</code> method should be used by 
  31.  * implementations of this class to decide if two keys are the same. 
  32.  *
  33.  * @author  unascribed
  34.  * @version 1.7, 01/28/97
  35.  * @see     java.lang.Object#equals(java.lang.Object)
  36.  * @see     java.lang.Object#hashCode()
  37.  * @see     java.util.Hashtable
  38.  * @since   JDK1.0
  39.  */
  40. public abstract
  41. class Dictionary {
  42.     /**
  43.      * Returns the number of keys in this dictionary.
  44.      *
  45.      * @return  the number of keys in this dictionary.
  46.      * @since   JDK1.0
  47.      */
  48.     abstract public int size();
  49.  
  50.     /**
  51.      * Tests if this dictionary maps no keys to value.
  52.      *
  53.      * @return  <code>true</code> if this dictionary maps no keys to values;
  54.      *          <code>false</code> otherwise.
  55.      * @since   JDK1.0
  56.      */
  57.     abstract public boolean isEmpty();
  58.  
  59.     /**
  60.      * Returns an enumeration of the keys in this dictionary.
  61.      *
  62.      * @return  an enumeration of the keys in this dictionary.
  63.      * @see     java.util.Dictionary#elements()
  64.      * @see     java.util.Enumeration
  65.      * @since   JDK1.0
  66.      */
  67.     abstract public Enumeration keys();
  68.  
  69.     /**
  70.      * Returns an enumeration of the values in this dictionary.
  71.      * the Enumeration methods on the returned object to fetch the elements
  72.      * sequentially.
  73.      *
  74.      * @return  an enumeration of the values in this dictionary.
  75.      * @see     java.util.Dictionary#keys()
  76.      * @see     java.util.Enumeration
  77.      * @since   JDK1.0
  78.      */
  79.     abstract public Enumeration elements();
  80.  
  81.     /**
  82.      * Returns the value to which the key is mapped in this dictionary.
  83.      *
  84.      * @return  the value to which the key is mapped in this dictionary;
  85.      * @param   key   a key in this dictionary.
  86.      *          <code>null</code> if the key is not mapped to any value in
  87.      *          this dictionary.
  88.      * @see     java.util.Dictionary#put(java.lang.Object, java.lang.Object)
  89.      * @since   JDK1.0
  90.      */
  91.     abstract public Object get(Object key);
  92.  
  93.     /**
  94.      * Maps the specified <code>key</code> to the specified 
  95.      * <code>value</code> in this dictionary. Neither the key nor the 
  96.      * value can be <code>null</code>.
  97.      * <p>
  98.      * The <code>value</code> can be retrieved by calling the 
  99.      * <code>get</code> method with a <code>key</code> that is equal to 
  100.      * the original <code>key</code>. 
  101.      *
  102.      * @param      key     the hashtable key.
  103.      * @param      value   the value.
  104.      * @return     the previous value to which the <code>key</code> was mapped
  105.      *             in this dictionary, or <code>null</code> if the key did not
  106.      *             have a previous mapping.
  107.      * @exception  NullPointerException  if the <code>key</code> or
  108.      *               <code>value</code> is <code>null</code>.
  109.      * @see        java.lang.Object#equals(java.lang.Object)
  110.      * @see        java.util.Dictionary#get(java.lang.Object)
  111.      * @since      JDK1.0
  112.      */
  113.     abstract public Object put(Object key, Object value);
  114.  
  115.     /**
  116.      * Removes the <code>key</code> (and its corresponding 
  117.      * <code>value</code>) from this dictionary. This method does nothing 
  118.      * if the <code>key</code> is not in this dictionary. 
  119.      *
  120.      * @param   key   the key that needs to be removed.
  121.      * @return  the value to which the <code>key</code> had been mapped in this
  122.      *          dictionary, or <code>null</code> if the key did not have a
  123.      *          mapping.
  124.      * @since   JDK1.0
  125.      */
  126.     abstract public Object remove(Object key);
  127. }
  128.