Package org.firebirdsql.gds.ng.wire
Class AbstractFbWireStatement
- java.lang.Object
-
- org.firebirdsql.gds.ng.AbstractFbStatement
-
- org.firebirdsql.gds.ng.wire.AbstractFbWireStatement
-
- All Implemented Interfaces:
java.lang.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 Constructor Description AbstractFbWireStatement(FbWireDatabase database)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected byte[]calculateBlr(RowDescriptor rowDescriptor)Returns the (possibly cached) blr byte array for aRowDescriptor, ornullif the parameter is null.protected byte[]calculateBlr(RowDescriptor rowDescriptor, RowValue rowValue)Returns the blr byte array for aRowValue, ornullif the parameter is null.voidclose()Close and deallocate this statement.RowDescriptoremptyRowDescriptor()protected BlrCalculatorgetBlrCalculator()FbWireDatabasegetDatabase()intgetHandle()protected byte[]getInfo(int operation, byte[] requestItems, int bufferLength)byte[]getSqlInfo(byte[] requestItems, int bufferLength)Request statement info.protected XdrInputStreamgetXdrIn()Gets the XdrInputStream.protected XdrOutputStreamgetXdrOut()Gets the XdrOutputStream.protected booleanisValidTransactionClass(java.lang.Class<? extends FbTransaction> transactionClass)Method to decide if a transaction implementation class is valid for the statement implementation.protected voidsetHandle(int handle)LockCloseablewithLock()Locks the lock withLock.lock()(or equivalent).protected <T> DeferredActionwrapDeferredResponse(DeferredResponse<T> deferredResponse, java.util.function.Function<Response,T> responseMapper)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, checkStatementValid, checkStatementValid, closeCursor, closeCursor, createExecutionPlanProcessor, createSqlCountProcessor, ensureClosedCursor, fetchScroll, fetchScrollImpl, finalize, forceState, free, getAllowedTimeout, getCursorInfo, getCursorInfo, getCursorInfoImpl, 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, setParameterDescriptor, setRowDescriptor, setTimeout, setTransaction, setType, signalExecute, signalFetch, switchState, unprepare, validateParameters
-
Methods inherited from class java.lang.Object
clone, equals, 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, 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 Detail
-
AbstractFbWireStatement
public AbstractFbWireStatement(FbWireDatabase database)
-
-
Method Detail
-
withLock
public final LockCloseable withLock()
Description copied from interface:FbStatementLocks the lock withLock.lock()(or equivalent).Implementations are expected to apply the same lock as
FbAttachment.withLock().- Specified by:
withLockin interfaceFbStatement- Returns:
- lock closeable which unlocks the lock on close
- See Also:
FbAttachment.withLock()
-
getXdrIn
protected final XdrInputStream getXdrIn() throws java.sql.SQLException
Gets the XdrInputStream.- Returns:
- Instance of XdrInputStream
- Throws:
java.sql.SQLException- If no connection is opened or when exceptions occur retrieving the InputStream
-
getXdrOut
protected final XdrOutputStream getXdrOut() throws java.sql.SQLException
Gets the XdrOutputStream.- Returns:
- Instance of XdrOutputStream
- Throws:
java.sql.SQLException- If no connection is opened or when exceptions occur retrieving the OutputStream
-
getDatabase
public final FbWireDatabase getDatabase()
- Specified by:
getDatabasein interfaceFbStatement- Returns:
- The database connection that created this statement
-
getHandle
public final int getHandle()
- Specified by:
getHandlein interfaceFbStatement- Returns:
- The Firebird statement handle identifier
-
setHandle
protected final void setHandle(int handle)
-
calculateBlr
protected final byte[] calculateBlr(RowDescriptor rowDescriptor) throws java.sql.SQLException
Returns the (possibly cached) blr byte array for aRowDescriptor, ornullif the parameter is null.- Parameters:
rowDescriptor- The row descriptor.- Returns:
- blr byte array or
nullwhenrowDescriptorisnull - Throws:
java.sql.SQLException- When theRowDescriptorcontains an unsupported field type.
-
calculateBlr
protected final byte[] calculateBlr(RowDescriptor rowDescriptor, RowValue rowValue) throws java.sql.SQLException
Returns the blr byte array for aRowValue, ornullif 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
nullwhenrowValueisnull - Throws:
java.sql.SQLException- When theRowValuecontains an unsupported field type.
-
getBlrCalculator
protected final BlrCalculator getBlrCalculator()
- Returns:
- The
BlrCalculatorinstance for this statement (currently always the one from theFbWireDatabaseinstance).
-
close
public void close() throws java.sql.SQLExceptionDescription copied from interface:FbStatementClose and deallocate this statement.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceFbStatement- Overrides:
closein classAbstractFbStatement- Throws:
java.sql.SQLException
-
isValidTransactionClass
protected boolean isValidTransactionClass(java.lang.Class<? extends FbTransaction> transactionClass)
Description copied from class:AbstractFbStatementMethod to decide if a transaction implementation class is valid for the statement implementation.Eg a
V10Statementwill only work with anFbWireTransactionimplementation.- Specified by:
isValidTransactionClassin classAbstractFbStatement- Parameters:
transactionClass- Class of the transaction- Returns:
truewhen the transaction class is valid for the statement implementation.
-
emptyRowDescriptor
public final RowDescriptor emptyRowDescriptor()
- Specified by:
emptyRowDescriptorin interfaceFbStatement- Returns:
- A potentially cached empty row descriptor for this statement or database.
-
getSqlInfo
public byte[] getSqlInfo(byte[] requestItems, int bufferLength) throws java.sql.SQLExceptionDescription copied from interface:FbStatementRequest statement info.- Specified by:
getSqlInfoin interfaceFbStatement- Parameters:
requestItems- Array of info items to requestbufferLength- Response buffer length to use- Returns:
- Response buffer
- Throws:
java.sql.SQLException- For errors retrieving or transforming the response.
-
getInfo
protected byte[] getInfo(int operation, byte[] requestItems, int bufferLength) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
wrapDeferredResponse
protected final <T> DeferredAction wrapDeferredResponse(DeferredResponse<T> deferredResponse, java.util.function.Function<Response,T> responseMapper)
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 aResponseto the response object expected by the deferred response- Returns:
- deferred action
-
-