ca.sqlpower.wabit
Class ResultSetAndUpdateCountCollection

java.lang.Object
  extended by ca.sqlpower.wabit.ResultSetAndUpdateCountCollection

public class ResultSetAndUpdateCountCollection
extends java.lang.Object

Contains a set of result sets and update counts that are returned by executing a query.


Constructor Summary
ResultSetAndUpdateCountCollection(java.sql.ResultSet rs, AbstractWabitObject parentObject)
          This will wrap a given result set in a ResultSetAndUpdateCountCollection.
ResultSetAndUpdateCountCollection(ResultSetAndUpdateCountCollection rsCollection)
          Returns a copy of the given result set collection.
ResultSetAndUpdateCountCollection(java.sql.Statement statement, boolean isNextAResultSet, boolean isStreaming, int streamingRowLimit, AbstractWabitObject parent)
          This constructor will iterate through the statement's results and collect a set of result sets and update counts.
 
Method Summary
 void addResultSetListener(StreamingResultSetCollectionListener l)
          The added listener will be notified when all of the streaming queries have stopped.
 void cleanup()
           
 int getCountOfUpdateCounts()
          Returns the number of update counts in this collection.
 ca.sqlpower.sql.CachedRowSet getFirstNonNullResultSet()
          Returns the first non-null result set contained in this collection.
 ca.sqlpower.sql.CachedRowSet getFirstResultSet()
          Gets the first result set from the collection of result sets.
 int getResultSetCount()
          Returns the number of null and non-null result set entries in this collection.
 java.util.List<ca.sqlpower.sql.CachedRowSet> getResultSets()
          Gets all of the result sets contained by this collection.
 java.util.List<java.lang.Integer> getUpdateCounts()
          Returns an unmodifiable list of the update counts.
 void removeResultSetListener(StreamingResultSetCollectionListener l)
          The removed listener will no longer be notified when all of the streaming queries have stopped streaming in this collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResultSetAndUpdateCountCollection

public ResultSetAndUpdateCountCollection(java.sql.Statement statement,
                                         boolean isNextAResultSet,
                                         boolean isStreaming,
                                         int streamingRowLimit,
                                         AbstractWabitObject parent)
                                  throws java.sql.SQLException
This constructor will iterate through the statement's results and collect a set of result sets and update counts. If the result sets in this statement are not streaming then the result sets stored in this class will not need any database resources and the statement can be closed after this object has been constructed. If the result sets are streaming the statement will have to remain open to continue streaming entries into the stored result sets.

If the CachedRowSet can be set to unmodifiable in the future the CachedRowSets created in this class should be unmodifiable.

Parameters:
statement - The statement to get results from.
isNextAResultSet - True if the first result from the statement is a result set. False if the first result from the statement is an update count.
isStreaming - True if the result sets in this statement are streaming, false otherwise.
streamingRowLimit - The number of rows to retain in the result set that is streaming values.
parent - Uses the parent's runInForeground method to fire all events on the foreground thread.
Throws:
java.sql.SQLException

ResultSetAndUpdateCountCollection

public ResultSetAndUpdateCountCollection(java.sql.ResultSet rs,
                                         AbstractWabitObject parentObject)
                                  throws java.sql.SQLException
This will wrap a given result set in a ResultSetAndUpdateCountCollection. The result set stored will be scrollable and contain no resources back to the original result set.

Parameters:
rs - The result set to wrap. This cannot be a streaming result set.
parentObject - The parent object to fire events on an appropriate foreground thread.
Throws:
java.sql.SQLException - Thrown if there are problems iterating over the result set.

ResultSetAndUpdateCountCollection

public ResultSetAndUpdateCountCollection(ResultSetAndUpdateCountCollection rsCollection)
Returns a copy of the given result set collection. The cached row sets contained in the copy will be shared copies of the ones in the given collection. The referenced threads in the copy will reference the threads in the original collection which means stopping the threads in a copy of a collection will stop the threads in all of the copies and the original collection.

Method Detail

addResultSetListener

public void addResultSetListener(@Nonnull
                                 StreamingResultSetCollectionListener l)
The added listener will be notified when all of the streaming queries have stopped. This cannot be null.


removeResultSetListener

public void removeResultSetListener(StreamingResultSetCollectionListener l)
The removed listener will no longer be notified when all of the streaming queries have stopped streaming in this collection.


getFirstResultSet

public ca.sqlpower.sql.CachedRowSet getFirstResultSet()
Gets the first result set from the collection of result sets. This can be null if an update count was the first value returned by the statement and no result set was associated with it. Throws an index out of bounds exception if there are no result sets in this collection.


getFirstNonNullResultSet

public ca.sqlpower.sql.CachedRowSet getFirstNonNullResultSet()
Returns the first non-null result set contained in this collection. If there are no non-null result sets in this collection it will return null. The result set returned will be a shared copy of the result set returned.

See Also:
CachedRowSet.createShared()

getResultSetCount

public int getResultSetCount()
Returns the number of null and non-null result set entries in this collection.


getResultSets

public java.util.List<ca.sqlpower.sql.CachedRowSet> getResultSets()
Gets all of the result sets contained by this collection. This list will be unmodifiable.


getCountOfUpdateCounts

public int getCountOfUpdateCounts()
Returns the number of update counts in this collection.


getUpdateCounts

public java.util.List<java.lang.Integer> getUpdateCounts()
Returns an unmodifiable list of the update counts.


cleanup

public void cleanup()
             throws java.sql.SQLException
Throws:
java.sql.SQLException


Copyright © 2009. All Rights Reserved.