com.simba.dsi.dataengine.impl
Class DSISimpleResultSet

java.lang.Object
  extended by com.simba.dsi.dataengine.impl.DSISimpleResultSet
All Implemented Interfaces:
IResultSet
Direct Known Subclasses:
DSIEmptyResultSet, DSIMetadataOnlyResultSet, DSIMetadataResultSet

public abstract class DSISimpleResultSet
extends java.lang.Object
implements IResultSet

Simple partial implementation of IResult which facilitates forward-only cursors. Implementers choosing to subclass DSISimpleResultSet need only cache the the current row in memory.


Field Summary
 
Fields inherited from interface com.simba.dsi.dataengine.interfaces.IResultSet
CURSOR_POSITION_BEFORE, RETRIEVE_ALL_DATA, ROW_COUNT_UNKNOWN
 
Constructor Summary
protected DSISimpleResultSet()
          Constructor.
 
Method Summary
 void appendRow()
          Append an empty row to the end of the result set.
 void close()
          Closes the ResultSet and releases any resources held by it.
 void closeCursor()
          Closes the result set's internal cursor.
 void deleteRow()
          Delete the current row from the result set.
protected abstract  void doCloseCursor()
          Clean up memory by closing the cursor.
protected abstract  boolean doMoveToNextRow()
          Moves the result set's internal cursor to the next row.
protected  int getCurrentRow()
          Get the current row number.
 boolean getDataNeeded(int column)
          Indicates whether getData() might be called on the given column after the next call to moveToNextRow().
 int getFetchSize()
          Retrieves the fetch size being used for this ResultSet.
 com.simba.support.IWarningListener getWarningListener()
          Gets the warning listener of this result set.
 boolean moveToNextRow()
          Moves the result set's internal cursor to the next row.
 void onFinishRowUpdate()
          Indicate that the current row is finished having data written to it.
 void onStartRowUpdate()
          Indicate that the current row is about to have data written to it.
 void registerWarningListener(com.simba.support.IWarningListener listener)
          Registers a warning listener for allowing the result set to post warnings.
 boolean rowDeleted()
          Retrieves whether the current row has been deleted.
 boolean rowInserted()
          Retrieves whether the current row has been inserted.
 boolean rowUpdated()
          Retrieves whether the current row has been updated.
 void setCursorType(CursorType cursorType)
          Sets the type of the cursor to be used for traversing over the result set.
 void setDataNeeded(int column, boolean isDataNeeded)
          Indicates whether getData() might be called on the given column after the next call to moveToNextRow().
 void setFetchSize(int fetchSize)
          Sets the fetch size being used for this ResultSet.
 boolean supportsHasMoreRows()
          Method to notify the JDBC layer if this resultset can support checking if there is a next row through the method IResultSet.hasMoreRows().
 boolean writeData(int column, DataWrapper data, long offset, boolean isDefault)
          Write data to a column in the current row and specified column.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.simba.dsi.dataengine.interfaces.IResultSet
getData, getRowCount, getSelectColumns, hasMoreRows, hasRowCount
 

Constructor Detail

DSISimpleResultSet

protected DSISimpleResultSet()
Constructor.

Method Detail

appendRow

public void appendRow()
               throws com.simba.support.exceptions.ErrorException
Append an empty row to the end of the result set. The cursor should be positioned on the newly appended row when the function returns.

Specified by:
appendRow in interface IResultSet
Throws:
com.simba.support.exceptions.ErrorException - if the result does not support updating.

close

public void close()
Closes the ResultSet and releases any resources held by it.

An IResultSet is closed: - just before the parent IQueryExecutor is closed, if the result set was generated by executing a query. - during a call to SQLCancel(), SQLCloseCursor() or SQLFreeStmt(SQL_CLOSE) while dealing with metadata results. - just before preparing a new query or generating a new metadata result on the parent statement while dealing with metadata results.

Specified by:
close in interface IResultSet

closeCursor

public void closeCursor()
                 throws com.simba.support.exceptions.ErrorException
Closes the result set's internal cursor. After a call to this method, no more calls will be made to moveToNextRow() and getData().

This method will not be called until IQueryExecutor.execute() has been called on the corresponding IQueryExecutor.

Specified by:
closeCursor in interface IResultSet
Throws:
com.simba.support.exceptions.ErrorException - If an error occurs

deleteRow

public void deleteRow()
               throws com.simba.support.exceptions.ErrorException
Delete the current row from the result set. The cursor should be positioned on the previous row when the function returns, so that the next call to Move() would move to the row after the deleted row.

Specified by:
deleteRow in interface IResultSet
Throws:
com.simba.support.exceptions.ErrorException - if the result does not support updating.

getDataNeeded

public boolean getDataNeeded(int column)
Indicates whether getData() might be called on the given column after the next call to moveToNextRow().

Specified by:
getDataNeeded in interface IResultSet
Parameters:
column - A column index. The first column uses index 0.
Returns:
true if data may be retrieved from the given column; false otherwise.
Throws:
java.lang.IndexOutOfBoundsException - if column number is negative.

getFetchSize

public int getFetchSize()
                 throws com.simba.support.exceptions.ErrorException
Retrieves the fetch size being used for this ResultSet.

Specified by:
getFetchSize in interface IResultSet
Returns:
the number of rows to attempt to fetch at a time.
Throws:
com.simba.support.exceptions.ErrorException - if an error occurs.

getWarningListener

public com.simba.support.IWarningListener getWarningListener()
Gets the warning listener of this result set.

Returns:
The warning listener of this result set.

moveToNextRow

public boolean moveToNextRow()
                      throws com.simba.support.exceptions.ErrorException
Moves the result set's internal cursor to the next row. Initially, the cursor should be placed before the first row, so the first call to moveToNextRow() moves it to the first row. The return value indicates if the move was successful or not.

This method will not be called until IQueryExecutor.execute() has been called on the corresponding IQueryExecutor.

Specified by:
moveToNextRow in interface IResultSet
Returns:
true if the move was successful, false if there is not another row left to move to.
Throws:
com.simba.support.exceptions.ErrorException - If an error occurs.

onFinishRowUpdate

public void onFinishRowUpdate()
                       throws com.simba.support.exceptions.ErrorException
Indicate that the current row is finished having data written to it.

Specified by:
onFinishRowUpdate in interface IResultSet
Throws:
com.simba.support.exceptions.ErrorException - If there is an error writing the row that cannot be determined until all of the data for the row has been written through calls to IResultSet.writeData(int, DataWrapper, long, boolean). If an error happens when writing a particular column, the preferred behaviour is to throw an exception from writeData.

onStartRowUpdate

public void onStartRowUpdate()
Indicate that the current row is about to have data written to it. Note that when AppendRow() is called, OnStartRowUpdate() will not be called as it is implied that the newly added row will be updated.

Specified by:
onStartRowUpdate in interface IResultSet

registerWarningListener

public void registerWarningListener(com.simba.support.IWarningListener listener)
Registers a warning listener for allowing the result set to post warnings.

Specified by:
registerWarningListener in interface IResultSet
Parameters:
listener - The listener to register with this result set.

rowDeleted

public boolean rowDeleted()
Retrieves whether the current row has been deleted.

Specified by:
rowDeleted in interface IResultSet
Returns:
True if the current row has been deleted; false otherwise.

rowInserted

public boolean rowInserted()
Retrieves whether the current row has been inserted.

Specified by:
rowInserted in interface IResultSet
Returns:
True if the current row has been inserted; false otherwise.

rowUpdated

public boolean rowUpdated()
Retrieves whether the current row has been updated.

Specified by:
rowUpdated in interface IResultSet
Returns:
True if the current row has been updated; false otherwise.

setCursorType

public void setCursorType(CursorType cursorType)
                   throws com.simba.support.exceptions.ErrorException
Sets the type of the cursor to be used for traversing over the result set.

This method must be called before calling move(), otherwise the cursor type used is undefined.

Specified by:
setCursorType in interface IResultSet
Parameters:
cursorType - The type of cursor used to traverse the result set.
Throws:
com.simba.support.exceptions.ErrorException - if the cursor type is not supported.

setDataNeeded

public void setDataNeeded(int column,
                          boolean isDataNeeded)
Indicates whether getData() might be called on the given column after the next call to moveToNextRow(). The value given here applies for any subsequent moveToNextRow() calls.

Specified by:
setDataNeeded in interface IResultSet
Parameters:
column - A column index. The first column uses index 0.
isDataNeeded - Indicates whether data may be retrieved from the given column.
Throws:
java.lang.IndexOutOfBoundsException - if column number is negative.

setFetchSize

public void setFetchSize(int fetchSize)
                  throws com.simba.support.exceptions.ErrorException
Sets the fetch size being used for this ResultSet. This may be ignored in favour of using a preferred default.

If the specified fetch size is zero, the default fetch size will automatically be used.

Specified by:
setFetchSize in interface IResultSet
Parameters:
fetchSize - The number of rows to attempt to fetch at a time.
Throws:
com.simba.support.exceptions.ErrorException - if an error occurs.

writeData

public boolean writeData(int column,
                         DataWrapper data,
                         long offset,
                         boolean isDefault)
                  throws com.simba.support.exceptions.ErrorException
Write data to a column in the current row and specified column. Note that if isDefault is true, then data will be null, and offset should be ignored.

Specified by:
writeData in interface IResultSet
Parameters:
column - The column to write data to.
data - The container for the data to write.
offset - The offset into the column to start writing data at.
isDefault - Flag indicating that the default value should be used for the column.
Returns:
true if data is truncated; false otherwise.
Throws:
com.simba.support.exceptions.ErrorException - if the column is invalid, the offset is invalid or will result in data overflowing the boundaries of the column, or if the result does not support updating.

supportsHasMoreRows

public boolean supportsHasMoreRows()
Description copied from interface: IResultSet
Method to notify the JDBC layer if this resultset can support checking if there is a next row through the method IResultSet.hasMoreRows(). This method should consistently return the same value per instance.

Specified by:
supportsHasMoreRows in interface IResultSet
Returns:
true if IResultSet.hasMoreRows() is supported; false otherwise.

doCloseCursor

protected abstract void doCloseCursor()
                               throws com.simba.support.exceptions.ErrorException
Clean up memory by closing the cursor. Called from closeCursor() to ensure that the ResultSet performs any special handling needed to clear associated memory.

Throws:
com.simba.support.exceptions.ErrorException - If an error occurs.

doMoveToNextRow

protected abstract boolean doMoveToNextRow()
                                    throws com.simba.support.exceptions.ErrorException
Moves the result set's internal cursor to the next row. Initially, the cursor should be placed before the first row, so the first call to moveToNextRow() moves it to the first row.

This method will not be called until IQueryExecutor.execute() has been called on the corresponding IQueryExecutor.

Returns:
true if the move was successful, false if there is not another row left to move to.
Throws:
com.simba.support.exceptions.ErrorException - If an error occurs.

getCurrentRow

protected int getCurrentRow()
Get the current row number.

Returns:
The current 0-based row number.


Copyright © 2006-2014 Simba Technologies Incorporated. All Rights Reserved.