org.exolab.core.database.recman
Class PMDTreeMap

java.lang.Object
  extended by org.exolab.core.foundation.PersistentObject
      extended by org.exolab.core.database.recman.PMDTreeMap
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, PersistentCapableIfc, TreeMapIfc

public class PMDTreeMap
extends PersistentObject
implements TreeMapIfc, java.io.Externalizable

This is an implementation of the TreeMapIfc for the PMD datastore. The implementation currently uses java.util.TreeMap but this will be changed in a subsequent release to provide a more concurrent capable container and take advantages of this database's features.

Version:
$Revision: 1.3 $ $Date: 2001/06/12 07:11:35 $
Author:
Jim Alateras
See Also:
TreeMapIfc, PersistentObject, Serialized Form

Constructor Summary
PMDTreeMap()
          Default constructor simply instantiates an instance of a TreeMap
PMDTreeMap(java.util.Comparator comparator)
          Construct an instance of a TreeMap with the specified comparator.
 
Method Summary
 void clear()
          Removes all mappings from this TreeMap.
 java.util.Comparator comparator()
          Returns the comparator used to order this map or null if this map uses natural ordering
 boolean containsKey(java.lang.Object key)
          Test whether a particular key is mapped to an object in the container.
 boolean containsValue(java.lang.Object value)
          Returns true if this map maps one or more keys to the specified value.
 java.util.Collection elements()
          Return an enumeration of all the elements in the map
 java.lang.Object firstKey()
          Returns the first (lowest) key currently in this sorted map.It throws NoSuchElementException if the element does not exist.
 java.lang.Object get(java.lang.Object key)
          Returns the value associated with the specified key.
 boolean isEmpty()
          Test is the map is empty
 java.util.Set keySet()
          Returns a Set view of the keys contained in this map.
 java.lang.Object lastKey()
          Returns the last (highest) key currently in this sorted map.It throws NoSuchElementException if the element does not exist.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Associates the specified value with the specified key in this map.
 void readExternal(java.io.ObjectInput stream)
           
 java.lang.Object remove(java.lang.Object key)
          Removes the mapping for this key from this TreeMap if present.If the key cannot be compared to other values in the map then thorw the Class- castExcpetion.
 int size()
          Returns the number of key-value mappings in this map.
 java.util.SortedMap sortedMap()
          Returns the internal TreeMap
 java.util.SortedMap tailMap(java.lang.Object key)
          Returns a view of the portion of this map whose keys are greater than or equal to fromKey.
 void writeExternal(java.io.ObjectOutput stream)
           
 
Methods inherited from class org.exolab.core.foundation.PersistentObject
clone, equals, getId, getMinimumObjectSize, getObjectId, getObjectVersion, getVersion, setId, setMinimumObjectSize, setObjectId, setObjectVersion, setVersion
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.exolab.core.foundation.PersistentCapableIfc
getMinimumObjectSize, getObjectId, getObjectVersion, setMinimumObjectSize
 

Constructor Detail

PMDTreeMap

public PMDTreeMap()
Default constructor simply instantiates an instance of a TreeMap


PMDTreeMap

public PMDTreeMap(java.util.Comparator comparator)
Construct an instance of a TreeMap with the specified comparator. The comparator is used to sort the elements in the map. If a null comparator is specified then natural order pervails.

Parameters:
comparator - used for ordering
Method Detail

size

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

Specified by:
size in interface TreeMapIfc
Returns:
number of mappings in this map.

containsKey

public boolean containsKey(java.lang.Object key)
Test whether a particular key is mapped to an object in the container. If the key cannot be compared with the jeys in the map the ClassCast- Exception is thrown. If the key is null and the map uses natural ordering or its comparator does not tolerate null raise the NullPointer- Exception

Specified by:
containsKey in interface TreeMapIfc
Parameters:
key - key whose value to find
Returns:
boolean true if the key is mapped
Throws:
java.lang.ClassCastException
java.lang.NullPointerException

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.

Specified by:
containsValue in interface TreeMapIfc
Parameters:
value - test for this value
Returns:
boolean true if object is present

get

public java.lang.Object get(java.lang.Object key)
Returns the value associated with the specified key. If the key cannot be compared with the keys then the ClassCastException. If the key is null and this map uses natural ordering or its comparator does not tol- erate null keys throw the NullPointerException

Specified by:
get in interface TreeMapIfc
Parameters:
key - key whose value to find
Returns:
boolean true if the key is mapped
Throws:
java.lang.ClassCastException
java.lang.NullPointerException

comparator

public java.util.Comparator comparator()
Returns the comparator used to order this map or null if this map uses natural ordering

Specified by:
comparator in interface TreeMapIfc
Returns:
Comparator

firstKey

public java.lang.Object firstKey()
Returns the first (lowest) key currently in this sorted map.It throws NoSuchElementException if the element does not exist.

Specified by:
firstKey in interface TreeMapIfc
Returns:
Object
Throws:
NoSuchElementException

lastKey

public java.lang.Object lastKey()
Returns the last (highest) key currently in this sorted map.It throws NoSuchElementException if the element does not exist.

Specified by:
lastKey in interface TreeMapIfc
Returns:
Object
Throws:
NoSuchElementException

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. If the map previously contained a mapping for this key, the old value is replaced.

If the key cannot be compared with other keys in the map it will throw the ClassCastException. Similarly, if the key is null and the map uses natural ordering or its comparator cannot tolerate null keys throw the NullPointerException

Specified by:
put in interface TreeMapIfc
Parameters:
key - key object
value - value object
Throws:
java.lang.ClassCastException
java.lang.NullPointerException

remove

public java.lang.Object remove(java.lang.Object key)
Removes the mapping for this key from this TreeMap if present.If the key cannot be compared to other values in the map then thorw the Class- castExcpetion. Similarly, ifthe key is null and the key uses natural order or its comparator does not tolerate null keys the NullPointer- Exception is raised.

Specified by:
remove in interface TreeMapIfc
Parameters:
key - key whose value to remove
Returns:
Object remove value
Throws:
ClassCastEzception
java.lang.NullPointerException

clear

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

Specified by:
clear in interface TreeMapIfc

keySet

public java.util.Set keySet()
Returns a Set view of the keys contained in this map. The set's iterator will return the keys in ascending order. The map is backed by this TreeMap instance, so changes to this map are reflected in the Set, and vice-versa. The Set supports element removal,

Specified by:
keySet in interface TreeMapIfc
Returns:
Set view of the keys contained in this TreeMap.

isEmpty

public boolean isEmpty()
Test is the map is empty

Specified by:
isEmpty in interface TreeMapIfc
Returns:
boolean true if the map is empty and false otherwise

elements

public java.util.Collection elements()
Return an enumeration of all the elements in the map

Specified by:
elements in interface TreeMapIfc
Returns:
Enumeration

tailMap

public java.util.SortedMap tailMap(java.lang.Object key)
Returns a view of the portion of this map whose keys are greater than or equal to fromKey.

Specified by:
tailMap in interface TreeMapIfc
Parameters:
id - The key to compare to.
Returns:
a view of the portion of this map whose keys are greater than or equal to fromKey.

sortedMap

public java.util.SortedMap sortedMap()
Returns the internal TreeMap

Specified by:
sortedMap in interface TreeMapIfc
Returns:
The internal TreeMap used.

writeExternal

public void writeExternal(java.io.ObjectOutput stream)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Overrides:
writeExternal in class PersistentObject
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput stream)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Overrides:
readExternal in class PersistentObject
Throws:
java.io.IOException
java.lang.ClassNotFoundException


Copyright © 1999-2012 The Exolab Group. All Rights Reserved.