uk.ac.starlink.table.jdbc
Class SequentialResultSetStarTable

java.lang.Object
  extended byuk.ac.starlink.table.AbstractStarTable
      extended byuk.ac.starlink.table.jdbc.SequentialResultSetStarTable
All Implemented Interfaces:
StarTable

public class SequentialResultSetStarTable
extends AbstractStarTable

StarTable implementation based on a ResultSet. It can read through the data once, and no more.

Beware: it therefore breaks the general contract of StarTable, in that calls of getRowSequence() after the first one will throw a UnrepeatableSequenceException. Only use this class if you know that the table needs to be read once only.

Since:
23 Jul 2007

Constructor Summary
SequentialResultSetStarTable(ResultSet rset)
          Constructor.
 
Method Summary
 List getColumnAuxDataInfos()
          Goes through the table columns (ColumnInfo objects) and picks out all the AuxData items which exist, generalising where necessary and returning a union of them in alphabetical order by name.
 int getColumnCount()
          Returns the number of columns in this table.
 ColumnInfo getColumnInfo(int icol)
          Returns the object describing the data in a given column.
 ResultSet getResultSet()
          Returns the result set on which this table is built.
 long getRowCount()
          Returns the number of rows in this table, if known.
 RowSequence getRowSequence()
          The first time it is called, returns an iterator over the rows of the result set.
 
Methods inherited from class uk.ac.starlink.table.AbstractStarTable
checkedLongToInt, getCell, getName, getParameterByName, getParameters, getRow, getURL, isRandom, setName, setParameter, setParameters, setURL
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SequentialResultSetStarTable

public SequentialResultSetStarTable(ResultSet rset)
                             throws SQLException
Constructor.

Parameters:
rset - result set containing data - should be positioned at start
Method Detail

getResultSet

public ResultSet getResultSet()
Returns the result set on which this table is built.

Returns:
result set

getColumnCount

public int getColumnCount()
Description copied from interface: StarTable
Returns the number of columns in this table.

Specified by:
getColumnCount in interface StarTable
Specified by:
getColumnCount in class AbstractStarTable

getColumnInfo

public ColumnInfo getColumnInfo(int icol)
Description copied from interface: StarTable
Returns the object describing the data in a given column.

Specified by:
getColumnInfo in interface StarTable
Specified by:
getColumnInfo in class AbstractStarTable

getRowCount

public long getRowCount()
Description copied from interface: StarTable
Returns the number of rows in this table, if known. If the number of rows cannot be (easily) determined, a value of -1 will be returned.

Specified by:
getRowCount in interface StarTable
Specified by:
getRowCount in class AbstractStarTable

getColumnAuxDataInfos

public List getColumnAuxDataInfos()
Description copied from class: AbstractStarTable
Goes through the table columns (ColumnInfo objects) and picks out all the AuxData items which exist, generalising where necessary and returning a union of them in alphabetical order by name. Subclasses should override this if they can do better, for instance providing an order for the keys.

Specified by:
getColumnAuxDataInfos in interface StarTable
Overrides:
getColumnAuxDataInfos in class AbstractStarTable
Returns:
a list of all the auxiliary metadata ValueInfo items which in fact crop up in column metadata

getRowSequence

public RowSequence getRowSequence()
                           throws UnrepeatableSequenceException,
                                  IOException
The first time it is called, returns an iterator over the rows of the result set. Subsequent calls will throw an UnrepeatableSequenceException.

Specified by:
getRowSequence in interface StarTable
Specified by:
getRowSequence in class AbstractStarTable
Throws:
UnrepeatableSequenceException - if called more than once
IOException

Copyright © 2004 CLRC: Central Laboratory of the Research Councils. All rights reserved.