Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.clra.web
Class BoatSet  view BoatSet download BoatSet.java

java.lang.Object
  extended bycom.clra.web.BoatSet
All Implemented Interfaces:
java.util.Collection, java.lang.Iterable, java.util.Set, java.util.SortedSet

public class BoatSet
extends java.lang.Object
implements java.util.SortedSet

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

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

Version:
$Id: BoatSet.java,v 1.4 2003/02/26 03:38:46 rphall Exp $

Field Summary
private static java.lang.String base
           
private  java.util.SortedSet data
          The current implementations return data in an in-memory collections.
private static org.apache.log4j.Category theLog
           
 
Constructor Summary
private BoatSet()
          BoatSet instances are created by static "finder" methods
 
Method Summary
 boolean add(java.lang.Object o)
          Adds the specified element to the set if it is not already present (optional operation).
 boolean addAll(java.util.Collection c)
          Adds all of the elements of the given collection to this set (optional operation).
 void clear()
          Removes all elements from this set (optional operation).
 java.util.Comparator comparator()
          Returns the comparator associated with this sorted set, or null if it uses its elements' natural ordering.
 boolean contains(java.lang.Object o)
          Returns true if this set contains the specified element.
 boolean containsAll(java.util.Collection c)
          Returns true if this set contains all of the elements of the specified collection.
 boolean equals(java.lang.Object o)
          Compares the specified object with this set for equality.
static BoatSet findAllActiveBoats()
          Finds all active boats of the CLRA.
static com.clra.rowing.BoatView findBoatById(int id)
          Finds the boat that has the given id.
static com.clra.rowing.BoatView findBoatByName(java.lang.String name)
          Finds the boat that has the given name.
 java.lang.Object first()
          Returns the first (lowest) element currently in this sorted set.
 int hashCode()
          Returns the hash code value for this set.
 java.util.SortedSet headSet(java.lang.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.
 java.util.Iterator iterator()
          Returns an iterator over the (sorted) elements in this set.
 java.lang.Object last()
          Returns the last (highest) element currently in this sorted set.
private static com.clra.rowing.BoatView loadBoat(java.sql.PreparedStatement stmt)
          Loads an in-memory object from a database using the specified SQL
private static void loadBoatSet(java.sql.PreparedStatement stmt, java.util.SortedSet set)
          Loads an in-memory set from a database using the specified SQL
private static com.clra.rowing.BoatView mapRowToBoat(java.sql.ResultSet rs)
          Maps a row of SQL ResultSet to a BoatView object
 boolean remove(java.lang.Object o)
          Removes the specified element from this set (optional operation).
 boolean removeAll(java.util.Collection c)
          Removes from this set all elements contained in the specified collection (optional operation).
 boolean retainAll(java.util.Collection c)
          Retains only the elements in this set that are also in the specified collection (optional operation).
 int size()
          Returns the number of elements in this set (its cardinality).
 java.util.SortedSet subSet(java.lang.Object fromElement, java.lang.Object toElement)
          Returns a view of the portion of this sorted set whose elements range from fromElement, inclusive, to toElement, exclusive.
 java.util.SortedSet tailSet(java.lang.Object fromElement)
          Returns a view of the portion of this sorted set whose elements are greater than or equal to fromElement.
 java.lang.Object[] toArray()
          Returns an array containing all of the elements in this set.
 java.lang.Object[] toArray(java.lang.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
 

Field Detail

base

private static final java.lang.String base

theLog

private static final org.apache.log4j.Category theLog

data

private final java.util.SortedSet data
The current implementations return data in an in-memory collections. Since the underlaying Boat database table may already be cached in memory, this can lead to duplicate caching. Future implementations should avoid in-memory duplicates by implementing SortedSet and Iterator methods directly in SQL.

Constructor Detail

BoatSet

private BoatSet()
BoatSet instances are created by static "finder" methods

Method Detail

findAllActiveBoats

public static BoatSet findAllActiveBoats()
                                  throws WebException
Finds all active boats of the CLRA. Boats are sorted by name (the natural comparator for boats).


findBoatById

public static com.clra.rowing.BoatView findBoatById(int id)
                                             throws WebException
Finds the boat that has the given id. This "finder" returns at most one boat.


findBoatByName

public static com.clra.rowing.BoatView findBoatByName(java.lang.String name)
                                               throws WebException
Finds the boat that has the given name. Names are unique, so this "finder" returns at most one boat.


comparator

public java.util.Comparator comparator()
Returns the comparator associated with this sorted set, or null if it uses its elements' natural ordering.

Specified by:
comparator in interface java.util.SortedSet

subSet

public java.util.SortedSet subSet(java.lang.Object fromElement,
                                  java.lang.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 java.util.SortedSet

headSet

public java.util.SortedSet headSet(java.lang.Object toElement)
Returns a view of the portion of this sorted set whose elements are strictly less than toElement.

Specified by:
headSet in interface java.util.SortedSet

tailSet

public java.util.SortedSet tailSet(java.lang.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 java.util.SortedSet

first

public java.lang.Object first()
Returns the first (lowest) element currently in this sorted set.

Specified by:
first in interface java.util.SortedSet

last

public java.lang.Object last()
Returns the last (highest) element currently in this sorted set.

Specified by:
last in interface java.util.SortedSet

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 java.util.Set

isEmpty

public boolean isEmpty()
Returns true if this set contains no elements.

Specified by:
isEmpty in interface java.util.Set

contains

public boolean contains(java.lang.Object o)
Returns true if this set contains the specified element.

Specified by:
contains in interface java.util.Set

iterator

public java.util.Iterator iterator()
Returns an iterator over the (sorted) elements in this set.

Specified by:
iterator in interface java.util.Set

toArray

public java.lang.Object[] toArray()
Returns an array containing all of the elements in this set.

Specified by:
toArray in interface java.util.Set

toArray

public java.lang.Object[] toArray(java.lang.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 java.util.Set

containsAll

public boolean containsAll(java.util.Collection c)
Returns true if this set contains all of the elements of the specified collection.

Specified by:
containsAll in interface java.util.Set

equals

public boolean equals(java.lang.Object o)
Compares the specified object with this set for equality.

Specified by:
equals in interface java.util.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 java.util.Set

add

public boolean add(java.lang.Object o)
Description copied from interface: java.util.Set
Adds the specified element to the set if it is not already present (optional operation). In particular, the comparison algorithm is o == null ? e == null : o.equals(e). Sets need not permit all values, and may document what exceptions will be thrown if a value is not permitted.

Specified by:
add in interface java.util.Set

remove

public boolean remove(java.lang.Object o)
Description copied from interface: java.util.Set
Removes the specified element from this set (optional operation). If an element e exists, o == null ? e == null : o.equals(e), it is removed from the set.

Specified by:
remove in interface java.util.Set

addAll

public boolean addAll(java.util.Collection c)
Description copied from interface: java.util.Set
Adds all of the elements of the given collection to this set (optional operation). If the argument is also a Set, this returns the mathematical union of the two. The behavior is unspecified if the set is modified while this is taking place.

Specified by:
addAll in interface java.util.Set

retainAll

public boolean retainAll(java.util.Collection c)
Description copied from interface: java.util.Set
Retains only the elements in this set that are also in the specified collection (optional operation). If the argument is also a set, this performs the intersection of the two sets.

Specified by:
retainAll in interface java.util.Set

removeAll

public boolean removeAll(java.util.Collection c)
Description copied from interface: java.util.Set
Removes from this set all elements contained in the specified collection (optional operation). If the argument is a set, this returns the asymmetric set difference of the two sets.

Specified by:
removeAll in interface java.util.Set

clear

public void clear()
Description copied from interface: java.util.Set
Removes all elements from this set (optional operation). This set will be empty afterwords, unless an exception occurs.

Specified by:
clear in interface java.util.Set

loadBoat

private static com.clra.rowing.BoatView loadBoat(java.sql.PreparedStatement stmt)
                                          throws java.sql.SQLException,
                                                 WebException
Loads an in-memory object from a database using the specified SQL


loadBoatSet

private static void loadBoatSet(java.sql.PreparedStatement stmt,
                                java.util.SortedSet set)
                         throws java.sql.SQLException,
                                WebException
Loads an in-memory set from a database using the specified SQL


mapRowToBoat

private static com.clra.rowing.BoatView mapRowToBoat(java.sql.ResultSet rs)
                                              throws java.sql.SQLException,
                                                     WebException
Maps a row of SQL ResultSet to a BoatView object