ostore.util
Class QSHashMap

java.lang.Object
  |
  +--ostore.util.QSHashMap
All Implemented Interfaces:
QuickSerializable

public class QSHashMap
extends Object
implements QuickSerializable

A QSHashMap is a wrapper class of HashMap that implements QuickSerializable. All elements of the QSHashMap must also be QuickSerializable. Most of the functionality from the HashMap has not been ported. If you require the use of a missing method, implement it.

Version:
$Id: QSHashMap.java,v 1.1 2003/01/24 21:02:10 strib Exp $
Author:
Jeremy Stribling

Constructor Summary
QSHashMap()
          Constructs a QSHashMap.
QSHashMap(InputBuffer buffer)
          Constructs a QSHashMap from its serialized form.
 
Method Summary
 void clear()
          Removes all mappings from this set.
 boolean containsKey(QuickSerializable o)
          Returns true if this map contains the specified key.
 boolean containsValue(QuickSerializable o)
          Returns true if this map contains the specified value.
 boolean equals(Object o)
          Compare this QSHashMap to another Object.
 QuickSerializable get(QuickSerializable o)
          Returns the object mapped to the given key in this map if it is present.
protected  HashMap getHashMap()
           
 int hashCode()
          Return a hashcode, specified and generated as in HashMap.
 boolean isEmpty()
          Returns true if this map contains no mappings.
 Set keySet()
          Returns a set view of the keys contained in this map.
 QuickSerializable put(QuickSerializable key, QuickSerializable value)
          Puts this mapping in the map
 QuickSerializable remove(QuickSerializable o)
          Removes the given key mapping from this map if it is present.
 void serialize(OutputBuffer buffer)
          As specified by {link ostore.util.QuickSerializable}.
 int size()
          Returns the number of mappings in this map.
 Collection values()
          Returns a collection view of the values contained in this map.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QSHashMap

public QSHashMap()
Constructs a QSHashMap.


QSHashMap

public QSHashMap(InputBuffer buffer)
          throws QSException
Constructs a QSHashMap from its serialized form.

Parameters:
buffer - serialized form of object.
Method Detail

serialize

public void serialize(OutputBuffer buffer)
As specified by {link ostore.util.QuickSerializable}.

Specified by:
serialize in interface QuickSerializable
Parameters:
buffer - the output buffer to add the object to

hashCode

public int hashCode()
Return a hashcode, specified and generated as in HashMap.

Overrides:
hashCode in class Object
Returns:
a hashcode which incorporates the hashcodes of all the elements in the QSTreeSet

getHashMap

protected HashMap getHashMap()

equals

public boolean equals(Object o)
Compare this QSHashMap to another Object.

Overrides:
equals in class Object
Returns:
true iff the other Object is also a QSHashMap and contains equal elements.

keySet

public Set keySet()
Returns a set view of the keys contained in this map.

Returns:
a set view of the keys contained in this map

values

public Collection values()
Returns a collection view of the values contained in this map.

Returns:
a collection view of the values contained in this map

size

public int size()
Returns the number of mappings in this map.

Returns:
the number of mappings in this map

isEmpty

public boolean isEmpty()
Returns true if this map contains no mappings.

Returns:
true if this map contains no mappings

containsKey

public boolean containsKey(QuickSerializable o)
Returns true if this map contains the specified key.

Parameters:
o - the key to be checked for containment in this map.
Returns:
true if this map contains the specified key.
Throws:
ClassCastException - if the specified object cannot be compared with the elements currently in the map.

containsValue

public boolean containsValue(QuickSerializable o)
Returns true if this map contains the specified value.

Parameters:
o - the value to be checked for containment in this map.
Returns:
true if this map contains the specified value.
Throws:
ClassCastException - if the specified object cannot be compared with the elements currently in the map.

put

public QuickSerializable put(QuickSerializable key,
                             QuickSerializable value)
Puts this mapping in the map

Throws:
ClassCastException - if the specified object cannot be compared with the elements currently in the set.

get

public QuickSerializable get(QuickSerializable o)
Returns the object mapped to the given key in this map if it is present.

Parameters:
o - key to lookup
Returns:
the object the key is mapped to
Throws:
ClassCastException - if the specified object cannot be compared with the elements currently in the set.

remove

public QuickSerializable remove(QuickSerializable o)
Removes the given key mapping from this map if it is present.

Parameters:
o - key of the mapping to be removed from this map, if present.
Returns:
the object the key was mapped to
Throws:
ClassCastException - if the specified object cannot be compared with the elements currently in the set.

clear

public void clear()
Removes all mappings from this set.