com.xavax.xstore.util
Interface CollectionMap

All Superinterfaces:
Collection
All Known Implementing Classes:
AbstractCollectionMap

public interface CollectionMap
extends Collection

CollectionMap is the interface for containers that implements the Collection interface but delegate to a Map class. CollectionMap retains the best feature of a Map which is the ability to locate an object quickly using a key. While a CollectionMap cannot be cast as a Map, the implementing class can choose to implement the map method which returns the underlying map.

The persistence framework only supports containers that implement the Collection interface. CollectionMap makes it possible to use a Map to model a 1:n association.


Method Summary
 boolean containsKey(Object key)
          Returns true if this map contains a mapping for the specified key.
 Object get(Object key)
          Returns the value to which this map maps the specified key.
 Object makeKey(Object o)
          Create a key to which a value can be associated.
 Object put(Object key, Object value)
          Associates the specified value with the specified key in this map.
 Object removeKey(Object key)
          Removes the mapping for the specified key from this collection.
 
Methods inherited from interface Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Method Detail

containsKey

public boolean containsKey(Object key)
Returns true if this map contains a mapping for the specified key. More formally, returns true if and only if this map contains at a mapping for a key k such that (key==null ? k==null : key.equals(k)). (There can be at most one such mapping.)

Parameters:
key - key whose presence in this map is to be tested.
Returns:
true if this map contains a mapping for the specified key.

get

public Object get(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.

More formally, if this map contains a mapping from a key k to a value v such that (key==null ? k==null : key.equals(k)), then this method returns v; otherwise it returns null. (There can be at most one such mapping.)

Parameters:
key - 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.

makeKey

public Object makeKey(Object o)
Create a key to which a value can be associated. This method is used to create the key needed when calling the get and put methods of the underlying map.

Parameters:
o - the value for which a key is to be computed.
Returns:
a key for the specified value.

put

public Object put(Object key,
                  Object value)
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 by the specified value. (A map m is said to contain a mapping for a key k if and only if m.containsKey(k) would return true.))

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.

removeKey

public Object removeKey(Object key)
Removes the mapping for the specified key from this collection. More formally, if this map contains a mapping from key k to value v such that (key==null ? k==null : key.equals(k)), that mapping is removed. Returns the value to which the map previously associated the key, or null if the map contained no mapping for this key.

Parameters:
key - key whose mapping is to be removed from the collection.
Returns:
the value previously associated with the key.