java.util.Dictionary翻译

 
JavaTM 2 Platform
Std. Ed. v1.4.2

java.util
Class Dictionary

java.lang.Object
  extended byjava.util.Dictionary
Direct Known Subclasses:
Hashtable

public abstract class Dictionary extends Object

The Dictionary class is the abstract parent of any class, such as Hashtable, which maps keys to values. Every key and every value is an object. In any one Dictionary object, every key is associated with at most one value. Given a Dictionary and a key, the associated element can be looked up. Any non-null object can be used as a key and as a value. Dictionary是一个抽象类,可以作为某些映射key与值的类的父类,比如Hashtable。 每个key和每个值都是一个对象。在任意一个Dictionary对象中,每一个key至多只能与一个 值关联。给定Dictionary和key,可以查找相关联的元素。任何非null对象都可以作为key或值。

As a rule, the equals method should be used by implementations of this class to decide if two keys are the same. 原则上equals方法应当在该类的实现中使用,来确定两个key是否相同。

NOTE: This class is obsolete. New implementations should implement the Map interface, rather than extending this class. 注意:该类已过时。新的实现应该实现Map接口,而不是继承该类。

Since:
JDK1.0
See Also:
Map , Object.equals(java.lang.Object) , Object.hashCode() , Hashtable

Constructor Summary
Dictionary()
          Sole constructor. 唯一的构造函数。
 
Method Summary
abstract  Enumerationelements()
          Returns an enumeration of the values in this dictionary. 返回dictionary中值的枚举。
abstract  Objectget(Object key)
          Returns the value to which the key is mapped in this dictionary. 返回dictionary中key的映射值。
abstract  booleanisEmpty()
          Tests if this dictionary maps no keys to value. 测试该dictionary是否有键值的映射。
abstract  Enumerationkeys()
          Returns an enumeration of the keys in this dictionary. 返回dictionary中key的枚举。
abstract  Objectput(Object key, Object value)
          Maps the specified key to the specified value in this dictionary. 在dictionary中为指定的key和指定的value建立映射。
abstract  Objectremove(Object key)
          Removes the key (and its corresponding value) from this dictionary. 从dictionary中删除key(和它的相应值)。
abstract  intsize()
          Returns the number of entries (dinstint keys) in this dictionary. 返回dictionary中项的数目(不同的key)。
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Dictionary

public Dictionary()
Sole constructor. (For invocation by subclass constructors, typically implicit.) 唯一的构造函数。(通常被子类构造函数隐式调用)

Method Detail

size

public abstract int size()
Returns the number of entries (dinstint keys) in this dictionary. 返回dictionary中项的数目(不同的key)。

Returns:
the number of keys in this dictionary. dictionary中key的数目。

isEmpty

public abstract boolean isEmpty()
Tests if this dictionary maps no keys to value. The general contract for the isEmpty method is that the result is true if and only if this dictionary contains no entries. 测试该dictionary是否有键值的映射。isEmpty方法通常约定为:只有当dictionary中不含项时结果才为true。

Returns:
true if this dictionary maps no keys to values; false otherwise. 如果dictionary不含键值的映射,返回true,否则为false。

keys

public abstract Enumeration keys()
Returns an enumeration of the keys in this dictionary. The general contract for the keys method is that an Enumeration object is returned that will generate all the keys for which this dictionary contains entries. 返回dictionary中key的枚举。keys方法通常约定为:返回Enumeration对象,包含dictionary所含项的所有key。

Returns:
an enumeration of the keys in this dictionary. dictionary中key的枚举。
See Also:
elements() , Enumeration

elements

public abstract Enumeration elements()
Returns an enumeration of the values in this dictionary. The general contract for the elements method is that an Enumeration is returned that will generate all the elements contained in entries in this dictionary. 返回dictionary中值的枚举。elements方法通常约定为:返回Enumeration对象,元素等于dictionary的所含项。

Returns:
an enumeration of the values in this dictionary. dictionary中值的枚举。
See Also:
keys() , Enumeration

get

public abstract Object get(Object key)
Returns the value to which the key is mapped in this dictionary. The general contract for the isEmpty method is that if this dictionary contains an entry for the specified key, the associated value is returned; otherwise, null is returned. 返回dictionary中key的映射值。get方法通常约定为:如果该dictionary包含指定key的项,返回关联值,否则返回null。

Parameters:
key - a key in this dictionary. dictionary中的key。 null if the key is not mapped to any value in this dictionary. 如果dictionary中该key没有映射任何值。
Returns:
the value to which the key is mapped in this dictionary; dictionary中key的映射值。
Throws:
NullPointerException - if the key is null 如果key为null时抛出。.
See Also:
put(java.lang.Object, java.lang.Object)

put

public abstract Object put(Object key,
                           Object value)
Maps the specified key to the specified value in this dictionary. Neither the key nor the value can be null. 在dictionary中为指定的key和指定的value建立映射。key和value都不能为null。

If this dictionary already contains an entry for the specified key, the value already in this dictionary for that key is returned, after modifying the entry to contain the new element.

If this dictionary does not already have an entry for the specified key, an entry is created for the specified key and value, and null is returned. 如果dictionary已经包含了一个指定key的项,在修改项使包含新的元素后,返回该key在dictionary中的原值。 如果dictionary不含一个指定key的项,则创建一个指定key和value的项,返回null。

The value can be retrieved by calling the get method with a key that is equal to the original key. 返回的值可以通过调用get方法获取(key为原key)。

Parameters:
key - the hashtable key. hash表中的key。
value - the value. 值。
Returns:
the previous value to which the key was mapped in this dictionary, or null if the key did not have a previous mapping. dictionary中key映射的原值,如果该key原本没有映射,返回null。
Throws:
NullPointerException - if the key or value is null key或value为null时抛出。.
See Also:
Object.equals(java.lang.Object) , get(java.lang.Object)

remove

public abstract Object remove(Object key)
Removes the key (and its corresponding value) from this dictionary. This method does nothing if the key is not in this dictionary. 从dictionary中删除key(和它的相应值)。如果dictionary中没有该key,方法什么也不做。

Parameters:
key - the key that needs to be removed. 要被删除的key。
Returns:
the value to which the key had been mapped in this dictionary, or null if the key did not have a mapping. key在dictionary中映射的值,如果该key没有映射,返回null。
Throws:
NullPointerException - if key is null. 如果key为null时抛出。

JavaTM 2 Platform
Std. Ed. v1.4.2

Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation . That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Copyright 2003 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值