org.objectweb.medor.datasource.rdb.lib

Class JDBCTupleCollection

Implemented Interfaces:
TupleCollection

public class JDBCTupleCollection
extends java.lang.Object
implements TupleCollection

This class encapsulates a resultset as a TupleCollection.

Author:
S.Chassande-Barrioz

Constructor Summary

JDBCTupleCollection(TupleStructure tupleStructure, ResultSet rs, PreparedStatement ps, RdbAdapter adapter, Logger logger)

Method Summary

void
close()
void
first()
Moves the cursor to the first Tuple of this TupleCollection
TupleStructure
getMetaData()
int
getRow()
Retrieves the current row Number of this TupleCollection
Tuple
getTuple()
Tuple
getTuple(int row)
boolean
isEmpty()
boolean
isLast()
Checks whether the current row is the last row.
boolean
next()
Moves the cursor down one row from its current position to the next row.
boolean
row(int i)

Constructor Details

JDBCTupleCollection

public JDBCTupleCollection(TupleStructure tupleStructure,
                           ResultSet rs,
                           PreparedStatement ps,
                           RdbAdapter adapter,
                           Logger logger)
            throws MedorException,
                   ExpressionException,
                   SQLException

Parameters:
tupleStructure - is the TupleStructure describing the struture of the TupleCollection.
rs - is the encapsulated ResultSet. The resultset is already positioned on the first element.
ps - is the PreparedStatement which must be closed in same time than this tuple collection and the ResultSet.
adapter - is the RdbAdapter to use
logger -

Method Details

close

public void close()
            throws MedorException
Specified by:
close in interface TupleCollection


first

public void first()
            throws MedorException
Moves the cursor to the first Tuple of this TupleCollection
Specified by:
first in interface TupleCollection


getMetaData

public TupleStructure getMetaData()
            throws MedorException
Specified by:
getMetaData in interface TupleCollection


getRow

public int getRow()
            throws MedorException
Retrieves the current row Number of this TupleCollection
Specified by:
getRow in interface TupleCollection


getTuple

public Tuple getTuple()
            throws MedorException
Specified by:
getTuple in interface TupleCollection


getTuple

public Tuple getTuple(int row)
            throws MedorException
Specified by:
getTuple in interface TupleCollection


isEmpty

public boolean isEmpty()
            throws MedorException
Specified by:
isEmpty in interface TupleCollection


isLast

public boolean isLast()
            throws MedorException
Checks whether the current row is the last row.

This method relies on the resultSet.next() method, and not on the resultSet.isLast() method, since isLast is not supported by all JDBC drivers. Method next() of this class first checks whether resultSet.next() has already been called by isLast before calling it.

Specified by:
isLast in interface TupleCollection

Returns:
true if it was the last row, false otherwise

Throws:
MedorException - if there is a SQL exception


next

public boolean next()
            throws MedorException
Moves the cursor down one row from its current position to the next row.

Note that nothing is done in the case resultSet.next() was already called when calling isLast().

Specified by:
next in interface TupleCollection

Returns:
true if there was a next row, false if there is no next row.

Throws:
MedorException - if there is a SQL Exception.


row

public boolean row(int i)
            throws MedorException
Specified by:
row in interface TupleCollection