Package uk.ac.starlink.table.jdbc
Class SequentialResultSetStarTable
- java.lang.Object
-
- uk.ac.starlink.table.AbstractStarTable
-
- uk.ac.starlink.table.jdbc.SequentialResultSetStarTable
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,StarTable
public class SequentialResultSetStarTable extends AbstractStarTable
StarTable implementation based on aResultSet
. It can read through the data once, and no more.Beware: it therefore breaks the general contract of
StarTable
, in that calls ofgetRowSequence()
after the first one will throw aUnrepeatableSequenceException
. Only use this class if you know that the table needs to be read once only.- Since:
- 23 Jul 2007
- Author:
- Mark Taylor
-
-
Constructor Summary
Constructors Constructor Description SequentialResultSetStarTable(java.sql.ResultSet rset)
Constructor.SequentialResultSetStarTable(StarResultSet srset)
Constructs from a StarResultSet.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
The AbstractStarTable implementation of this method does nothing.java.util.List<ValueInfo>
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.java.sql.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, getParameters, getRow, getRowAccess, getRowSplittable, getURL, isRandom, setName, setParameters, setURL
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface uk.ac.starlink.table.StarTable
getParameterByName, setParameter
-
-
-
-
Constructor Detail
-
SequentialResultSetStarTable
public SequentialResultSetStarTable(java.sql.ResultSet rset) throws java.sql.SQLException
Constructor.- Parameters:
rset
- result set containing data - should be positioned at start- Throws:
java.sql.SQLException
-
SequentialResultSetStarTable
public SequentialResultSetStarTable(StarResultSet srset)
Constructs from a StarResultSet.- Parameters:
srset
- result set containing data - should be positioned at start
-
-
Method Detail
-
getResultSet
public java.sql.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 interfaceStarTable
- Specified by:
getColumnCount
in classAbstractStarTable
- Returns:
- the number of columns
-
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 interfaceStarTable
- Specified by:
getColumnInfo
in classAbstractStarTable
- Parameters:
icol
- the column for which header information is required- Returns:
- a ValueInfo object for column icol
-
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 interfaceStarTable
- Specified by:
getRowCount
in classAbstractStarTable
- Returns:
- the number of rows, or -1
-
getColumnAuxDataInfos
public java.util.List<ValueInfo> 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 interfaceStarTable
- Overrides:
getColumnAuxDataInfos
in classAbstractStarTable
- Returns:
- a list of all the auxiliary metadata ValueInfo items which in fact crop up in column metadata
- See Also:
DefaultValueInfo.getAuxData()
-
getRowSequence
public RowSequence getRowSequence() throws UnrepeatableSequenceException, java.io.IOException
The first time it is called, returns an iterator over the rows of the result set. Subsequent calls will throw anUnrepeatableSequenceException
.- Specified by:
getRowSequence
in interfaceStarTable
- Specified by:
getRowSequence
in classAbstractStarTable
- Returns:
- new RowSequence
- Throws:
UnrepeatableSequenceException
- if called more than oncejava.io.IOException
- if there is an error providing access
-
close
public void close() throws java.io.IOException
Description copied from class:AbstractStarTable
The AbstractStarTable implementation of this method does nothing.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in interfaceStarTable
- Overrides:
close
in classAbstractStarTable
- Throws:
java.io.IOException
-
-