org.apache.derby.client.net
Class NetCursor

java.lang.Object
  extended by org.apache.derby.client.am.Cursor
      extended by org.apache.derby.client.net.NetCursor
Direct Known Subclasses:
NetSqldta

public class NetCursor
extends Cursor


Field Summary
(package private)  boolean blocking_
           
(package private)  java.util.ArrayList extdtaData_
           
(package private)  java.util.HashMap extdtaPositions_
           
(package private)  boolean[] isGraphic_
           
(package private)  int maximumRowSize_
           
(package private)  NetAgent netAgent_
           
(package private)  NetResultSet netResultSet_
           
(package private)  int numMddOverrides_
           
private  boolean qryclsimpEnabled_
          Flag indicating whether the result set on the server is implicitly closed when end-of-data is received.
(package private)  Typdef qrydscTypdef_
           
(package private)  boolean rtnextrow_
           
(package private)  int targetSqlamForTypdef_
           
(package private)  int[] typeToUseForComputingDataLength_
           
 
Fields inherited from class org.apache.derby.client.am.Cursor
agent_, BYTES, ccsid_, charsetName_, columnDataComputedLength_, columnDataIsNullCache_, columnDataLengthCache_, columnDataPosition_, columnDataPositionCache_, columns_, currentRowPosition_, dataBuffer_, dataBufferStream_, DBCS_CLOB, fdocaLength_, hasLobs_, isNull_, isUpdateDeleteHole_, isUpdateDeleteHoleCache_, jdbcTypes_, lastValidBytePosition_, MBCS_CLOB, NULL_TERMINATED_BYTES, NULL_TERMINATED_STRING, nullable_, position_, ROW_IS_NOT_NULL, ROW_IS_NULL, SBCS_CLOB, STRING, VARIABLE_BYTES, VARIABLE_SHORT_BYTES, VARIABLE_SHORT_STRING, VARIABLE_STRING
 
Constructor Summary
NetCursor(NetAgent netAgent)
           
NetCursor(NetAgent netAgent, int qryprctyp)
           
 
Method Summary
private  void adjustColumnOffsetsForColumnsPreviouslyCalculated(int index)
           
private  int[] allocateColumnDataComputedLengthArray(int row)
           
private  boolean[] allocateColumnDataIsNullArray(int row)
           
private  int[] allocateColumnDataPositionArray(int row)
           
(package private)  void allocateColumnOffsetAndLengthArrays()
           
protected  void allocateDataBuffer()
           
protected  void allocateDataBuffer(int length)
           
protected  boolean calculateColumnOffsetsForRow_(int rowIndex, boolean allowServerFetch)
          Calculate the column offsets for a row.
(package private)  void calculateLobColumnPositionsForRow()
           
private  void checkAndThrowReceivedEndqryrm()
           
private  void checkAndThrowReceivedEndqryrm(int lastValidBytePositionBeforeFetch)
           
protected  void clearLobData_()
           
private  int completeSplitRow()
           
private  int completeSplitRow(int index)
           
(package private)  int ensureSpaceForDataBuffer(int ddmLength)
           
protected  byte[] findExtdtaData(int column)
           
 Blob getBlobColumn_(int column, Agent agent, boolean toBePublished)
          Returns a Blob object.
 byte[] getClobBytes_(int column, int[] dataOffset)
           
 Clob getClobColumn_(int column, Agent agent, boolean toBePublished)
          Returns a Clob object.
protected  int getDecimalLength(int index)
           
protected  void getMoreData_()
           
(package private)  boolean getQryclsimpEnabled()
          Check whether QRYCLSIMP is enabled on this cursor.
(package private)  void initializeColumnInfoArrays(Typdef typdef, int columnCount, int targetSqlamForTypdef)
           
protected  boolean isDataBufferNull()
           
(package private)  boolean isNonTrivialDataLob(int index)
           
protected  int locator(int column)
          Get locator for LOB of the designated column Note that this method cannot be invoked on a LOB column that is NULL.
 void nullDataForGC()
           
private  NetSqlca[] parseSQLCAGRP(Typdef typdef)
           
(package private)  NetSqlca[] parseSQLCARD(Typdef typdef)
           
private  void parseSQLCAXGRP(Typdef typdef, NetSqlca netSqlca)
           
private  NetSqlca parseSQLDCGRP()
           
private  NetSqlca parseSQLDCROW()
           
(package private)  void parseSQLDCTOKS()
           
private  void parseSQLDCXGRP()
           
private  NetSqlca[] parseSQLDIAGCI()
           
private  void parseSQLDIAGCN()
           
private  NetSqlca[] parseSQLDIAGGRP()
           
private  void parseSQLDIAGSTT()
           
private  java.lang.String parseVCS(Typdef typdefInEffect)
           
private  byte[] readFdocaBytes(int length)
           
private  int readFdocaInt()
           
private  long readFdocaLong()
           
private  int readFdocaOneByte()
           
private  int readFdocaOneByte(int index)
           
private  java.lang.String readFdocaString(int length, java.lang.String encoding)
           
private  int readFdocaTwoByteLength()
           
private  int readFdocaTwoByteLength(int index)
           
private  void resetCurrentRowPosition()
           
(package private)  void scanDataBufferForEndOfData()
          Scan the data buffer to see if end of data (SQL state 02000) has been received.
 void setAllRowsReceivedFromServer(boolean b)
          Set the value of value of allRowsReceivedFromServer_.
(package private)  void setBlocking(int queryProtocolType)
           
(package private)  void setQryclsimpEnabled(boolean flag)
          Set a flag indicating whether QRYCLSIMP is enabled.
private  void shiftPartialRowToBeginning()
           
private  int skipFdocaBytes(int length)
           
private  int skipFdocaBytes(int length, int index)
           
 
Methods inherited from class org.apache.derby.client.am.Cursor
allocateCharBuffer, allRowsReceivedFromServer, currentRowPositionIsEqualToNextRowPosition, dataBufferHasUnprocessedData, get_INTEGER, getArray, getAsciiStream, getBinaryStream, getBlob, getCharacterStream, getClob, getDataBuffer, getDataBufferLength, getIsRowUpdated, getIsUpdateDeleteHole, getLastValidBytePosition, getObject, getRef, getUnicodeStream, incrementRowsReadEvent, makeNextRowPositionCurrent, markCurrentRowPosition, markNextRowPosition, next, resetDataBuffer, setBuffer, setIsRowUpdated, setIsUpdataDeleteHole, setNumberOfColumns, stepNext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

netResultSet_

NetResultSet netResultSet_

netAgent_

NetAgent netAgent_

qrydscTypdef_

Typdef qrydscTypdef_

targetSqlamForTypdef_

int targetSqlamForTypdef_

numMddOverrides_

int numMddOverrides_

maximumRowSize_

int maximumRowSize_

blocking_

boolean blocking_

typeToUseForComputingDataLength_

int[] typeToUseForComputingDataLength_

isGraphic_

boolean[] isGraphic_

extdtaPositions_

java.util.HashMap extdtaPositions_

extdtaData_

java.util.ArrayList extdtaData_

rtnextrow_

boolean rtnextrow_

qryclsimpEnabled_

private boolean qryclsimpEnabled_
Flag indicating whether the result set on the server is implicitly closed when end-of-data is received.

Constructor Detail

NetCursor

NetCursor(NetAgent netAgent)

NetCursor

NetCursor(NetAgent netAgent,
          int qryprctyp)
Method Detail

calculateColumnOffsetsForRow_

protected boolean calculateColumnOffsetsForRow_(int rowIndex,
                                                boolean allowServerFetch)
                                         throws SqlException,
                                                DisconnectException
Calculate the column offsets for a row.

Pseudo-code:

  1. parse thru the current row in dataBuffer computing column offsets
  2. if (we hit the super.lastValidBytePosition, ie. encounter partial row)
    1. shift partial row bytes to beginning of dataBuffer (this.shiftPartialRowToBeginning())
    2. reset current row position (also done by this.shiftPartialRowToBeginning())
    3. send and recv continue-query into commBuffer (rs.flowContinueQuery())
    4. parse commBuffer up to QRYDTA (rs.flowContinueQuery())
    5. copy query data from reply's commBuffer to our dataBuffer (this.copyQrydta())

Specified by:
calculateColumnOffsetsForRow_ in class Cursor
Parameters:
rowIndex - row index
allowServerFetch - if true, allow fetching more data from server
Returns:
true if the current row position is a valid row position.
Throws:
SqlException
DisconnectException

scanDataBufferForEndOfData

void scanDataBufferForEndOfData()
                          throws SqlException
Scan the data buffer to see if end of data (SQL state 02000) has been received. This method should only be called when the cursor is being closed since the pointer to the current row can be modified.

Throws:
SqlException

isDataBufferNull

protected boolean isDataBufferNull()

allocateDataBuffer

protected void allocateDataBuffer()

allocateDataBuffer

protected void allocateDataBuffer(int length)

readFdocaInt

private int readFdocaInt()
                  throws DisconnectException,
                         SqlException
Throws:
DisconnectException
SqlException

readFdocaLong

private long readFdocaLong()
                    throws DisconnectException,
                           SqlException
Throws:
DisconnectException
SqlException

readFdocaOneByte

private int readFdocaOneByte()
                      throws DisconnectException,
                             SqlException
Throws:
DisconnectException
SqlException

readFdocaOneByte

private int readFdocaOneByte(int index)
                      throws DisconnectException,
                             SqlException
Throws:
DisconnectException
SqlException

readFdocaBytes

private byte[] readFdocaBytes(int length)
                       throws DisconnectException,
                              SqlException
Throws:
DisconnectException
SqlException

readFdocaTwoByteLength

private int readFdocaTwoByteLength()
                            throws DisconnectException,
                                   SqlException
Throws:
DisconnectException
SqlException

readFdocaTwoByteLength

private int readFdocaTwoByteLength(int index)
                            throws DisconnectException,
                                   SqlException
Throws:
DisconnectException
SqlException

skipFdocaBytes

private int skipFdocaBytes(int length)
                    throws DisconnectException,
                           SqlException
Throws:
DisconnectException
SqlException

skipFdocaBytes

private int skipFdocaBytes(int length,
                           int index)
                    throws DisconnectException,
                           SqlException
Throws:
DisconnectException
SqlException

shiftPartialRowToBeginning

private void shiftPartialRowToBeginning()

adjustColumnOffsetsForColumnsPreviouslyCalculated

private void adjustColumnOffsetsForColumnsPreviouslyCalculated(int index)

resetCurrentRowPosition

private void resetCurrentRowPosition()

calculateLobColumnPositionsForRow

void calculateLobColumnPositionsForRow()

isNonTrivialDataLob

boolean isNonTrivialDataLob(int index)

clearLobData_

protected void clearLobData_()
Specified by:
clearLobData_ in class Cursor

parseSQLCARD

NetSqlca[] parseSQLCARD(Typdef typdef)
                  throws DisconnectException,
                         SqlException
Throws:
DisconnectException
SqlException

parseSQLCAGRP

private NetSqlca[] parseSQLCAGRP(Typdef typdef)
                          throws DisconnectException,
                                 SqlException
Throws:
DisconnectException
SqlException

parseSQLCAXGRP

private void parseSQLCAXGRP(Typdef typdef,
                            NetSqlca netSqlca)
                     throws DisconnectException,
                            SqlException
Throws:
DisconnectException
SqlException

parseSQLDIAGGRP

private NetSqlca[] parseSQLDIAGGRP()
                            throws DisconnectException,
                                   SqlException
Throws:
DisconnectException
SqlException

parseSQLDIAGSTT

private void parseSQLDIAGSTT()
                      throws DisconnectException,
                             SqlException
Throws:
DisconnectException
SqlException

parseSQLDIAGCI

private NetSqlca[] parseSQLDIAGCI()
                           throws DisconnectException,
                                  SqlException
Throws:
DisconnectException
SqlException

parseSQLDIAGCN

private void parseSQLDIAGCN()
                     throws DisconnectException,
                            SqlException
Throws:
DisconnectException
SqlException

parseSQLDCGRP

private NetSqlca parseSQLDCGRP()
                        throws DisconnectException,
                               SqlException
Throws:
DisconnectException
SqlException

parseSQLDCROW

private NetSqlca parseSQLDCROW()
                        throws DisconnectException,
                               SqlException
Throws:
DisconnectException
SqlException

parseSQLDCTOKS

void parseSQLDCTOKS()
              throws DisconnectException,
                     SqlException
Throws:
DisconnectException
SqlException

parseSQLDCXGRP

private void parseSQLDCXGRP()
                     throws DisconnectException,
                            SqlException
Throws:
DisconnectException
SqlException

parseVCS

private java.lang.String parseVCS(Typdef typdefInEffect)
                           throws DisconnectException,
                                  SqlException
Throws:
DisconnectException
SqlException

readFdocaString

private java.lang.String readFdocaString(int length,
                                         java.lang.String encoding)
                                  throws DisconnectException,
                                         SqlException
Throws:
DisconnectException
SqlException

allocateColumnOffsetAndLengthArrays

void allocateColumnOffsetAndLengthArrays()

setBlocking

void setBlocking(int queryProtocolType)

findExtdtaData

protected byte[] findExtdtaData(int column)

locator

protected int locator(int column)
Get locator for LOB of the designated column

Note that this method cannot be invoked on a LOB column that is NULL.

Specified by:
locator in class Cursor
Parameters:
column - column number, starts at 1
Returns:
locator value, Lob.INVALID_LOCATOR if LOB value was sent instead of locator

getBlobColumn_

public Blob getBlobColumn_(int column,
                           Agent agent,
                           boolean toBePublished)
                    throws SqlException
Description copied from class: Cursor
Returns a Blob object.

Specified by:
getBlobColumn_ in class Cursor
Parameters:
column - 1-based column index
agent - associated agent
toBePublished - whether the Blob will be published to the user
Returns:
A Blob object.
Throws:
SqlException - if getting the Blob fails
See Also:
Cursor.getBlobColumn_(int, org.apache.derby.client.am.Agent, boolean)

getClobColumn_

public Clob getClobColumn_(int column,
                           Agent agent,
                           boolean toBePublished)
                    throws SqlException
Description copied from class: Cursor
Returns a Clob object.

Specified by:
getClobColumn_ in class Cursor
Parameters:
column - 1-based column index
agent - associated agent
toBePublished - whether the Clob will be published to the user
Returns:
A Clob object.
Throws:
SqlException - if getting the Clob fails
See Also:
Cursor.getClobColumn_(int, org.apache.derby.client.am.Agent, boolean)

getClobBytes_

public byte[] getClobBytes_(int column,
                            int[] dataOffset)
                     throws SqlException
Specified by:
getClobBytes_ in class Cursor
Throws:
SqlException

initializeColumnInfoArrays

void initializeColumnInfoArrays(Typdef typdef,
                                int columnCount,
                                int targetSqlamForTypdef)
                          throws DisconnectException
Throws:
DisconnectException

ensureSpaceForDataBuffer

int ensureSpaceForDataBuffer(int ddmLength)

getMoreData_

protected void getMoreData_()
                     throws SqlException
Specified by:
getMoreData_ in class Cursor
Throws:
SqlException

nullDataForGC

public void nullDataForGC()
Overrides:
nullDataForGC in class Cursor

checkAndThrowReceivedEndqryrm

private void checkAndThrowReceivedEndqryrm()
                                    throws SqlException
Throws:
SqlException

checkAndThrowReceivedEndqryrm

private void checkAndThrowReceivedEndqryrm(int lastValidBytePositionBeforeFetch)
                                    throws SqlException
Throws:
SqlException

completeSplitRow

private int completeSplitRow()
                      throws DisconnectException,
                             SqlException
Throws:
DisconnectException
SqlException

completeSplitRow

private int completeSplitRow(int index)
                      throws DisconnectException,
                             SqlException
Throws:
DisconnectException
SqlException

allocateColumnDataPositionArray

private int[] allocateColumnDataPositionArray(int row)

allocateColumnDataComputedLengthArray

private int[] allocateColumnDataComputedLengthArray(int row)

allocateColumnDataIsNullArray

private boolean[] allocateColumnDataIsNullArray(int row)

getDecimalLength

protected int getDecimalLength(int index)

setAllRowsReceivedFromServer

public final void setAllRowsReceivedFromServer(boolean b)
Set the value of value of allRowsReceivedFromServer_.

Overrides:
setAllRowsReceivedFromServer in class Cursor
Parameters:
b - a boolean value indicating whether all rows are received from the server

setQryclsimpEnabled

final void setQryclsimpEnabled(boolean flag)
Set a flag indicating whether QRYCLSIMP is enabled.

Parameters:
flag - true if QRYCLSIMP is enabled

getQryclsimpEnabled

final boolean getQryclsimpEnabled()
Check whether QRYCLSIMP is enabled on this cursor.

Returns:
true if QRYCLSIMP is enabled

Built on Thu 2010-12-23 20:49:13+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.