    All Packages    This Package  Previous  Next

# Class sqlj.runtime.ref.ResultSetIterImpl

    java.lang.Object
       |
       +----sqlj.runtime.ref.ResultSetIterImpl

public class ResultSetIterImpl
extends Object
implements ResultSetIterator

The result set iter(ator) impl(ementation) class implements the functionality of both a positioned iterator, and a named iterator. However, it does not directly implement either of these interfaces. Rather, the translator will generate iterator classes which subclass this class and implement only the iterator interface that they were declared to implement (thus avoiding iterators which appear to be both positional and named).

This class is used internally by the reference translator code generation. It is expected that clients will not directly reference this class.

See Also:
  PositionedIterator, NamedIterator, ForUpdate

##

resultSet
  The underlying reference runtime result set

##

ResultSetIterImpl(RTResultSet)
  Creates a new result set iter impl object that uses data found in the passed result set.
ResultSetIterImpl(RTResultSet, int)
  Creates a new result set iter impl object that uses data found in the passed result set.

##

checkColumns(RTResultSet, int)
  Verifies that the passed result set has the passed expected number of columns.
close()
  closes this iterator and the underlying result set.
endFetch()
  Returns false if currently on a row, true otherwise.
finalize()
  finalizes the super object and calls close if this iterator has not already been closed.
findColumn(String)
  Returns the index associated with the passed column name on the underlying result set.
getCursorName()
  Returns the cursor name of the underlying result set.
getResultSet()
  Returns the JDBC result set associated with this iterator, if any.
isClosed()
  Returns true if this iterator has been closed, false otherwise.
next()
  Fetches the next row in the iterator and returns true if there was a row to fetch, false otherwise.

##

resultSet

     protected RTResultSet resultSet

  The underlying reference runtime result set

##

ResultSetIterImpl

     public ResultSetIterImpl(RTResultSet rs)

  Creates a new result set iter impl object that uses data found in the passed result set.

ResultSetIterImpl

     public ResultSetIterImpl(RTResultSet rs,
                              int numColumns) throws SQLException

  Creates a new result set iter impl object that uses data found in the passed result set. Verifies that the passed result set contains the same number of columns as is passed in the numColumns parameter.

  Note: If a SQLException is raised by the constructor, the passed result set is automatically closed.

  Parameters:
    rs - the underlying result set
    numColumns - the expected number of columns in the result set
  Throws: SQLException
    if the result set does not contain the expected number of columns
  See Also:
    checkColumns

##

checkColumns

     public static void checkColumns(RTResultSet rs,
                                     int expectedColumns) throws SQLException

  Verifies that the passed result set has the passed expected number of columns. An exception is raised if not. This method is provided for uniformity of error reporting between select..into and iterators.

  Parameters:
    rs - the result set to check.
    expectedColumns - the expected number of columns in the result set.
  Throws: SQLException
    if the result set does not have the expected number of columns.

findColumn

     protected int findColumn(String name) throws SQLException

  Returns the index associated with the passed column name on the underlying result set. Throws an exception if the column name does not exist. Used by generated named iterators for uniform treatment of findColumn. Assumes that this method is called during construction

  Note: We assume that this method is only called during subclass construction, and thus if a SQLException is raised during this method, the underlying result set is automatically closed.

  Parameters:
    name - the name of the column in question
  Throws: SQLException
    if the column cannot be found. Underlying result set is closed in this case.

getResultSet

     public ResultSet getResultSet() throws SQLException

  Returns the JDBC result set associated with this iterator, if any.

  Throws: SQLException
    if there is no JDBC result set associated with this iterator.

close

     public void close() throws SQLException

  closes this iterator and the underlying result set.

  Throws: SQLException
    if an error occurs during close
  See Also:
    close

isClosed

     public boolean isClosed() throws SQLException

  Returns true if this iterator has been closed, false otherwise.

  Throws: SQLException
    if a database access error occurs.
  See Also:
    isClosed

getCursorName

     public String getCursorName() throws SQLException

  Returns the cursor name of the underlying result set.

  Throws: SQLException
    if the underlying result set does not have a cursor name.
  See Also:
    getCursorName

endFetch

     public boolean endFetch() throws SQLException

  Returns false if currently on a row, true otherwise. Provides a termination condition for FETCH..INTO statements, as endFetch will be true after the last row has been FETCHed.

  Throws: SQLException
    if a database access error occurs.
  See Also:
    endFetch

next

     public boolean next() throws SQLException

  Fetches the next row in the iterator and returns true if there was a row to fetch, false otherwise.

  Throws: SQLException
    if an error occurs in the underlying result set's call to next.
  See Also:
    next

finalize

     protected void finalize() throws Throwable

  finalizes the super object and calls close if this iterator has not already been closed.

  Throws: Throwable
    if an error occurs during finalization
  Overrides:
    finalize in class Object
  See Also:
    close, isClosed

    All Packages    This Package  Previous  Next