CLRA 0.1.2

com.clra.web
Class OarsetSet

java.lang.Object
  |
  +--com.clra.web.OarsetSet
All Implemented Interfaces:
Collection, Set, SortedSet

public class OarsetSet
extends Object
implements SortedSet

A collection of "finder" methods that return read-only, sorted sets of CLRA oarsets.

FIXME: when this class changes to a "Session-like" design, make sure

Version:
$Id: OarsetSet.java,v 1.2 2002/02/18 18:06:44 rphall Exp $
Author:
Rick Hall

Method Summary
 boolean add(Object o)
           
 boolean addAll(Collection c)
           
 void clear()
           
 Comparator comparator()
          Returns the comparator associated with this sorted set, or null if it uses its elements' natural ordering.
 boolean contains(Object o)
          Returns true if this set contains the specified element.
 boolean containsAll(Collection c)
          Returns true if this set contains all of the elements of the specified collection.
 boolean equals(Object o)
          Compares the specified object with this set for equality.
static OarsetSet findAllActiveOarsets()
          Finds all active oarsets of the CLRA.
static OarsetView findOarsetById(int id)
          Finds the oarset that has the given id.
static OarsetView findOarsetByName(String name)
          Finds the oarset that has the given name.
 Object first()
          Returns the first (lowest) element currently in this sorted set.
 int hashCode()
          Returns the hash code value for this set.
 SortedSet headSet(Object toElement)
          Returns a view of the portion of this sorted set whose elements are strictly less than toElement.
 boolean isEmpty()
          Returns true if this set contains no elements.
 Iterator iterator()
          Returns an iterator over the (sorted) elements in this set.
 Object last()
          Returns the last (highest) element currently in this sorted set.
 boolean remove(Object o)
           
 boolean removeAll(Collection c)
           
 boolean retainAll(Collection c)
           
 int size()
          Returns the number of elements in this set (its cardinality).
 SortedSet subSet(Object fromElement, Object toElement)
          Returns a view of the portion of this sorted set whose elements range from fromElement, inclusive, to toElement, exclusive.
 SortedSet tailSet(Object fromElement)
          Returns a view of the portion of this sorted set whose elements are greater than or equal to fromElement.
 Object[] toArray()
          Returns an array containing all of the elements in this set.
 Object[] toArray(Object[] a)
          Returns an array containing all of the elements in this set whose runtime type is that of the specified array.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

findAllActiveOarsets

public static OarsetSet findAllActiveOarsets()
                                      throws WebException
Finds all active oarsets of the CLRA. Oarsets are sorted by name (the natural comparator for oarsets).

findOarsetById

public static OarsetView findOarsetById(int id)
                                 throws WebException
Finds the oarset that has the given id. This "finder" returns at most one oarset.

findOarsetByName

public static OarsetView findOarsetByName(String name)
                                   throws WebException
Finds the oarset that has the given name. Names are unique, so this "finder" returns at most one oarset.

comparator

public Comparator comparator()
Returns the comparator associated with this sorted set, or null if it uses its elements' natural ordering.
Specified by:
comparator in interface SortedSet
Returns:
the comparator associated with this sorted set, or null if it uses its elements' natural ordering.

subSet

public SortedSet subSet(Object fromElement,
                        Object toElement)
Returns a view of the portion of this sorted set whose elements range from fromElement, inclusive, to toElement, exclusive.
Specified by:
subSet in interface SortedSet
Parameters:
fromElement - low endpoint (inclusive) of the subSet.
toElement - high endpoint (exclusive) of the subSet.
Returns:
a view of the specified range within this sorted set.
Throws:
ClassCastException - if fromElement and toElement are not Oarset objects.
IllegalArgumentException - if fromElement is greater than toElement; or if this set is itself a subSet, headSet, or tailSet, and fromElement or toElement are not within the specified range of the subSet, headSet, or tailSet.
NullPointerException - if fromElement or toElement is null

headSet

public SortedSet headSet(Object toElement)
Returns a view of the portion of this sorted set whose elements are strictly less than toElement.
Specified by:
headSet in interface SortedSet
Parameters:
toElement - high endpoint (exclusive) of the headSet.
Returns:
a view of the specified initial range of this sorted set.
Throws:
ClassCastException - if toElement is not compatible with this set's comparator (or, if the set has no comparator, if toElement does not implement Comparable).
NullPointerException - if toElement is null
IllegalArgumentException - if this set is itself a subSet, headSet, or tailSet, and toElement is not within the specified range of the subSet, headSet, or tailSet.

tailSet

public SortedSet tailSet(Object fromElement)
Returns a view of the portion of this sorted set whose elements are greater than or equal to fromElement.
Specified by:
tailSet in interface SortedSet
Parameters:
fromElement - low endpoint (inclusive) of the tailSet.
Returns:
a view of the specified final range of this sorted set.
Throws:
ClassCastException - if fromElement is not compatible with this set's comparator (or, if the set has no comparator, if fromElement does not implement Comparable).
NullPointerException - if fromElement is null
IllegalArgumentException - if this set is itself a subSet, headSet, or tailSet, and fromElement is not within the specified range of the subSet, headSet, or tailSet.

first

public Object first()
Returns the first (lowest) element currently in this sorted set.
Specified by:
first in interface SortedSet
Returns:
the first (lowest) element currently in this sorted set.
Throws:
NoSuchElementException - sorted set is empty.

last

public Object last()
Returns the last (highest) element currently in this sorted set.
Specified by:
last in interface SortedSet
Returns:
the last (highest) element currently in this sorted set.
Throws:
NoSuchElementException - sorted set is empty.

size

public int size()
Returns the number of elements in this set (its cardinality). If this set contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
Specified by:
size in interface Set
Returns:
the number of elements in this set (its cardinality).

isEmpty

public boolean isEmpty()
Returns true if this set contains no elements.
Specified by:
isEmpty in interface Set
Returns:
true if this set contains no elements.

contains

public boolean contains(Object o)
Returns true if this set contains the specified element.
Specified by:
contains in interface Set
Parameters:
o - element whose presence in this set is to be tested.
Returns:
true if this set contains the specified element.

iterator

public Iterator iterator()
Returns an iterator over the (sorted) elements in this set.
Specified by:
iterator in interface Set
Returns:
an iterator over the elements in this set.

toArray

public Object[] toArray()
Returns an array containing all of the elements in this set.
Specified by:
toArray in interface Set
Returns:
an array containing all of the elements in this set.

toArray

public Object[] toArray(Object[] a)
Returns an array containing all of the elements in this set whose runtime type is that of the specified array.
Specified by:
toArray in interface Set
Parameters:
a - the array into which the elements of this set are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
Returns:
an array containing the elements of this set.
Throws:
ArrayStoreException - the runtime type of a is not a supertype of the runtime type of Oarset.

containsAll

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

equals

public boolean equals(Object o)
Compares the specified object with this set for equality.
Specified by:
equals in interface Set
Overrides:
equals in class Object
Parameters:
o - Object to be compared for equality with this set.
Returns:
true if the specified Object is equal to this set.

hashCode

public int hashCode()
Returns the hash code value for this set. The hash code of a set is defined to be the sum of the hash codes of the elements in the set.
Specified by:
hashCode in interface Set
Overrides:
hashCode in class Object
Returns:
the hash code value for this set.

add

public boolean add(Object o)
Specified by:
add in interface Set
Throws:
UnsupportedOperationException - since the add method is not supported by this set.

remove

public boolean remove(Object o)
Specified by:
remove in interface Set
Throws:
UnsupportedOperationException - since the remove method is not supported by this set.

addAll

public boolean addAll(Collection c)
Specified by:
addAll in interface Set
Throws:
UnsupportedOperationException - since the addAll method is not supported by this set.

retainAll

public boolean retainAll(Collection c)
Specified by:
retainAll in interface Set
Throws:
UnsupportedOperationException - since the retainAll method is not supported by this Collection.

removeAll

public boolean removeAll(Collection c)
Specified by:
removeAll in interface Set
Throws:
UnsupportedOperationException - since the removeAll method is not supported by this Collection.

clear

public void clear()
Specified by:
clear in interface Set
Throws:
UnsupportedOperationException - since the clear method is not supported by this set.

CLRA 0.1.2