Overview | Package | Class | Tree | Deprecated | Index | Help
| 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

## oracle.jbo.server.java.util
Interface Map

public interface Map

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.

Since:
  JDK1.2
See Also:
  `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

### size

    public int size()

  Returns the number of key-value mappings in this Map.
  Since:
    JDK1.2

### isEmpty

    public boolean isEmpty()

  Returns true if this Map contains no key-value mappings.
  Since:
    JDK1.2

### containsKey

    public boolean containsKey(java.lang.Object key)

  Returns true if this Map contains a mapping for the specified key.
  Parameters:
    `key` - key whose presence in this Map is to be tested.
  Throws:
    `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.
  Since:
    JDK1.2

### containsValue

    public boolean containsValue(java.lang.Object value)

  Returns true if this Map maps one or more keys to the specified value. More formally, returns true if and only if this Map contains at least one mapping to a 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.
  Parameters:
    `value` - value whose presence in this Map is to be tested.
  Since:
    JDK1.2

### get

    public java.lang.Object get(java.lang.Object key)

  Returns the value to which this Map maps the specified key. Returns null if the Map contains no mapping for this key. A return value of null does not necessarily indicate that the Map contains no mapping for the key; it's also possible that the Map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.
  Parameters:
    `key` - key whose associated value is to be returned.
  Throws:
    `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.
  Since:
    JDK1.2
  See Also:
    `containsKey(Object)`

### put

    public 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). If the Map previously contained a mapping for this key, the old value is replaced.
  Parameters:
    `key` - key with which the specified value is to be associated.
    `value` - value to be associated with the specified key.
  Returns:
    previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the Map previously associated null with the specified key, if the implementation supports null values.
  Throws:
    `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.
  Since:
    JDK1.2

### remove

    public java.lang.Object remove(java.lang.Object key)

  Removes the mapping for this key from this Map if present (optional operation).
  Parameters:
    `key` - key whose mapping is to be removed from the Map.
  Returns:
    previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the Map previously associated null with the specified key, if the implementation supports null values.
  Throws:
    `UnsupportedOperationException` - remove is not supported by this Map.
  Since:
    JDK1.2

### putAll

    public void putAll(Map t)

  Copies all of the mappings from the specified Map to this Map (optional operation). These mappings will replace any mappings that this Map had for any of the keys currently in the specified Map.
  Parameters:
    `t` - Mappings to be stored in this Map.
  Throws:
    `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.
  Since:
    JDK1.2

### clear

    public void clear()

  Removes all mappings from this Map (optional operation).
  Throws:
    `UnsupportedOperationException` - clear is not supported by this Map.
  Since:
    JDK1.2

### keySet

    public Set keySet()

  Returns a Set view of the keys contained in this Map. The Set is backed by the Map, so changes to the Map are reflected in the Set, and vice-versa. If the Map is modified while while an iteration over the Set is in progress, the results of the iteration are undefined. The Set supports element removal, which removes the corresponding mapping from the Map, via the Iterator.remove, Set.remove, removeAll retainAll, and clear operations. It does not support the add or addAll operations.
  Since:
    JDK1.2

### values

    public Collection values()

  Returns a Collection view of the values contained in this Map. The Collection is backed by the Map, so changes to the Map are reflected in the Collection, and vice-versa. If the Map is modified while while an iteration over the Collection is in progress, the results of the iteration are undefined. The Collection supports element removal, which removes the corresponding mapping from the Map, via the Iterator.remove, Collection.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.
  Since:
    JDK1.2

### entries

    public Collection entries()

  Returns a Collection view of the mappings contained in this Map. Each element in the returned collection is a Map.Entry. The Collection is backed by the Map, so changes to the Map are reflected in the Collection, and vice-versa. If the Map is modified while while an iteration over the Collection is in progress, the results of the iteration are undefined. The Collection supports element removal, which removes the corresponding mapping from the Map, via the Iterator.remove, Collection.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.
  Since:
    JDK1.2

### equals

    public boolean equals(java.lang.Object o)

  Compares the specified Object with this Map for equality. Returns true if the given object is also a Map and the two Maps represent the same mappings. More formally, two Maps `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.
  Parameters:
    `o` - Object to be compared for equality with this Map.
  Returns:
    true if the specified Object is equal to this Map.
  Since:
    JDK1.2

### hashCode

    public int hashCode()

  Returns the hash code value for this Map. The hash code of a Map is defined to be the sum of the hashCodes of each Entry in the Map's entries view. This ensures that `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.
  Since:
    JDK1.2
  See Also:
    `hashCode()`, `Object.hashCode()`, `Object.equals(Object)`, `equals(Object)`

Overview | Package | Class | Tree | Deprecated | Index | Help
| 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

Copyright © 1997, 2005, Oracle. All rights reserved.