Module org.firebirdsql.jaybird
Package org.firebirdsql.gds.ng.listeners

# Class StatementListenerDispatcher

java.lang.Object
org.firebirdsql.gds.ng.listeners.AbstractListenerDispatcher<StatementListener>
org.firebirdsql.gds.ng.listeners.StatementListenerDispatcher

All Implemented Interfaces:
  `Iterable<StatementListener>`, `StatementListener`

public final class StatementListenerDispatcher extends AbstractListenerDispatcher<StatementListener> implements StatementListener
Dispatcher to maintain and notify other `StatementListener`.

Since:
  3.0
Author:
  Mark Rotteveel

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StatementListenerDispatcher()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `afterLast(FbStatement sender)`
  Method to be notified when the cursor of a statement is positioned after the last row.
  `void`
  `beforeFirst(FbStatement sender)`
  Method to be notified when the cursor of a statement is positioned before the first row.
  `void`
  `fetchComplete(FbStatement sender, FetchDirection fetchDirection, int rows)`
  Method to be notified of the number of rows fetched in a single `FbStatement.fetchRows(int)`.
  `protected void`
  `logError(String message, Throwable throwable)`
  `void`
  `receivedRow(FbStatement sender, RowValue rowValue)`
  Method to be notified of a new row of data.
  `void`
  `sqlCounts(FbStatement sender, SqlCountHolder sqlCounts)`
  Called when the SQL counts of a statement have been retrieved.
  `void`
  `statementExecuted(FbStatement sender, boolean hasResultSet, boolean hasSingletonResult)`
  Method to be notified when a statement has been executed.
  `void`
  `statementStateChanged(FbStatement sender, StatementState newState, StatementState previousState)`
  Method to be notified when the state of a statement has changed.
  `void`
  `warningReceived(FbStatement sender, SQLWarning warning)`
  Called when a warning was received for the `sender` statement.

  ### Methods inherited from class org.firebirdsql.gds.ng.listeners.AbstractListenerDispatcher

  `addListener, addWeakListener, isShutdown, iterator, notify, removeAllListeners, removeListener, shutdown`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface java.lang.Iterable

  `forEach, spliterator`

- ## Constructor Details

  - ### StatementListenerDispatcher

    public StatementListenerDispatcher()

- ## Method Details

  - ### receivedRow

    public void receivedRow(FbStatement sender, RowValue rowValue)
    Description copied from interface: `StatementListener`
    Method to be notified of a new row of data.

    Listeners that process `StatementListener.beforeFirst(FbStatement)` and/or `StatementListener.afterLast(FbStatement)` should consider calls to this method to clear the before-first or after-last state to an

  - in-cursor
  state.

Specified by:
  `receivedRow` in interface `StatementListener`
Parameters:
  `sender` - the `FbStatement` that called this method
  `rowValue` - The row values.

- ### fetchComplete

  public void fetchComplete(FbStatement sender, FetchDirection fetchDirection, int rows)
  Description copied from interface: `StatementListener`
  Method to be notified of the number of rows fetched in a single `FbStatement.fetchRows(int)`.

  This method will not be called for singleton results of statements like `EXECUTE PROCEDURE`.

  When end of cursor is reached, it is undefined whether this method will be called first or `afterLast/beforeFirst`. Listeners must be prepared to handle either order.

  Specified by:
    `fetchComplete` in interface `StatementListener`
  Parameters:
    `sender` - the `FbStatement` that called this method
    `fetchDirection` - fetch direction of the completed fetch operation
    `rows` - number of rows fetched in the completed fetch operation (NOTE: for native implementations, this will always be `1` or `0` for end of cursor)

- ### beforeFirst

  public void beforeFirst(FbStatement sender)
  Description copied from interface: `StatementListener`
  Method to be notified when the cursor of a statement is positioned before the first row.

  When server-side scrolling is used, this method can be called multiple times during the lifetime of a single open cursor. This method may be called even if the cursor is already before-first.

  Specified by:
    `beforeFirst` in interface `StatementListener`
  Parameters:
    `sender` - the `FbStatement` that called this method
  See Also:
    - `StatementListener.statementExecuted(FbStatement, boolean, boolean)`
    - `StatementListener.receivedRow(FbStatement, RowValue)`
    - `StatementListener.afterLast(FbStatement)`

- ### afterLast

  public void afterLast(FbStatement sender)
  Description copied from interface: `StatementListener`
  Method to be notified when the cursor of a statement is positioned after the last row.

  When server-side scrolling is used, this method might be called multiple times during the lifetime of a single open cursor. This method may be called even if the cursor is already after-last.

  Specified by:
    `afterLast` in interface `StatementListener`
  Parameters:
    `sender` - the `FbStatement` that called this method
  See Also:
    - `StatementListener.statementExecuted(FbStatement, boolean, boolean)`
    - `StatementListener.receivedRow(FbStatement, RowValue)`
    - `StatementListener.beforeFirst(FbStatement)`

- ### statementExecuted

  public void statementExecuted(FbStatement sender, boolean hasResultSet, boolean hasSingletonResult)
  Description copied from interface: `StatementListener`
  Method to be notified when a statement has been executed.

  This event with `hasResultSet=true` can be seen as a counterpart of `StatementListener.afterLast(FbStatement)`.

  Specified by:
    `statementExecuted` in interface `StatementListener`
  Parameters:
    `sender` - the `FbStatement` that called this method
    `hasResultSet` - `true` there is a result set, `false` there is no result set
    `hasSingletonResult` - `true` singleton result, `false` statement will produce indeterminate number of rows; can be ignored when `hasResultSet` is `false`

- ### statementStateChanged

  public void statementStateChanged(FbStatement sender, StatementState newState, StatementState previousState)
  Description copied from interface: `StatementListener`
  Method to be notified when the state of a statement has changed.
  Specified by:
    `statementStateChanged` in interface `StatementListener`
  Parameters:
    `sender` - the `FbStatement` that called this method
    `newState` - new state of the statement
    `previousState` - old state of the statement

- ### warningReceived

  public void warningReceived(FbStatement sender, SQLWarning warning)
  Description copied from interface: `StatementListener`
  Called when a warning was received for the `sender` statement.
  Specified by:
    `warningReceived` in interface `StatementListener`
  Parameters:
    `sender` - Statement receiving the warning
    `warning` - Warning

- ### sqlCounts

  public void sqlCounts(FbStatement sender, SqlCountHolder sqlCounts)
  Description copied from interface: `StatementListener`
  Called when the SQL counts of a statement have been retrieved.
  Specified by:
    `sqlCounts` in interface `StatementListener`
  Parameters:
    `sender` - Statement that called this method
    `sqlCounts` - SQL counts

- ### logError

  protected void logError(String message, Throwable throwable)
  Specified by:
    `logError` in class `AbstractListenerDispatcher<StatementListener>`