Package uk.ac.starlink.table.jdbc
Class StarResultSet
- java.lang.Object
-
- uk.ac.starlink.table.jdbc.StarResultSet
-
public class StarResultSet extends java.lang.Object
Wraps theResultSet
class to provide the functions which are required to provideStarTable
functionality.- Since:
- 23 Jul 2007
- Author:
- Mark Taylor
-
-
Constructor Summary
Constructors Constructor Description StarResultSet(java.sql.ResultSet rset)
Constructs a StarResultSet with default type mapping behaviour.StarResultSet(java.sql.ResultSet rset, TypeMapper typeMapper)
Constructs a StarResultSet with given type mapping behaviour.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RowSequence
createRowSequence()
Returns a sequential RowSequence based on this object.java.lang.Object
getCell(int icol)
Returns the object at a given column in the current row of this result set in a form suitable for use as the content of a StarTable cell.java.util.List
getColumnAuxDataInfos()
Returns an ordered list ofValueInfo
objects representing the auxilliary metadata returned by this object's ColumnInfo objects.ColumnInfo[]
getColumnInfos()
Returns the array of column metadata objects corresponding to the columns in this result set.java.sql.ResultSet
getResultSet()
Returns the result set on which this table is based.java.lang.Object[]
getRow()
Returns the current row of this result set in a form suitable for use as the content of a StarTable.long
getRowCount()
Lazily counts the number of rows in this result set, if it has random access.boolean
isRandom()
Indicates whether this result set can be used for random access.void
setRowIndex(long lrow)
Sets the row index from which subsequentgetCell(int)
andgetRow()
calls will read.
-
-
-
Constructor Detail
-
StarResultSet
public StarResultSet(java.sql.ResultSet rset) throws java.sql.SQLException
Constructs a StarResultSet with default type mapping behaviour.- Parameters:
rset
- result set- Throws:
java.sql.SQLException
-
StarResultSet
public StarResultSet(java.sql.ResultSet rset, TypeMapper typeMapper) throws java.sql.SQLException
Constructs a StarResultSet with given type mapping behaviour.- Parameters:
rset
- result settypeMapper
- handles conversion of JDBC types to cell types- Throws:
java.sql.SQLException
-
-
Method Detail
-
getResultSet
public java.sql.ResultSet getResultSet()
Returns the result set on which this table is based.- Returns:
- result set
-
getColumnInfos
public ColumnInfo[] getColumnInfos()
Returns the array of column metadata objects corresponding to the columns in this result set.- Returns:
- column info array (not a copy)
-
isRandom
public boolean isRandom()
Indicates whether this result set can be used for random access.- Returns:
- true iff random access is possible
-
getRowCount
public long getRowCount()
Lazily counts the number of rows in this result set, if it has random access. Otherwise, returns -1 (unknown), since a count may be very expensive. If the count cannot be calculated for a random access table for some reason, zero is returned and a warning is logged.- Returns:
- row count
-
getColumnAuxDataInfos
public java.util.List getColumnAuxDataInfos()
Returns an ordered list ofValueInfo
objects representing the auxilliary metadata returned by this object's ColumnInfo objects.- Returns:
- an unmodifiable ordered set of known metadata keys
- See Also:
StarTable.getColumnAuxDataInfos()
-
setRowIndex
public void setRowIndex(long lrow) throws java.io.IOException
Sets the row index from which subsequentgetCell(int)
andgetRow()
calls will read. Callers may need to worry about synchronization.- Parameters:
lrow
- row index (0-based)- Throws:
java.lang.UnsupportedOperationException
- for non-random result setsjava.io.IOException
-
getCell
public java.lang.Object getCell(int icol) throws java.io.IOException
Returns the object at a given column in the current row of this result set in a form suitable for use as the content of a StarTable cell. Callers may need to worry about synchronization.- Parameters:
icol
- the column to use (first column is 0)- Returns:
- the cell value
- Throws:
java.io.IOException
-
getRow
public java.lang.Object[] getRow() throws java.io.IOException
Returns the current row of this result set in a form suitable for use as the content of a StarTable. Callers may need to worry about synchronization.- Returns:
- array of cell values in current row
- Throws:
java.io.IOException
-
createRowSequence
public RowSequence createRowSequence() throws java.io.IOException
Returns a sequential RowSequence based on this object. This assumes that the cursor is currently at the beginning of the result set - no checking is performed here.- Returns:
- row sequence
- Throws:
java.io.IOException
-
-