com.arsdigita.acs
Class SeekableSelection

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

public class SeekableSelection
extends java.lang.Object
implements MultiDataSource

Represents a generic multiple-row data source pulled in from the database. Stores all query results in memory because of the requirements of the templating system (must be able to traverse query results multiple times, must provide rowcount). Entity objects for doing logical operations on more specific database objects should extend Selection, adding additional accessors for derived properties as needed.


Fields inherited from interface com.arsdigita.acs.MultiDataSource
cvsId
 
Constructor Summary
SeekableSelection(java.lang.Object obj)
          Casts the given object to SimpleResultSet
SeekableSelection(com.arsdigita.db.SimpleResultSet srs)
          Creates a new SeekableSelection, 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.Object getObject(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()
          Returns the number of rows in this datasource.
 int rownum()
          Returns the current row number in the datasource.
 void seek(int rownum)
          Sets the current row to the given (one-based) row number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SeekableSelection

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

SeekableSelection

public SeekableSelection(com.arsdigita.db.SimpleResultSet srs)
                  throws java.sql.SQLException
Creates a new SeekableSelection, 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
Sets the current row to the given (one-based) row number. The initial value, before next() is called, is 0, so you need to call seek(0) if you want to reset the datasource to its initial state.
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 null if the column value is null.
Specified by:
get in interface DataSource
Throws:
InvalidKeyException - if key is not found.

getObject

public java.lang.Object getObject(java.lang.String key)
                           throws DataSourceException
Returns the value of the column named by key. Returns null if the column value is null.
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
Returns the number of rows in this datasource.
Specified by:
rowcount in interface MultiDataSource