rt/emul/compact/src/main/java/java/util/Dictionary.java
changeset 772 d382dacfd73f
parent 597 ee8a922f4268
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/rt/emul/compact/src/main/java/java/util/Dictionary.java	Tue Feb 26 16:54:16 2013 +0100
     1.3 @@ -0,0 +1,155 @@
     1.4 +/*
     1.5 + * Copyright (c) 1995, 2004, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +
    1.29 +package java.util;
    1.30 +
    1.31 +/**
    1.32 + * The <code>Dictionary</code> class is the abstract parent of any
    1.33 + * class, such as <code>Hashtable</code>, which maps keys to values.
    1.34 + * Every key and every value is an object. In any one <tt>Dictionary</tt>
    1.35 + * object, every key is associated with at most one value. Given a
    1.36 + * <tt>Dictionary</tt> and a key, the associated element can be looked up.
    1.37 + * Any non-<code>null</code> object can be used as a key and as a value.
    1.38 + * <p>
    1.39 + * As a rule, the <code>equals</code> method should be used by
    1.40 + * implementations of this class to decide if two keys are the same.
    1.41 + * <p>
    1.42 + * <strong>NOTE: This class is obsolete.  New implementations should
    1.43 + * implement the Map interface, rather than extending this class.</strong>
    1.44 + *
    1.45 + * @author  unascribed
    1.46 + * @see     java.util.Map
    1.47 + * @see     java.lang.Object#equals(java.lang.Object)
    1.48 + * @see     java.lang.Object#hashCode()
    1.49 + * @see     java.util.Hashtable
    1.50 + * @since   JDK1.0
    1.51 + */
    1.52 +public abstract
    1.53 +class Dictionary<K,V> {
    1.54 +    /**
    1.55 +     * Sole constructor.  (For invocation by subclass constructors, typically
    1.56 +     * implicit.)
    1.57 +     */
    1.58 +    public Dictionary() {
    1.59 +    }
    1.60 +
    1.61 +    /**
    1.62 +     * Returns the number of entries (distinct keys) in this dictionary.
    1.63 +     *
    1.64 +     * @return  the number of keys in this dictionary.
    1.65 +     */
    1.66 +    abstract public int size();
    1.67 +
    1.68 +    /**
    1.69 +     * Tests if this dictionary maps no keys to value. The general contract
    1.70 +     * for the <tt>isEmpty</tt> method is that the result is true if and only
    1.71 +     * if this dictionary contains no entries.
    1.72 +     *
    1.73 +     * @return  <code>true</code> if this dictionary maps no keys to values;
    1.74 +     *          <code>false</code> otherwise.
    1.75 +     */
    1.76 +    abstract public boolean isEmpty();
    1.77 +
    1.78 +    /**
    1.79 +     * Returns an enumeration of the keys in this dictionary. The general
    1.80 +     * contract for the keys method is that an <tt>Enumeration</tt> object
    1.81 +     * is returned that will generate all the keys for which this dictionary
    1.82 +     * contains entries.
    1.83 +     *
    1.84 +     * @return  an enumeration of the keys in this dictionary.
    1.85 +     * @see     java.util.Dictionary#elements()
    1.86 +     * @see     java.util.Enumeration
    1.87 +     */
    1.88 +    abstract public Enumeration<K> keys();
    1.89 +
    1.90 +    /**
    1.91 +     * Returns an enumeration of the values in this dictionary. The general
    1.92 +     * contract for the <tt>elements</tt> method is that an
    1.93 +     * <tt>Enumeration</tt> is returned that will generate all the elements
    1.94 +     * contained in entries in this dictionary.
    1.95 +     *
    1.96 +     * @return  an enumeration of the values in this dictionary.
    1.97 +     * @see     java.util.Dictionary#keys()
    1.98 +     * @see     java.util.Enumeration
    1.99 +     */
   1.100 +    abstract public Enumeration<V> elements();
   1.101 +
   1.102 +    /**
   1.103 +     * Returns the value to which the key is mapped in this dictionary.
   1.104 +     * The general contract for the <tt>isEmpty</tt> method is that if this
   1.105 +     * dictionary contains an entry for the specified key, the associated
   1.106 +     * value is returned; otherwise, <tt>null</tt> is returned.
   1.107 +     *
   1.108 +     * @return  the value to which the key is mapped in this dictionary;
   1.109 +     * @param   key   a key in this dictionary.
   1.110 +     *          <code>null</code> if the key is not mapped to any value in
   1.111 +     *          this dictionary.
   1.112 +     * @exception NullPointerException if the <tt>key</tt> is <tt>null</tt>.
   1.113 +     * @see     java.util.Dictionary#put(java.lang.Object, java.lang.Object)
   1.114 +     */
   1.115 +    abstract public V get(Object key);
   1.116 +
   1.117 +    /**
   1.118 +     * Maps the specified <code>key</code> to the specified
   1.119 +     * <code>value</code> in this dictionary. Neither the key nor the
   1.120 +     * value can be <code>null</code>.
   1.121 +     * <p>
   1.122 +     * If this dictionary already contains an entry for the specified
   1.123 +     * <tt>key</tt>, the value already in this dictionary for that
   1.124 +     * <tt>key</tt> is returned, after modifying the entry to contain the
   1.125 +     *  new element. <p>If this dictionary does not already have an entry
   1.126 +     *  for the specified <tt>key</tt>, an entry is created for the
   1.127 +     *  specified <tt>key</tt> and <tt>value</tt>, and <tt>null</tt> is
   1.128 +     *  returned.
   1.129 +     * <p>
   1.130 +     * The <code>value</code> can be retrieved by calling the
   1.131 +     * <code>get</code> method with a <code>key</code> that is equal to
   1.132 +     * the original <code>key</code>.
   1.133 +     *
   1.134 +     * @param      key     the hashtable key.
   1.135 +     * @param      value   the value.
   1.136 +     * @return     the previous value to which the <code>key</code> was mapped
   1.137 +     *             in this dictionary, or <code>null</code> if the key did not
   1.138 +     *             have a previous mapping.
   1.139 +     * @exception  NullPointerException  if the <code>key</code> or
   1.140 +     *               <code>value</code> is <code>null</code>.
   1.141 +     * @see        java.lang.Object#equals(java.lang.Object)
   1.142 +     * @see        java.util.Dictionary#get(java.lang.Object)
   1.143 +     */
   1.144 +    abstract public V put(K key, V value);
   1.145 +
   1.146 +    /**
   1.147 +     * Removes the <code>key</code> (and its corresponding
   1.148 +     * <code>value</code>) from this dictionary. This method does nothing
   1.149 +     * if the <code>key</code> is not in this dictionary.
   1.150 +     *
   1.151 +     * @param   key   the key that needs to be removed.
   1.152 +     * @return  the value to which the <code>key</code> had been mapped in this
   1.153 +     *          dictionary, or <code>null</code> if the key did not have a
   1.154 +     *          mapping.
   1.155 +     * @exception NullPointerException if <tt>key</tt> is <tt>null</tt>.
   1.156 +     */
   1.157 +    abstract public V remove(Object key);
   1.158 +}