org.exolab.core.foundation
Interface TreeMapIfc

All Superinterfaces:
PersistentCapableIfc, java.io.Serializable
All Known Implementing Classes:
PMDTreeMap

public interface TreeMapIfc
extends PersistentCapableIfc, java.io.Serializable

This interface abstracts the Persistent TreeMap data structure so that it can be mapped to various persistent and transient datastores. It basically uses the JDK1.1.2 java.util.TreeMap to derive the interface.

Version:
$Revision: 1.2 $ $Date: 2000/04/30 23:50:17 $
Author:
Jim Alateras
See Also:
PersistentCapableIfc, Serializable

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.
 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.
 
Methods inherited from interface org.exolab.core.foundation.PersistentCapableIfc
getMinimumObjectSize, getObjectId, getObjectVersion, setMinimumObjectSize
 

Method Detail

size

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

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

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.

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

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

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.

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.

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

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.

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.


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,

Returns:
Set view of the keys contained in this TreeMap.

isEmpty

public boolean isEmpty()
Test is the map is empty

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

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.

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

Returns:
The internal TreeMap used.


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