|
Oracle Application Development Framework Model and Business Components Java API Reference
10g Release 3 (10.1.3) B16005-01 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
An object that maps keys to values. A Map cannot contain duplicate keys; each key can map to at most one value.
This interface takes the place of Dictionary, which was a totally abstract class rather than an interface. This Interface is implemented by HashMap, ArrayMap, TreeMap and Hashtable.
The Map interface provides three Collection views, which allow a Map's contents to be viewed as a Collection of keys, values, or key-value mappings. The order of a Map is defined as the order in which the iterators on the Map's Collection views return their elements. Some Map implementations, like TreeMap and ArrayMap, make specific guarantees as to their order; others, like HashMap, do not.
All general-purpose Map implementation classes should provide two "standard" constructors: A void (no arguments) constructor which creates an empty Map, and a constructor with a single argument of type Map, which creates a new Map with the same key-value mappings as its argument. In effect, the latter constructor allows the user to copy any Map, producing an equivalent Map of the desired class. There is no way to enforce this recommendation (as interfaces cannot contain constructors) but all of the general-purpose Map implementations in the JDK comply.
HashMap, TreeMap, Hashtable, Collection, Set| Method Summary | |
void |
clear()Removes all mappings from this Map (optional operation). |
boolean |
containsKey(java.lang.Object key)Returns true if this Map contains a mapping for the specified key. |
boolean |
containsValue(java.lang.Object value)Returns true if this Map maps one or more keys to the specified value. |
Collection |
entries()Returns a Collection view of the mappings contained in this Map. |
boolean |
equals(java.lang.Object o)Compares the specified Object with this Map for equality. |
java.lang.Object |
get(java.lang.Object key)Returns the value to which this Map maps the specified key. |
int |
hashCode()Returns the hash code value for this Map. |
boolean |
isEmpty()Returns true if this Map contains no key-value mappings. |
Set |
keySet()Returns a Set view of the keys contained in this Map. |
java.lang.Object |
put(java.lang.Object key, java.lang.Object value)Associates the specified value with the specified key in this Map (optional operation). |
void |
putAll(Map t)Copies all of the mappings from the specified Map to this Map (optional operation). |
java.lang.Object |
remove(java.lang.Object key)Removes the mapping for this key from this Map if present (optional operation). |
int |
size()Returns the number of key-value mappings in this Map. |
Collection |
values()Returns a Collection view of the values contained in this Map. |
| Method Detail |
public int size()
public boolean isEmpty()
public boolean containsKey(java.lang.Object key)
key - key whose presence in this Map is to be tested.java.lang.ClassCastException - key is of an inappropriate type for this Map.java.lang.NullPointerException - key is null and this Map does not not permit null keys.public boolean containsValue(java.lang.Object value)
v such that (value==null ? v==null : value.equals(v)). This operation will probably require time linear in the Map size for most implementations of Map.value - value whose presence in this Map is to be tested.public java.lang.Object get(java.lang.Object key)
key - key whose associated value is to be returned.java.lang.ClassCastException - key is of an inappropriate type for this Map.java.lang.NullPointerException - key is null and this Map does not not permit null keys.containsKey(Object)
public java.lang.Object put(java.lang.Object key,
java.lang.Object value)
key - key with which the specified value is to be associated.value - value to be associated with the specified key.UnsupportedOperationException - put operation is not supported by this Map.java.lang.ClassCastException - class of the specified key or value prevents it from being stored in this Map.java.lang.IllegalArgumentException - some aspect of this key or value prevents it from being stored in this Map.java.lang.NullPointerException - this Map does not permit null keys or values, and the specified key or value is null.public java.lang.Object remove(java.lang.Object key)
key - key whose mapping is to be removed from the Map.UnsupportedOperationException - remove is not supported by this Map.public void putAll(Map t)
t - Mappings to be stored in this Map.UnsupportedOperationException - putAll is not supported by this Map.java.lang.ClassCastException - class of a key or value in the specified Map prevents it from being stored in this Map.java.lang.IllegalArgumentException - some aspect of a key or value in the specified Map prevents it from being stored in this Map.java.lang.NullPointerException - this Map does not permit null keys or values, and the specified key or value is null.public void clear()
UnsupportedOperationException - clear is not supported by this Map.public Set keySet()
public Collection values()
public Collection entries()
public boolean equals(java.lang.Object o)
t1 and t2 represent the same mappings if t1.keySet().equals(t2.keySet()) and for every key k in t1.keySet(), (t1.get(k)==null ? t2.get(k)==null : t1.get(k).equals(t2.get(k))) . This ensures that the equals method works properly across different implementations of the Map interface.o - Object to be compared for equality with this Map.public int hashCode()
t1.equals(t2) implies that t1.hashCode()==t2.hashCode() for any two Maps t1 and t2, as required by the general contract of Object.hashCode.hashCode(), Object.hashCode(), Object.equals(Object), equals(Object)
|
Oracle Application Development Framework Model and Business Components Java API Reference
10g Release 3 (10.1.3) B16005-01 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||