Overview | Package | Class | Tree | Index | Help

Oracle® Coherence Java API Reference
v3.5.3
E15583-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.tangosol.util
Class ChainedMap

    java.lang.Object
      java.util.AbstractMap
          com.tangosol.util.ChainedMap

All Implemented Interfaces:
  java.io.Serializable, java.util.Map

    public class ChainedMap

extends java.util.AbstractMap
implements java.io.Serializable

Chains two maps into one virtual map.

The contents of the first map take precedence over the contents in the second map. If there are already entries in the two maps when this map is constructed, then the keys in the second map that are also in the first map will be removed from the second map.

Since:
  Coherence 2.4
Author:
  cp 2004.03.24

Nested Class Summary
`class` | `ChainedMap.EntrySet` A set of entries backed by this map.

Nested classes/interfaces inherited from interface java.util.Map
`java.util.Map.Entry`

Field Summary
`protected java.util.Map` | `m_mapFirst` The first map.
`protected java.util.Map` | `m_mapSecond` The second map.
`protected ChainedMap.EntrySet` | `m_setEntries` The entry set.

Constructor Summary
`ChainedMap(java.util.Map mapFirst, java.util.Map mapSecond)` Construct a ChainedMap out of two maps.

Method Summary
`boolean` | `containsKey(java.lang.Object oKey)` Returns `true` if this map contains a mapping for the specified key.
`java.util.Set` | `entrySet()` Returns a set view of the mappings contained in this map.
`java.lang.Object` | `get(java.lang.Object oKey)` Returns the value to which this map maps the specified key.
`java.util.Map` | `getFirstMap()` Get the first (front) map.
`java.util.Map` | `getSecondMap()` Get the second (back) map.
`protected ChainedMap.EntrySet` | `instantiateEntrySet()` (Factory pattern) Instantiate an Entry Set or subclass thereof.
`java.lang.Object` | `put(java.lang.Object oKey, java.lang.Object oValue)` Associates the specified value with the specified key in this map.
`java.lang.Object` | `remove(java.lang.Object oKey)` Removes the mapping for this key from this map if present.
`int` | `size()` Returns the number of key-value mappings in this map.

Methods inherited from class java.util.AbstractMap
`clear, clone, containsValue, equals, hashCode, isEmpty, keySet, putAll, toString, values`

Field Detail

### m_mapFirst

    protected java.util.Map m_mapFirst

  The first map.

### m_mapSecond

    protected java.util.Map m_mapSecond

  The second map.

### m_setEntries

    protected transient ChainedMap.EntrySet m_setEntries

  The entry set.

Constructor Detail

### ChainedMap

    public ChainedMap(java.util.Map mapFirst,
                      java.util.Map mapSecond)

  Construct a ChainedMap out of two maps.

  Parameters:
    `mapFirst` - the map whose mappings are to be placed in this map.

Method Detail

### getFirstMap

    public java.util.Map getFirstMap()

  Get the first (front) map.

  Note: direct modifications of the returned map may cause an unpredictable behavior of the ChainedMap.

  Returns:
    the first Map

### getSecondMap

    public java.util.Map getSecondMap()

  Get the second (back) map.

  Note: direct modifications of the returned map may cause an unpredictable behavior of the ChainedMap.

  Returns:
    the second Map

### size

    public int size()

  Returns the number of key-value mappings in this map. If the map contains more than `Integer.MAX_VALUE` elements, returns `Integer.MAX_VALUE`.

  Specified by:
    `size` in interface `java.util.Map`
  Overrides:
    `size` in class `java.util.AbstractMap`
  Returns:
    the number of key-value mappings in this map

### containsKey

    public boolean containsKey(java.lang.Object oKey)

  Returns `true` if this map contains a mapping for the specified key.

  Specified by:
    `containsKey` in interface `java.util.Map`
  Overrides:
    `containsKey` in class `java.util.AbstractMap`
  Parameters:
    `oKey` - key whose presence in this map is to be tested
  Returns:
    `true` if this map contains a mapping for the specified key

### get

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

  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.

  Specified by:
    `get` in interface `java.util.Map`
  Overrides:
    `get` in class `java.util.AbstractMap`
  Parameters:
    `oKey` - key whose associated value is to be returned
  Returns:
    the value to which this map maps the specified key, or `null` if the map contains no mapping for this key

### put

    public java.lang.Object put(java.lang.Object oKey,
                                java.lang.Object oValue)

  Associates the specified value with the specified key in this map. If the map previously contained a mapping for this key, the old value is replaced.

  Specified by:
    `put` in interface `java.util.Map`
  Overrides:
    `put` in class `java.util.AbstractMap`
  Parameters:
    `oKey` - key with which the specified value is to be associated
    `oValue` - 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

### remove

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

  Removes the mapping for this key from this map if present.

  Specified by:
    `remove` in interface `java.util.Map`
  Overrides:
    `remove` in class `java.util.AbstractMap`
  Parameters:
    `oKey` - 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

### entrySet

    public java.util.Set entrySet()

  Returns a set view of the mappings contained in this map. Each element in the returned set is a `Map.Entry`. 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 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.

  Specified by:
    `entrySet` in interface `java.util.Map`
  Specified by:
    `entrySet` in class `java.util.AbstractMap`
  Returns:
    a set view of the mappings contained in this map.

### instantiateEntrySet

    protected ChainedMap.EntrySet instantiateEntrySet()

  (Factory pattern) Instantiate an Entry Set or subclass thereof. This method permits inheriting classes to easily override the implementation of the EntrySet object.

  Returns:
    an instance of EntrySet

Overview | Package | Class | Tree | Index | Help

Oracle® Coherence Java API Reference
v3.5.3
E15583-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2010, Oracle. All rights reserved.