com.xavax.xstore.util
Class AbstractCollectionMap

Object
  extended byAbstractCollectionMap
All Implemented Interfaces:
Collection, CollectionMap

public abstract class AbstractCollectionMap
extends Object
implements CollectionMap

AbstractCollectionMap implements all methods of the CollectionMap interface except makeKey and is intended to be used as an abstract base class for containers that need Map capabilities.


Method Summary
 boolean add(Object o)
          Add an object to the underlying map.
 boolean addAll(Collection c)
          Add a Collection of objects to the map.
 void clear()
          Remove all elements from this collection.
 boolean contains(Object o)
          Returns true if this collection contains the specified element.
 boolean containsAll(Collection c)
          Returns true if this collection contains all of the elements in the specified collection.
 boolean containsKey(Object key)
          Returns true if this map contains a mapping for the specified key.
 boolean equals(Object o)
          Compares the specified object with this collection for equality.
 Object get(Object key)
          Returns the value to which this map maps the specified key.
 int hashCode()
          Returns the hash code for this collection.
 boolean isEmpty()
          Returns true if this collection is empty.
 Iterator iterator()
          Returns an iterator for this collection.
 Object put(Object key, Object value)
          Associates the specified value with the specified key in this map.
 boolean remove(Object o)
          Removes the specified element from this collection, if it is present.
 boolean removeAll(Collection c)
          Remove a collection of objects from this collection.
 Object removeKey(Object key)
          Removes the mapping for the specified key from this collection.
 boolean retainAll(Collection c)
          Retains only the elements in this collection that are contained in the specified collection.
 int size()
          Returns the number of elements in this collection.
 Object[] toArray()
          Returns an array containing the elements of this collection.
 Object[] toArray(Object[] a)
          Return an array containing the elements of this collection.
 String toString()
          Returns a string representation of this collection.
 
Methods inherited from class Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface CollectionMap
makeKey
 

Method Detail

toString

public String toString()
Returns a string representation of this collection.

Returns:
a string representation of this collection.

add

public boolean add(Object o)
Add an object to the underlying map. The makeKey method is used to generate the key for the object. If the map already contains an object mapped to the generated key, it is replace with the specified object. Returns true if the map changed as a result of the call. Returns false if a key could not be generated for the object because it is not an instance of an appropriate class.

Specified by:
add in interface Collection
Parameters:
o - the object to be added to the collection.
Returns:
true if the map was modified.

addAll

public boolean addAll(Collection c)
Add a Collection of objects to the map. The makeKey method is used to generate the key for each object. Returns true if the map changed as a result of the call.

Specified by:
addAll in interface Collection
Parameters:
c - the collection to be added.
Returns:
true if the map was modified.

clear

public void clear()
Remove all elements from this collection.

Specified by:
clear in interface Collection

contains

public boolean contains(Object o)
Returns true if this collection contains the specified element.

Specified by:
contains in interface Collection
Parameters:
o - the object to be found.
Returns:
true if the hash map contains o.

containsAll

public boolean containsAll(Collection c)
Returns true if this collection contains all of the elements in the specified collection.

Specified by:
containsAll in interface Collection
Parameters:
c - collection to be checked for containment in this collection.
Returns:
true if this collection contains all of the elements in the specified collection

equals

public boolean equals(Object o)
Compares the specified object with this collection for equality.

Specified by:
equals in interface Collection
Parameters:
o - object to be compared for equality with this collection.
Returns:
true if the specified object equals this collection.

hashCode

public int hashCode()
Returns the hash code for this collection.

Specified by:
hashCode in interface Collection
Returns:
the hash code for this collection.

isEmpty

public boolean isEmpty()
Returns true if this collection is empty.

Specified by:
isEmpty in interface Collection
Returns:
true if this collection is empty.

iterator

public Iterator iterator()
Returns an iterator for this collection.

Specified by:
iterator in interface Collection
Returns:
an iterator for this collection.

remove

public boolean remove(Object o)
Removes the specified element from this collection, if it is present. Returns true if this collection contained the specified element.

Specified by:
remove in interface Collection
Parameters:
o - the object to be removed.
Returns:
true if the hash map was modified.

removeAll

public boolean removeAll(Collection c)
Remove a collection of objects from this collection.

Specified by:
removeAll in interface Collection
Parameters:
c - the collection of objects to be removed.
Returns:
true if the collection was modified.

retainAll

public boolean retainAll(Collection c)
Retains only the elements in this collection that are contained in the specified collection. Returns true if this collection was modified.

Specified by:
retainAll in interface Collection
Parameters:
c - the collection of objects to be retained.
Returns:
true if this collection was modified.

size

public int size()
Returns the number of elements in this collection.

Specified by:
size in interface Collection
Returns:
the number of elements in this collection.

toArray

public Object[] toArray()
Returns an array containing the elements of this collection.

Specified by:
toArray in interface Collection
Returns:
an array containing the elements of this collection.

toArray

public Object[] toArray(Object[] a)
Return an array containing the elements of this collection. The runtime type of the returned array is that of the specified array.

Specified by:
toArray in interface Collection
Parameters:
a - the array into which the elements of this hash map are to be stored, if it is large enough; otherwise, a new array of the same runtime type is allocated for this purpose.
Returns:
an array containing the elements of this hash map.

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.)

Specified by:
containsKey in interface CollectionMap
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.)

Specified by:
get in interface CollectionMap
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.

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.))

Specified by:
put in interface CollectionMap
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.

Specified by:
removeKey in interface CollectionMap
Parameters:
key - key whose mapping is to be removed from the collection.
Returns:
the value previously associated with the key.