org.exolab.core.database.recman
Class PMDTreeSet

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

public class PMDTreeSet
extends PersistentObject
implements TreeSetIfc, java.io.Externalizable

This class implements the TreeSetIfc for the PMD database. The current implementation simply wraps the java.util.TreeSet and makes it persistent.

Future implementations will store handles instead of objects and hence making it more concurrent aware.

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

Constructor Summary
PMDTreeSet()
          The default constructor initialises the the TreeSet object.
PMDTreeSet(java.util.Comparator comparator)
          Construct a set with the specified constructor.
 
Method Summary
 boolean add(java.lang.Object object)
          Adds the specified element to this set if it is not already present.If the element alsready exists then return false, otherwise return true.
 void clear()
          Removes all of the elements from this set.
 java.util.Comparator comparator()
          Returns the comparator used to order this set or null if this set uses natural ordering
 boolean contains(java.lang.Object object)
          Test whether the set contains the speciied object.If the object cannot be compared with other elements in the set the ClassCastException is raised.
 java.lang.Object first()
          Returns the first (lowest) key currently in this sorted set.It throws NoSuchElementException if the element does not exist.
 boolean isEmpty()
          Test is the set is empty
 java.util.Iterator iterator()
          Returns an iterator for the elements in this set.
 java.lang.Object last()
          Returns the last (highest) key currently in this sorted map.It throws NoSuchElementException if the element does not exist.
 void readExternal(java.io.ObjectInput stream)
           
 boolean remove(java.lang.Object object)
          Removes the given element from this set if it is present.
 int size()
          Returns the number elements in the set
 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

PMDTreeSet

public PMDTreeSet()
The default constructor initialises the the TreeSet object.


PMDTreeSet

public PMDTreeSet(java.util.Comparator comparator)
Construct a set with the specified constructor. The constructor is used to compare all elements in the set

Parameters:
comparator - used for ordering
Method Detail

iterator

public java.util.Iterator iterator()
Returns an iterator for the elements in this set. The elements are returned in ascending order.

Specified by:
iterator in interface TreeSetIfc
Returns:
Iterator

size

public int size()
Returns the number elements in the set

Specified by:
size in interface TreeSetIfc
Returns:
number of mappings in this set

isEmpty

public boolean isEmpty()
Test is the set is empty

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

contains

public boolean contains(java.lang.Object object)
Test whether the set contains the speciied object.If the object cannot be compared with other elements in the set the ClassCastException is raised.

Specified by:
contains in interface TreeSetIfc
Parameters:
object - object to test for
Returns:
boolean true if present; false otherwise
Throws:
java.lang.ClassCastException

add

public boolean add(java.lang.Object object)
Adds the specified element to this set if it is not already present.If the element alsready exists then return false, otherwise return true. If the specified object cannot be compared with other objects in the set it will throw the ClassCastException

Specified by:
add in interface TreeSetIfc
Parameters:
object - object to add
Returns:
true if it was added and false otherwise
Throws:
java.lang.ClassCastException

remove

public boolean remove(java.lang.Object object)
Removes the given element from this set if it is present. If the set contained the object return true otherwise return false. If the object cannot be compared with other elements in the set then throw the ClassCastException

Specified by:
remove in interface TreeSetIfc
Parameters:
object - object to remove
Returns:
boolean true if the object originally existed
Throws:
java.lang.ClassCastException

clear

public void clear()
Removes all of the elements from this set.

Specified by:
clear in interface TreeSetIfc

comparator

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

Specified by:
comparator in interface TreeSetIfc
Returns:
Comparator

first

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

Specified by:
first in interface TreeSetIfc
Returns:
Object
Throws:
NoSuchElementException

last

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

Specified by:
last in interface TreeSetIfc
Returns:
Object
Throws:
NoSuchElementException

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.