com.arsdigita.acs
Class Selection

java.lang.Object
  |
  +--com.arsdigita.acs.Selection
All Implemented Interfaces:
DataSource, MultiDataSource

public class Selection
extends java.lang.Object
implements MultiDataSource

Represents a generic multiple-row data source pulled in from the database. To ensure scalability of large queries, does not cache any query results. If it's necessary to call the rowcount or seek methods, you should use SeekableSelection instead.


Field Summary
static java.lang.String cvsId
           
protected  java.lang.String[] keys
           
protected  com.arsdigita.db.SimpleResultSet srs
          The result set that we're managing
 
Constructor Summary
Selection(java.lang.Object obj)
          Casts the given object to SimpleResultSet
Selection(com.arsdigita.db.SimpleResultSet srs)
          Creates a new Selection, initialized from a SimpleResultSet.
 
Method Summary
 boolean contains(java.lang.String column)
          Returns true if this contains a column named column.
 java.lang.String get(java.lang.String key)
          Returns the value of the column named by key.
 java.lang.String[] keys()
          Returns a list of available keys (column names) in the Selection.
 boolean next()
          Advances to the next row in the data source, if there is one.
 int rowcount()
          Not implemented by this object.
 int rownum()
          Returns the current row number in the datasource.
 void seek(int rownum)
          This object only implements sequential access, so calling seek with any row other than the current row results in a DataSourceException being thrown.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cvsId

public static final java.lang.String cvsId

srs

protected com.arsdigita.db.SimpleResultSet srs
The result set that we're managing

keys

protected java.lang.String[] keys
Constructor Detail

Selection

public Selection(java.lang.Object obj)
          throws java.sql.SQLException
Casts the given object to SimpleResultSet

Selection

public Selection(com.arsdigita.db.SimpleResultSet srs)
          throws java.sql.SQLException
Creates a new Selection, initialized from a SimpleResultSet.
Method Detail

contains

public boolean contains(java.lang.String column)
                 throws DataSourceException
Returns true if this contains a column named column.
Specified by:
contains in interface DataSource

seek

public void seek(int rownum)
          throws DataSourceException
This object only implements sequential access, so calling seek with any row other than the current row results in a DataSourceException being thrown.
Specified by:
seek in interface MultiDataSource

get

public java.lang.String get(java.lang.String key)
                     throws DataSourceException
Returns the value of the column named by key. Returns the empty string if the column value is null.
Specified by:
get in interface DataSource
Throws:
InvalidKeyException - if key is not found.

next

public boolean next()
             throws DataSourceException
Advances to the next row in the data source, if there is one.
Specified by:
next in interface MultiDataSource
Returns:
true; or false if there are no more elements.

keys

public java.lang.String[] keys()
                        throws DataSourceException
Returns a list of available keys (column names) in the Selection.
Specified by:
keys in interface DataSource

rownum

public int rownum()
           throws DataSourceException
Returns the current row number in the datasource.
Specified by:
rownum in interface MultiDataSource

rowcount

public int rowcount()
             throws DataSourceException
Not implemented by this object. A DataSourceException is always thrown.
Specified by:
rowcount in interface MultiDataSource