Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## sqlj.runtime.ref
Class ResultSetIterImpl

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

Direct Known Subclasses:
  ScrollableResultSetIterImpl

public class ResultSetIterImpl
extends java.lang.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`

Field Summary
`protected sqlj.runtime.profile.RTResultSet` | `resultSet` The underlying reference runtime result set

Constructor Summary
`ResultSetIterImpl(sqlj.runtime.profile.RTResultSet rs)` Creates a new result set iter impl object that uses data found in the passed result set.
`ResultSetIterImpl(sqlj.runtime.profile.RTResultSet rs, int numColumns)` Creates a new result set iter impl object that uses data found in the passed result set.

Method Summary
`static void` | `checkColumns(sqlj.runtime.profile.RTResultSet rs, int expectedColumns)` Verifies that the passed result set has the passed expected number of columns.
`void` | `clearWarnings()` After this call getWarnings returns null until a new warning is reported for this iterator.
`void` | `close()` closes this iterator and the underlying result set.
`boolean` | `endFetch()` Returns false if currently on a row, true otherwise.
`protected void` | `finalize()` finalizes the super object and calls close if this iterator has not already been closed.
`protected int` | `findColumn(java.lang.String name)` Returns the index associated with the passed column name on the underlying result set.
`java.lang.String` | `getCursorName()` Returns the cursor name of the underlying result set.
`int` | `getFetchSize()` Retrieves the number of rows that is the current fetch size for this iterator object.
`java.sql.ResultSet` | `getResultSet()` Returns the JDBC result set associated with this iterator, if any.
`int` | `getSensitivity()` Returns the sensitivity of this iterator object.
`java.sql.SQLWarning` | `getWarnings()` Returns the first warning reported by calls on this iterator is returned.
`boolean` | `isClosed()` Returns true if this iterator has been closed, false otherwise.
`boolean` | `next()` Fetches the next row in the iterator and returns true if there was a row to fetch, false otherwise.
`void` | `setFetchSize(int rows)` Gives the SQLJ runtime a hint as to the number of rows that should be fetched when more rows are needed from this iterator object.

Methods inherited from class java.lang.Object
`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### resultSet

    protected sqlj.runtime.profile.RTResultSet resultSet

  The underlying reference runtime result set

Constructor Detail

### ResultSetIterImpl

    public ResultSetIterImpl(sqlj.runtime.profile.RTResultSet rs)

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

### ResultSetIterImpl

    public ResultSetIterImpl(sqlj.runtime.profile.RTResultSet rs,
                             int numColumns)
                      throws java.sql.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:
    java.sql.SQLException - if the result set does not contain the expected number of columns
  See Also:
    `checkColumns(sqlj.runtime.profile.RTResultSet, int)`

Method Detail

### checkColumns

    public static void checkColumns(sqlj.runtime.profile.RTResultSet rs,
                                    int expectedColumns)
                             throws java.sql.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:
    java.sql.SQLException - if the result set does not have the expected number of columns.

### findColumn

    protected int findColumn(java.lang.String name)
                      throws java.sql.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:
    java.sql.SQLException - if the column cannot be found. Underlying result set is closed in this case.

### getResultSet

    public java.sql.ResultSet getResultSet()
                                    throws java.sql.SQLException

  Returns the JDBC result set associated with this iterator, if any.
  Specified by:
    getResultSet in interface ResultSetIterator
  Throws:
    java.sql.SQLException - if there is no JDBC result set associated with this iterator.

### close

    public void close()
               throws java.sql.SQLException

  closes this iterator and the underlying result set.
  Specified by:
    close in interface ResultSetIterator
  Throws:
    java.sql.SQLException - if an error occurs during close
  See Also:
    `ResultSetIterator.close()`

### isClosed

    public boolean isClosed()
                     throws java.sql.SQLException

  Returns true if this iterator has been closed, false otherwise.
  Specified by:
    isClosed in interface ResultSetIterator
  Throws:
    java.sql.SQLException - if a database access error occurs.
  See Also:
    `ResultSetIterator.isClosed()`

### getCursorName

    public java.lang.String getCursorName()
                                   throws java.sql.SQLException

  Returns the cursor name of the underlying result set.
  Throws:
    java.sql.SQLException - if the underlying result set does not have a cursor name.
  See Also:
    `ForUpdate.getCursorName()`

### endFetch

    public boolean endFetch()
                     throws java.sql.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:
    java.sql.SQLException - if a database access error occurs.
  See Also:
    `PositionedIterator.endFetch()`

### next

    public boolean next()
                 throws java.sql.SQLException

  Fetches the next row in the iterator and returns true if there was a row to fetch, false otherwise.
  Specified by:
    next in interface ResultSetIterator
  Throws:
    java.sql.SQLException - if an error occurs in the underlying result set's call to next.
  See Also:
    `ResultSetIterator.next()`

### getWarnings

    public java.sql.SQLWarning getWarnings()
                                    throws java.sql.SQLException

  Returns the first warning reported by calls on this iterator is returned. Subsequent iterator warings will be chained to this SQLWarning.
  Specified by:
    getWarnings in interface ResultSetIterator
  Throws:
    java.sql.SQLException - if a database access error occurs.
  See Also:
    `ResultSetIterator.getWarnings()`

### clearWarnings

    public void clearWarnings()
                       throws java.sql.SQLException

  After this call getWarnings returns null until a new warning is reported for this iterator.
  Specified by:
    clearWarnings in interface ResultSetIterator
  Throws:
    java.sql.SQLException - if a database-access error occurs.

### finalize

    protected void finalize()
                     throws java.lang.Throwable

  finalizes the super object and calls close if this iterator has not already been closed.
  Throws:
    java.lang.Throwable - if an error occurs during finalization
  Overrides:
    finalize in class java.lang.Object
  See Also:
    `close()`, `isClosed()`

### getFetchSize

    public int getFetchSize()
                     throws java.sql.SQLException

  Retrieves the number of rows that is the current fetch size for this iterator object. If this iterator object has not set a fetch size by calling the method setFetchSize, or has set a fetch size of zero, then the value returned is implementation-dependent.
  Specified by:
    getFetchSize in interface ResultSetIterator
  Returns:
    the default fetch size for the iterator object.
  Throws:
    java.sql.SQLException - if a database access error occurs.

### setFetchSize

    public void setFetchSize(int rows)
                      throws java.sql.SQLException

  Gives the SQLJ runtime a hint as to the number of rows that should be fetched when more rows are needed from this iterator object. If the value specified is zero, then the the runtime is free to choose an implementation-dependent fetch size.
  Specified by:
    setFetchSize in interface ResultSetIterator
  Parameters:
    `rows` - the default fetch size for result sets generated from this iterator object.
  Throws:
    java.sql.SQLException - if a database access error occurs, or the condition 0 <= rows <= ECtxt.getMaxRows() is not satisfied, where ECtxt is the ExecutionContext object that was used to create this iterator object.

### getSensitivity

    public int getSensitivity()
                       throws java.sql.SQLException

  Returns the sensitivity of this iterator object. The type is determined by the declaration of the iterator object and by the SQLJ runtime implementation that created the iterator object.
  Specified by:
    getSensitivity in interface ResultSetIterator
  Returns:
    - ResultSetIterator.SENSITIVE - if this iterator object was declared with the <predefined iterator with keyword> sensitivity and a corresponding <with value> SENSITIVE, and the SQLJ runtime that created this iterator object supports sensitive iterators.
    - ResultSetIterator.INSENSITIVE - if this iterator object object was declared with the <predefined iterator with keyword> sensitivity and a corresponding <with value> INSENSITIVE, and the SQLJ runtime that created this iterator object supports insensitive iterators.
    - ResultSetIterator.ASENSITIVE - if this iterator object was declared with the <predefined iterator with keyword> sensitivity and a corresponding <with value> ASENSITIVE.
    - An implementation-dependent value otherwise.
  Throws:
    java.sql.SQLException - if a database access error occurs

Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD