Source Home >> Java Source 1.6.0 >> java.util.Dictionary V 0.09
  • 001/*
  • 002 * @(#)Dictionary.java 1.24 05/11/17
  • 003 *
  • 004 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
  • 005 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  • 006 */
  • 007
  • 008package java.util;
  • 009
  • 010/**
  • 011 * The <code>Dictionary</code> class is the abstract parent of any
  • 012 * class, such as <code>Hashtable</code>, which maps keys to values.
  • 013 * Every key and every value is an object. In any one <tt>Dictionary</tt>
  • 014 * object, every key is associated with at most one value. Given a
  • 015 * <tt>Dictionary</tt> and a key, the associated element can be looked up.
  • 016 * Any non-<code>null</code> object can be used as a key and as a value.
  • 017 * <p>
  • 018 * As a rule, the <code>equals</code> method should be used by
  • 019 * implementations of this class to decide if two keys are the same.
  • 020 * <p>
  • 021 * <strong>NOTE: This class is obsolete. New implementations should
  • 022 * implement the Map interface, rather than extending this class.</strong>
  • 023 *
  • 024 * @author unascribed
  • 025 * @version 1.24, 11/17/05
  • 026 * @see java.util.Map
  • 027 * @see java.lang.Object#equals(java.lang.Object)
  • 028 * @see java.lang.Object#hashCode()
  • 029 * @see java.util.Hashtable
  • 030 * @since JDK1.0
  • 031 */
  • 032public abstract
  • 033class Dictionary<K,V> {
  • 034 /**
  • 035 * Sole constructor. (For invocation by subclass constructors, typically
  • 036 * implicit.)
  • 037 */
  • 038 public Dictionary() {
  • 039 }
  • 040
  • 041 /**
  • 042 * Returns the number of entries (distinct keys) in this dictionary.
  • 043 *
  • 044 * @return the number of keys in this dictionary.
  • 045 */
  • 046 abstract public int size();
  • 047
  • 048 /**
  • 049 * Tests if this dictionary maps no keys to value. The general contract
  • 050 * for the <tt>isEmpty</tt> method is that the result is true if and only
  • 051 * if this dictionary contains no entries.
  • 052 *
  • 053 * @return <code>true</code> if this dictionary maps no keys to values;
  • 054 * <code>false</code> otherwise.
  • 055 */
  • 056 abstract public boolean isEmpty();
  • 057
  • 058 /**
  • 059 * Returns an enumeration of the keys in this dictionary. The general
  • 060 * contract for the keys method is that an <tt>Enumeration</tt> object
  • 061 * is returned that will generate all the keys for which this dictionary
  • 062 * contains entries.
  • 063 *
  • 064 * @return an enumeration of the keys in this dictionary.
  • 065 * @see java.util.Dictionary#elements()
  • 066 * @see java.util.Enumeration
  • 067 */
  • 068 abstract public Enumeration<K> keys();
  • 069
  • 070 /**
  • 071 * Returns an enumeration of the values in this dictionary. The general
  • 072 * contract for the <tt>elements</tt> method is that an
  • 073 * <tt>Enumeration</tt> is returned that will generate all the elements
  • 074 * contained in entries in this dictionary.
  • 075 *
  • 076 * @return an enumeration of the values in this dictionary.
  • 077 * @see java.util.Dictionary#keys()
  • 078 * @see java.util.Enumeration
  • 079 */
  • 080 abstract public Enumeration<V> elements();
  • 081
  • 082 /**
  • 083 * Returns the value to which the key is mapped in this dictionary.
  • 084 * The general contract for the <tt>isEmpty</tt> method is that if this
  • 085 * dictionary contains an entry for the specified key, the associated
  • 086 * value is returned; otherwise, <tt>null</tt> is returned.
  • 087 *
  • 088 * @return the value to which the key is mapped in this dictionary;
  • 089 * @param key a key in this dictionary.
  • 090 * <code>null</code> if the key is not mapped to any value in
  • 091 * this dictionary.
  • 092 * @exception NullPointerException if the <tt>key</tt> is <tt>null</tt>.
  • 093 * @see java.util.Dictionary#put(java.lang.Object, java.lang.Object)
  • 094 */
  • 095 abstract public V get(Object key);
  • 096
  • 097 /**
  • 098 * Maps the specified <code>key</code> to the specified
  • 099 * <code>value</code> in this dictionary. Neither the key nor the
  • 100 * value can be <code>null</code>.
  • 101 * <p>
  • 102 * If this dictionary already contains an entry for the specified
  • 103 * <tt>key</tt>, the value already in this dictionary for that
  • 104 * <tt>key</tt> is returned, after modifying the entry to contain the
  • 105 * new element. <p>If this dictionary does not already have an entry
  • 106 * for the specified <tt>key</tt>, an entry is created for the
  • 107 * specified <tt>key</tt> and <tt>value</tt>, and <tt>null</tt> is
  • 108 * returned.
  • 109 * <p>
  • 110 * The <code>value</code> can be retrieved by calling the
  • 111 * <code>get</code> method with a <code>key</code> that is equal to
  • 112 * the original <code>key</code>.
  • 113 *
  • 114 * @param key the hashtable key.
  • 115 * @param value the value.
  • 116 * @return the previous value to which the <code>key</code> was mapped
  • 117 * in this dictionary, or <code>null</code> if the key did not
  • 118 * have a previous mapping.
  • 119 * @exception NullPointerException if the <code>key</code> or
  • 120 * <code>value</code> is <code>null</code>.
  • 121 * @see java.lang.Object#equals(java.lang.Object)
  • 122 * @see java.util.Dictionary#get(java.lang.Object)
  • 123 */
  • 124 abstract public V put(K key, V value);
  • 125
  • 126 /**
  • 127 * Removes the <code>key</code> (and its corresponding
  • 128 * <code>value</code>) from this dictionary. This method does nothing
  • 129 * if the <code>key</code> is not in this dictionary.
  • 130 *
  • 131 * @param key the key that needs to be removed.
  • 132 * @return the value to which the <code>key</code> had been mapped in this
  • 133 * dictionary, or <code>null</code> if the key did not have a
  • 134 * mapping.
  • 135 * @exception NullPointerException if <tt>key</tt> is <tt>null</tt>.
  • 136 */
  • 137 abstract public V remove(Object key);
  • 138}

文件:Dictionary.java
包名:java.util
类名:Dictionary
继承:
接口: