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
-
Field Summary
Fields inherited from class org.firebirdsql.gds.ng.AbstractFbStatement
exceptionListenerDispatcher, statementListenerDispatcher
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final byte[]
calculateBlr
(RowDescriptor rowDescriptor) Returns the (possibly cached) blr byte array for aRowDescriptor
, ornull
if the parameter is null.protected final byte[]
calculateBlr
(RowDescriptor rowDescriptor, RowValue rowValue) Returns the blr byte array for aRowValue
, ornull
if the parameter is null.final void
close()
Close and deallocate this statement.final RowDescriptor
protected final BlrCalculator
final FbWireDatabase
final int
protected byte[]
getInfo
(int operation, byte[] requestItems, int bufferLength) byte[]
getSqlInfo
(byte[] requestItems, int bufferLength) Request statement info.protected final XdrInputStream
getXdrIn()
Gets the XdrInputStream.protected final XdrOutputStream
Gets the XdrOutputStream.protected boolean
isValidTransactionClass
(Class<? extends FbTransaction> transactionClass) Method to decide if a transaction implementation class is valid for the statement implementation.protected final void
setHandle
(int handle) final LockCloseable
withLock()
Locks the lock withLock.lock()
(or equivalent).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 usingFbWireDatabase.enqueueDeferredAction(DeferredAction)
, notifying the exception listener of this statement for exceptions, and forcing the ERROR state for IO errors.Methods inherited from class org.firebirdsql.gds.ng.AbstractFbStatement
addExceptionListener, addStatementListener, addWeakStatementListener, asyncFetchRows, checkFetchSize, checkPrepareAllowed, checkStatementHasOpenCursor, checkStatementValid, checkStatementValid, closeCursor, closeCursor, createExecutionPlanProcessor, createSqlCountProcessor, ensureClosedCursor, fetchScroll, fetchScrollImpl, forceState, free, getAllowedTimeout, getCursorInfo, getCursorInfo, getCursorInfoImpl, getCursorName, getExecutionPlan, getExplainedExecutionPlan, getParameterDescriptionInfoRequestItems, getParameterDescriptor, getRowDescriptor, getSqlCounts, getSqlInfo, getState, getStatementInfoRequestItems, getStatementWarningCallback, getTimeout, getTransaction, getTransactionListener, getType, hasFetched, hasFields, hasSingletonResult, isAfterLast, isBeforeFirst, isPrepareAllowed, parseStatementInfo, queueRowData, removeExceptionListener, removeStatementListener, reset, reset, resetAll, setAfterLast, setBeforeFirst, setCursorName, setCursorNameImpl, setParameterDescriptor, setRowDescriptor, setTimeout, setTransaction, setType, signalAsyncFetchComplete, signalAsyncFetchStart, signalExecute, signalFetch, switchState, unprepare, validateParameters
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.firebirdsql.gds.ng.listeners.ExceptionListenable
addExceptionListener, removeExceptionListener
Methods inherited from interface org.firebirdsql.gds.ng.FbStatement
addStatementListener, addWeakStatementListener, asyncFetchRows, batchCancel, batchExecute, clearCursorFlag, closeCursor, closeCursor, createBatchParameterBuffer, deferredBatchCreate, deferredBatchRelease, deferredBatchSend, ensureClosedCursor, execute, fetchRows, fetchScroll, getCursorInfo, getCursorInfo, getDefaultSqlInfoSize, getExecutionPlan, getExplainedExecutionPlan, getMaxSqlInfoSize, getParameterDescriptor, getRowDescriptor, getSqlCounts, getSqlInfo, getState, getTimeout, getTransaction, getType, hasFetched, isCursorFlagSet, prepare, removeStatementListener, setCursorFlag, setCursorName, setTimeout, setTransaction, supportBatchUpdates, supportsCursorInfo, supportsFetchScroll, unprepare, validateParameters
-
Constructor Details
-
AbstractFbWireStatement
-
-
Method Details
-
withLock
Description copied from interface:FbStatement
Locks the lock withLock.lock()
(or equivalent).Implementations are expected to apply the same lock as
FbAttachment.withLock()
.- Specified by:
withLock
in interfaceFbStatement
- Returns:
- lock closeable which unlocks the lock on close
- See Also:
-
getXdrIn
Gets the XdrInputStream.- Returns:
- Instance of XdrInputStream
- Throws:
SQLException
- If no connection is opened or when exceptions occur retrieving the InputStream
-
getXdrOut
Gets the XdrOutputStream.- Returns:
- Instance of XdrOutputStream
- Throws:
SQLException
- If no connection is opened or when exceptions occur retrieving the OutputStream
-
getDatabase
- Specified by:
getDatabase
in interfaceFbStatement
- Returns:
- The database connection that created this statement
-
getHandle
public final int getHandle()- Specified by:
getHandle
in interfaceFbStatement
- Returns:
- The Firebird statement handle identifier
-
setHandle
protected final void setHandle(int handle) -
calculateBlr
Returns the (possibly cached) blr byte array for aRowDescriptor
, ornull
if the parameter is null.- Parameters:
rowDescriptor
- The row descriptor.- Returns:
- blr byte array or
null
whenrowDescriptor
isnull
- Throws:
SQLException
- When theRowDescriptor
contains an unsupported field type.
-
calculateBlr
protected final byte[] calculateBlr(RowDescriptor rowDescriptor, RowValue rowValue) throws SQLException Returns the blr byte array for aRowValue
, ornull
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
whenrowValue
isnull
- Throws:
SQLException
- When theRowValue
contains an unsupported field type.
-
getBlrCalculator
- Returns:
- The
BlrCalculator
instance for this statement (currently always the one from theFbWireDatabase
instance).
-
close
Description copied from interface:FbStatement
Close and deallocate this statement.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceFbStatement
- Overrides:
close
in classAbstractFbStatement
- Throws:
SQLException
-
isValidTransactionClass
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 anFbWireTransaction
implementation.- Specified by:
isValidTransactionClass
in classAbstractFbStatement
- Parameters:
transactionClass
- Class of the transaction- Returns:
true
when the transaction class is valid for the statement implementation.
-
emptyRowDescriptor
- Specified by:
emptyRowDescriptor
in interfaceFbStatement
- Returns:
- A potentially cached empty row descriptor for this statement or database.
-
getSqlInfo
Description copied from interface:FbStatement
Request statement info.- Specified by:
getSqlInfo
in interfaceFbStatement
- Parameters:
requestItems
- Array of info items to requestbufferLength
- Response buffer length to use- Returns:
- Response buffer
- Throws:
SQLException
- For errors retrieving or transforming the response.
-
getInfo
- 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 usingFbWireDatabase.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 wrapresponseMapper
- Function to map aResponse
to the response object expected by the deferred responserequiresSync
-true
if the deferred response requires a sync action or flush before it can be processed- Returns:
- deferred action
-