src/java.base/share/classes/java/util/Dictionary.java
author jboes
Fri, 20 Sep 2019 11:07:52 +0100
changeset 58242 94bb65cb37d3
parent 47216 71c04702a3d5
permissions -rw-r--r--
8230648: Replace @exception tag with @throws in java.base Summary: Minor coding style update of javadoc tag in any file in java.base Reviewed-by: prappo, lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 47216
diff changeset
     2
 * Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.util;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/**
32108
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
    29
 * The {@code Dictionary} class is the abstract parent of any
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
    30
 * class, such as {@code Hashtable}, which maps keys to values.
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
    31
 * Every key and every value is an object. In any one {@code Dictionary}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * object, every key is associated with at most one value. Given a
32108
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
    33
 * {@code Dictionary} and a key, the associated element can be looked up.
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
    34
 * Any non-{@code null} object can be used as a key and as a value.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * <p>
32108
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
    36
 * As a rule, the {@code equals} method should be used by
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * implementations of this class to decide if two keys are the same.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * <strong>NOTE: This class is obsolete.  New implementations should
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * implement the Map interface, rather than extending this class.</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * @author  unascribed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * @see     java.util.Map
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * @see     java.lang.Object#equals(java.lang.Object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @see     java.lang.Object#hashCode()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * @see     java.util.Hashtable
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 5506
diff changeset
    47
 * @since   1.0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
public abstract
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
class Dictionary<K,V> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * Sole constructor.  (For invocation by subclass constructors, typically
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * implicit.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    public Dictionary() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * Returns the number of entries (distinct keys) in this dictionary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * @return  the number of keys in this dictionary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 32108
diff changeset
    63
    public abstract int size();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * Tests if this dictionary maps no keys to value. The general contract
32108
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
    67
     * for the {@code isEmpty} method is that the result is true if and only
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * if this dictionary contains no entries.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     *
32108
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
    70
     * @return  {@code true} if this dictionary maps no keys to values;
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
    71
     *          {@code false} otherwise.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 32108
diff changeset
    73
    public abstract boolean isEmpty();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * Returns an enumeration of the keys in this dictionary. The general
32108
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
    77
     * contract for the keys method is that an {@code Enumeration} object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * is returned that will generate all the keys for which this dictionary
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * contains entries.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * @return  an enumeration of the keys in this dictionary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * @see     java.util.Dictionary#elements()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * @see     java.util.Enumeration
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 32108
diff changeset
    85
    public abstract Enumeration<K> keys();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * Returns an enumeration of the values in this dictionary. The general
32108
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
    89
     * contract for the {@code elements} method is that an
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
    90
     * {@code Enumeration} is returned that will generate all the elements
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * contained in entries in this dictionary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @return  an enumeration of the values in this dictionary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * @see     java.util.Dictionary#keys()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * @see     java.util.Enumeration
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 32108
diff changeset
    97
    public abstract Enumeration<V> elements();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * Returns the value to which the key is mapped in this dictionary.
32108
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
   101
     * The general contract for the {@code isEmpty} method is that if this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * dictionary contains an entry for the specified key, the associated
32108
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
   103
     * value is returned; otherwise, {@code null} is returned.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * @return  the value to which the key is mapped in this dictionary;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * @param   key   a key in this dictionary.
32108
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
   107
     *          {@code null} if the key is not mapped to any value in
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     *          this dictionary.
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 47216
diff changeset
   109
     * @throws    NullPointerException if the {@code key} is {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * @see     java.util.Dictionary#put(java.lang.Object, java.lang.Object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 32108
diff changeset
   112
    public abstract V get(Object key);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    /**
32108
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
   115
     * Maps the specified {@code key} to the specified
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
   116
     * {@code value} in this dictionary. Neither the key nor the
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
   117
     * value can be {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * If this dictionary already contains an entry for the specified
32108
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
   120
     * {@code key}, the value already in this dictionary for that
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
   121
     * {@code key} is returned, after modifying the entry to contain the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     *  new element. <p>If this dictionary does not already have an entry
32108
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
   123
     *  for the specified {@code key}, an entry is created for the
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
   124
     *  specified {@code key} and {@code value}, and {@code null} is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     *  returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * <p>
32108
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
   127
     * The {@code value} can be retrieved by calling the
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
   128
     * {@code get} method with a {@code key} that is equal to
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
   129
     * the original {@code key}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @param      key     the hashtable key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * @param      value   the value.
32108
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
   133
     * @return     the previous value to which the {@code key} was mapped
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
   134
     *             in this dictionary, or {@code null} if the key did not
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     *             have a previous mapping.
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 47216
diff changeset
   136
     * @throws     NullPointerException  if the {@code key} or
32108
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
   137
     *               {@code value} is {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * @see        java.lang.Object#equals(java.lang.Object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * @see        java.util.Dictionary#get(java.lang.Object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 32108
diff changeset
   141
    public abstract V put(K key, V value);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    /**
32108
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
   144
     * Removes the {@code key} (and its corresponding
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
   145
     * {@code value}) from this dictionary. This method does nothing
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
   146
     * if the {@code key} is not in this dictionary.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * @param   key   the key that needs to be removed.
32108
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
   149
     * @return  the value to which the {@code key} had been mapped in this
aa5490a167ee 8133188: docs: replace <tt> tags (obsolete in html5) for java.util
avstepan
parents: 25859
diff changeset
   150
     *          dictionary, or {@code null} if the key did not have a
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     *          mapping.
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 47216
diff changeset
   152
     * @throws    NullPointerException if {@code key} is {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 32108
diff changeset
   154
    public abstract V remove(Object key);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
}