Class AbstractFbWireStatement

java.lang.Object
org.firebirdsql.gds.ng.AbstractFbStatement
org.firebirdsql.gds.ng.wire.AbstractFbWireStatement
All Implemented Interfaces:
AutoCloseable, FbStatement, ExceptionListenable, FbWireStatement
Direct Known Subclasses:
V10Statement

public abstract class AbstractFbWireStatement extends AbstractFbStatement implements FbWireStatement
Since:
3.0
Author:
Mark Rotteveel
  • Constructor Details

    • AbstractFbWireStatement

      protected AbstractFbWireStatement(FbWireDatabase database)
  • Method Details

    • withLock

      public final LockCloseable withLock()
      Description copied from interface: FbStatement
      Locks the lock with Lock.lock() (or equivalent).

      Implementations are expected to apply the same lock as FbAttachment.withLock().

      Specified by:
      withLock in interface FbStatement
      Returns:
      lock closeable which unlocks the lock on close
      See Also:
    • getXdrIn

      protected final XdrInputStream getXdrIn() throws SQLException
      Gets the XdrInputStream.
      Returns:
      Instance of XdrInputStream
      Throws:
      SQLException - If no connection is opened or when exceptions occur retrieving the InputStream
    • getXdrOut

      protected final XdrOutputStream getXdrOut() throws SQLException
      Gets the XdrOutputStream.
      Returns:
      Instance of XdrOutputStream
      Throws:
      SQLException - If no connection is opened or when exceptions occur retrieving the OutputStream
    • getDatabase

      public final FbWireDatabase getDatabase()
      Specified by:
      getDatabase in interface FbStatement
      Returns:
      The database connection that created this statement
    • getHandle

      public final int getHandle()
      Specified by:
      getHandle in interface FbStatement
      Returns:
      The Firebird statement handle identifier
    • setHandle

      protected final void setHandle(int handle)
    • calculateBlr

      protected final byte[] calculateBlr(RowDescriptor rowDescriptor) throws SQLException
      Returns the (possibly cached) blr byte array for a RowDescriptor, or null if the parameter is null.
      Parameters:
      rowDescriptor - The row descriptor.
      Returns:
      blr byte array or null when rowDescriptor is null
      Throws:
      SQLException - When the RowDescriptor contains an unsupported field type.
    • calculateBlr

      protected final byte[] calculateBlr(RowDescriptor rowDescriptor, RowValue rowValue) throws SQLException
      Returns the blr byte array for a RowValue, or null if the parameter is null.

      Contrary to calculateBlr(org.firebirdsql.gds.ng.fields.RowDescriptor), it is not allowed to cache this value as it depends on the actual row value.

      Parameters:
      rowValue - The row value.
      Returns:
      blr byte array or null when rowValue is null
      Throws:
      SQLException - When the RowValue contains an unsupported field type.
    • getBlrCalculator

      protected final BlrCalculator getBlrCalculator()
      Returns:
      The BlrCalculator instance for this statement (currently always the one from the FbWireDatabase instance).
    • close

      public final void close() throws SQLException
      Description copied from interface: FbStatement
      Close and deallocate this statement.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface FbStatement
      Overrides:
      close in class AbstractFbStatement
      Throws:
      SQLException
    • isValidTransactionClass

      protected boolean isValidTransactionClass(Class<? extends FbTransaction> transactionClass)
      Description copied from class: AbstractFbStatement
      Method to decide if a transaction implementation class is valid for the statement implementation.

      Eg a V10Statement will only work with an FbWireTransaction implementation.

      Specified by:
      isValidTransactionClass in class AbstractFbStatement
      Parameters:
      transactionClass - Class of the transaction
      Returns:
      true when the transaction class is valid for the statement implementation.
    • emptyRowDescriptor

      public final RowDescriptor emptyRowDescriptor()
      Specified by:
      emptyRowDescriptor in interface FbStatement
      Returns:
      A potentially cached empty row descriptor for this statement or database.
    • getSqlInfo

      public byte[] getSqlInfo(byte[] requestItems, int bufferLength) throws SQLException
      Description copied from interface: FbStatement
      Request statement info.
      Specified by:
      getSqlInfo in interface FbStatement
      Parameters:
      requestItems - Array of info items to request
      bufferLength - Response buffer length to use
      Returns:
      Response buffer
      Throws:
      SQLException - For errors retrieving or transforming the response.
    • getInfo

      protected byte[] getInfo(int operation, byte[] requestItems, int bufferLength) throws SQLException
      Throws:
      SQLException
    • wrapDeferredResponse

      protected final <T> DeferredAction wrapDeferredResponse(DeferredResponse<T> deferredResponse, Function<Response,T> responseMapper, boolean requiresSync)
      Wraps a deferred response to produce a deferred action that can be added using FbWireDatabase.enqueueDeferredAction(DeferredAction), notifying the exception listener of this statement for exceptions, and forcing the ERROR state for IO errors.
      Type Parameters:
      T - type of deferred response
      Parameters:
      deferredResponse - deferred response to wrap
      responseMapper - Function to map a Response to the response object expected by the deferred response
      requiresSync - true if the deferred response requires a sync action or flush before it can be processed
      Returns:
      deferred action