Package org.apache.derby.client.am
Class Cursor
- java.lang.Object
-
- org.apache.derby.client.am.Cursor
-
- Direct Known Subclasses:
NetCursor
public abstract class Cursor extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected Agentagent_private booleanallRowsReceivedFromServer_static intBYTESint[]ccsid_private char[]charBuffer_java.nio.charset.Charset[]charset_protected int[]columnDataComputedLength_protected java.util.ArrayList<boolean[]>columnDataIsNullCache_protected java.util.ArrayList<int[]>columnDataLengthCache_protected int[]columnDataPosition_protected java.util.ArrayList<int[]>columnDataPositionCache_intcolumns_protected intcurrentRowPosition_byte[]dataBuffer_java.io.ByteArrayOutputStreamdataBufferStream_int[]fdocaLength_booleanhasLobs_boolean[]isNull_(package private) static java.nio.charset.CharsetISO_8859_1private booleanisRowUpdated_(package private) booleanisUpdateDeleteHole_(package private) java.util.ArrayList<java.lang.Boolean>isUpdateDeleteHoleCache_int[]jdbcTypes_intlastValidBytePosition_(package private) intmaxFieldSize_private intnextRowPosition_static intNULL_TERMINATED_BYTESstatic intNULL_TERMINATED_STRINGboolean[]nullable_intposition_private java.util.CalendarrecyclableCalendar_private static java.lang.BooleanROW_IS_NOT_NULL(package private) static java.lang.BooleanROW_IS_NULL(package private) longrowsRead_static intSTRING(package private) static java.nio.charset.CharsetUTF_16BE(package private) static java.nio.charset.CharsetUTF_8static intVARIABLE_SHORT_STRINGstatic intVARIABLE_STRING
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidallocateCharBuffer()booleanallRowsReceivedFromServer()Returntrueif all rows are received from the server.protected abstract booleancalculateColumnOffsetsForRow_(int row, boolean allowServerFetch)Calculate the column offsets for a row.protected abstract voidclearLobData_()private ColumnTypeConversionExceptioncoercionError(java.lang.String targetType, int sourceColumn)(package private) booleancurrentRowPositionIsEqualToNextRowPosition()(package private) booleandataBufferHasUnprocessedData()private longget_BIGINT(int column)private booleanget_BOOLEAN(int column)private byte[]get_CHAR_FOR_BIT_DATA(int column)private java.math.BigDecimalget_DECIMAL(int column)private doubleget_DOUBLE(int column)private floatget_FLOAT(int column)protected intget_INTEGER(int column)private shortget_SMALLINT(int column)private java.lang.Objectget_UDT(int column)private byte[]get_VARCHAR_FOR_BIT_DATA(int column)(package private) java.sql.ArraygetArray(int column)(package private) java.io.InputStreamgetAsciiStream(int column)(package private) java.math.BigDecimalgetBigDecimal(int column)(package private) java.io.InputStreamgetBinaryStream(int column)(package private) java.sql.BlobgetBlob(int column)abstract ClientBlobgetBlobColumn_(int column, Agent agent, boolean toBePublished)Returns aBlobobject.(package private) booleangetBoolean(int column)(package private) bytegetByte(int column)(package private) byte[]getBytes(int column)private java.lang.StringgetCHAR(int column)(package private) java.io.ReadergetCharacterStream(int column)(package private) java.sql.ClobgetClob(int column)abstract ClientClobgetClobColumn_(int column, Agent agent, boolean toBePublished)Returns aClobobject.private intgetColumnPrecision(int column)private intgetColumnScale(int column)(package private) java.sql.DategetDate(int column, java.util.Calendar cal)private java.sql.DategetDATE(int column, java.util.Calendar cal)private java.sql.DategetDateFromTIMESTAMP(int column, java.util.Calendar cal)(package private) doublegetDouble(int column)private doublegetDoubleFromDECIMAL(int column)(package private) floatgetFloat(int column)(package private) intgetInt(int column)booleangetIsRowUpdated()Get updated status for this row.booleangetIsUpdateDeleteHole()Get deleted status for this row.(package private) CallableLocatorProceduresgetLocatorProcedures()Returns a reference to the locator procedures.(package private) longgetLong(int column)private longgetLongFromDECIMAL(int column, java.lang.String targetType)protected abstract voidgetMoreData_()(package private) java.lang.ObjectgetObject(int column)private java.util.CalendargetRecyclableCalendar()Instantiate an instance of Calendar that can be re-used for getting Time, Timestamp, and Date values from this cursor.(package private) java.sql.RefgetRef(int column)(package private) shortgetShort(int column)(package private) java.lang.StringgetString(int column)private java.lang.StringgetStringFromDATE(int column)private java.lang.StringgetStringFromTIME(int column)private java.lang.StringgetStringFromTIMESTAMP(int column)private java.lang.StringgetStringWithoutConvert(int position, int actualLength)(package private) java.sql.TimegetTime(int column, java.util.Calendar cal)private java.sql.TimegetTIME(int column, java.util.Calendar cal)private java.sql.TimegetTimeFromTIMESTAMP(int column, java.util.Calendar cal)(package private) java.sql.TimestampgetTimestamp(int column, java.util.Calendar cal)private java.sql.TimestampgetTIMESTAMP(int column, java.util.Calendar cal)private java.sql.TimestampgetTimestampFromDATE(int column, java.util.Calendar cal)private java.sql.TimestampgetTimestampFromTIME(int column, java.util.Calendar cal)private java.lang.StringgetVARCHAR(int column)voidincrementRowsReadEvent()protected abstract intlocator(int column)Returns the locator for the specified LOB column, orLob.INVALID_LOCATORif the LOB was not sent as a locator.protected voidmakeNextRowPositionCurrent()protected voidmarkNextRowPosition()booleannext()Makes the next row the current row.voidnullDataForGC()voidresetDataBuffer()voidsetAllRowsReceivedFromServer(boolean b)Set the value of value of allRowsReceivedFromServer_.voidsetIsRowUpdated(boolean isRowUpdated)Keep track of updated status for this row.voidsetIsUpdataDeleteHole(int row, boolean isRowNull)voidsetNumberOfColumns(int numberOfColumns)protected booleanstepNext(boolean allowServerFetch)Makes the next row the current row.
-
-
-
Field Detail
-
agent_
protected Agent agent_
-
STRING
public static final int STRING
- See Also:
- Constant Field Values
-
VARIABLE_STRING
public static final int VARIABLE_STRING
- See Also:
- Constant Field Values
-
VARIABLE_SHORT_STRING
public static final int VARIABLE_SHORT_STRING
- See Also:
- Constant Field Values
-
NULL_TERMINATED_STRING
public static final int NULL_TERMINATED_STRING
- See Also:
- Constant Field Values
-
BYTES
public static final int BYTES
- See Also:
- Constant Field Values
-
NULL_TERMINATED_BYTES
public static final int NULL_TERMINATED_BYTES
- See Also:
- Constant Field Values
-
UTF_16BE
static final java.nio.charset.Charset UTF_16BE
-
UTF_8
static final java.nio.charset.Charset UTF_8
-
ISO_8859_1
static final java.nio.charset.Charset ISO_8859_1
-
dataBuffer_
public byte[] dataBuffer_
-
dataBufferStream_
public java.io.ByteArrayOutputStream dataBufferStream_
-
position_
public int position_
-
lastValidBytePosition_
public int lastValidBytePosition_
-
hasLobs_
public boolean hasLobs_
-
currentRowPosition_
protected int currentRowPosition_
-
nextRowPosition_
private int nextRowPosition_
-
columnDataPosition_
protected int[] columnDataPosition_
-
columnDataComputedLength_
protected int[] columnDataComputedLength_
-
allRowsReceivedFromServer_
private boolean allRowsReceivedFromServer_
-
rowsRead_
long rowsRead_
-
maxFieldSize_
int maxFieldSize_
-
columnDataPositionCache_
protected java.util.ArrayList<int[]> columnDataPositionCache_
-
columnDataLengthCache_
protected java.util.ArrayList<int[]> columnDataLengthCache_
-
columnDataIsNullCache_
protected java.util.ArrayList<boolean[]> columnDataIsNullCache_
-
isUpdateDeleteHoleCache_
java.util.ArrayList<java.lang.Boolean> isUpdateDeleteHoleCache_
-
isUpdateDeleteHole_
boolean isUpdateDeleteHole_
-
isRowUpdated_
private boolean isRowUpdated_
-
ROW_IS_NULL
static final java.lang.Boolean ROW_IS_NULL
-
ROW_IS_NOT_NULL
private static final java.lang.Boolean ROW_IS_NOT_NULL
-
recyclableCalendar_
private java.util.Calendar recyclableCalendar_
-
jdbcTypes_
public int[] jdbcTypes_
-
columns_
public int columns_
-
nullable_
public boolean[] nullable_
-
charset_
public java.nio.charset.Charset[] charset_
-
isNull_
public boolean[] isNull_
-
fdocaLength_
public int[] fdocaLength_
-
ccsid_
public int[] ccsid_
-
charBuffer_
private char[] charBuffer_
-
-
Constructor Detail
-
Cursor
public Cursor(Agent agent)
-
-
Method Detail
-
setNumberOfColumns
public void setNumberOfColumns(int numberOfColumns)
-
stepNext
protected boolean stepNext(boolean allowServerFetch) throws SqlExceptionMakes the next row the current row. Returns true if the current row position is a valid row position.- Parameters:
allowServerFetch- if false, don't fetch more data from the server even if more data is needed- Returns:
trueif current row position is valid- Throws:
SqlException- if an error occurs
-
next
public boolean next() throws SqlExceptionMakes the next row the current row. Returns true if the current row position is a valid row position.- Returns:
trueif current row position is valid- Throws:
SqlException- if an error occurs
-
setAllRowsReceivedFromServer
public void setAllRowsReceivedFromServer(boolean b)
Set the value of value of allRowsReceivedFromServer_.- Parameters:
b- abooleanvalue indicating whether all rows are received from the server
-
allRowsReceivedFromServer
public final boolean allRowsReceivedFromServer()
Returntrueif all rows are received from the server.- Returns:
trueif all rows are received from the server.
-
currentRowPositionIsEqualToNextRowPosition
final boolean currentRowPositionIsEqualToNextRowPosition()
-
resetDataBuffer
public final void resetDataBuffer()
-
dataBufferHasUnprocessedData
final boolean dataBufferHasUnprocessedData()
-
calculateColumnOffsetsForRow_
protected abstract boolean calculateColumnOffsetsForRow_(int row, boolean allowServerFetch) throws SqlException, DisconnectExceptionCalculate the column offsets for a row.- Parameters:
row- row indexallowServerFetch- if true, allow fetching more data from server- Returns:
trueif the current row position is a valid row position.- Throws:
SqlExceptionDisconnectException
-
clearLobData_
protected abstract void clearLobData_()
-
getMoreData_
protected abstract void getMoreData_() throws SqlException- Throws:
SqlException
-
setIsUpdataDeleteHole
public final void setIsUpdataDeleteHole(int row, boolean isRowNull)
-
setIsRowUpdated
public final void setIsRowUpdated(boolean isRowUpdated)
Keep track of updated status for this row.- Parameters:
isRowUpdated- true if row has been updated- See Also:
getIsRowUpdated()
-
getIsRowUpdated
public final boolean getIsRowUpdated()
Get updated status for this row. Minion of ResultSet#rowUpdated.- See Also:
setIsRowUpdated(boolean)
-
getIsUpdateDeleteHole
public final boolean getIsUpdateDeleteHole()
Get deleted status for this row. Minion of ResultSet#rowDeleted.- See Also:
setIsUpdataDeleteHole(int, boolean)
-
markNextRowPosition
protected final void markNextRowPosition()
-
makeNextRowPositionCurrent
protected final void makeNextRowPositionCurrent()
-
incrementRowsReadEvent
public final void incrementRowsReadEvent()
-
get_BOOLEAN
private boolean get_BOOLEAN(int column)
-
get_SMALLINT
private final short get_SMALLINT(int column)
-
get_INTEGER
protected final int get_INTEGER(int column)
-
get_BIGINT
private final long get_BIGINT(int column)
-
get_FLOAT
private final float get_FLOAT(int column)
-
get_DOUBLE
private final double get_DOUBLE(int column)
-
get_DECIMAL
private final java.math.BigDecimal get_DECIMAL(int column) throws SqlException- Throws:
SqlException
-
getDoubleFromDECIMAL
private double getDoubleFromDECIMAL(int column) throws SqlException- Throws:
SqlException
-
getLongFromDECIMAL
private long getLongFromDECIMAL(int column, java.lang.String targetType) throws SqlException- Throws:
SqlException
-
getVARCHAR
private java.lang.String getVARCHAR(int column) throws SqlException- Throws:
SqlException
-
getCHAR
private java.lang.String getCHAR(int column) throws SqlException- Throws:
SqlException
-
getDATE
private java.sql.Date getDATE(int column, java.util.Calendar cal) throws SqlException- Throws:
SqlException
-
getTIME
private java.sql.Time getTIME(int column, java.util.Calendar cal) throws SqlException- Throws:
SqlException
-
getTIMESTAMP
private final java.sql.Timestamp getTIMESTAMP(int column, java.util.Calendar cal) throws SqlException- Throws:
SqlException
-
getTimestampFromDATE
private final java.sql.Timestamp getTimestampFromDATE(int column, java.util.Calendar cal) throws SqlException- Throws:
SqlException
-
getTimestampFromTIME
private final java.sql.Timestamp getTimestampFromTIME(int column, java.util.Calendar cal) throws SqlException- Throws:
SqlException
-
getDateFromTIMESTAMP
private final java.sql.Date getDateFromTIMESTAMP(int column, java.util.Calendar cal) throws SqlException- Throws:
SqlException
-
getTimeFromTIMESTAMP
private final java.sql.Time getTimeFromTIMESTAMP(int column, java.util.Calendar cal) throws SqlException- Throws:
SqlException
-
getStringFromDATE
private java.lang.String getStringFromDATE(int column) throws SqlException- Throws:
SqlException
-
getStringFromTIME
private java.lang.String getStringFromTIME(int column) throws SqlException- Throws:
SqlException
-
getStringFromTIMESTAMP
private java.lang.String getStringFromTIMESTAMP(int column) throws SqlException- Throws:
SqlException
-
get_CHAR_FOR_BIT_DATA
private byte[] get_CHAR_FOR_BIT_DATA(int column) throws SqlException- Throws:
SqlException
-
get_VARCHAR_FOR_BIT_DATA
private byte[] get_VARCHAR_FOR_BIT_DATA(int column) throws SqlException- Throws:
SqlException
-
get_UDT
private java.lang.Object get_UDT(int column) throws SqlException- Throws:
SqlException
-
getRecyclableCalendar
private java.util.Calendar getRecyclableCalendar()
Instantiate an instance of Calendar that can be re-used for getting Time, Timestamp, and Date values from this cursor. Assumption is that all users of the returned Calendar object will clear it as appropriate before using it.
-
getLocatorProcedures
CallableLocatorProcedures getLocatorProcedures()
Returns a reference to the locator procedures.These procedures are used to operate on large objects referenced on the server by locators.
- Returns:
- The locator procedures object.
-
locator
protected abstract int locator(int column)
Returns the locator for the specified LOB column, orLob.INVALID_LOCATORif the LOB was not sent as a locator. The server may send the LOB value instead of a locator if it is running an old version which doesn't support locators, or if the database it accesses is soft upgraded from a version that doesn't have the necessary stored procedures for locator support.Note that this method cannot be invoked on a LOB column that is NULL.
- Parameters:
column- 1-based column index- Returns:
- A positive integer locator if valid,
Lob.INVALID_LOCATORotherwise.
-
getBlobColumn_
public abstract ClientBlob getBlobColumn_(int column, Agent agent, boolean toBePublished) throws SqlException
Returns aBlobobject.- Parameters:
column- 1-based column indexagent- associated agenttoBePublished- whether the Blob will be published to the user- Returns:
- A Blob object.
- Throws:
SqlException- if getting theBlobfails
-
getClobColumn_
public abstract ClientClob getClobColumn_(int column, Agent agent, boolean toBePublished) throws SqlException
Returns aClobobject.- Parameters:
column- 1-based column indexagent- associated agenttoBePublished- whether the Clob will be published to the user- Returns:
- A
java.sql.Clobobject. - Throws:
SqlException- if getting theClobfails
-
getBoolean
final boolean getBoolean(int column) throws SqlException- Throws:
SqlException
-
getByte
final byte getByte(int column) throws SqlException- Throws:
SqlException
-
getShort
final short getShort(int column) throws SqlException- Throws:
SqlException
-
getInt
final int getInt(int column) throws SqlException- Throws:
SqlException
-
getLong
final long getLong(int column) throws SqlException- Throws:
SqlException
-
getFloat
final float getFloat(int column) throws SqlException- Throws:
SqlException
-
getDouble
final double getDouble(int column) throws SqlException- Throws:
SqlException
-
getBigDecimal
final java.math.BigDecimal getBigDecimal(int column) throws SqlException- Throws:
SqlException
-
getDate
final java.sql.Date getDate(int column, java.util.Calendar cal) throws SqlException- Throws:
SqlException
-
getTime
final java.sql.Time getTime(int column, java.util.Calendar cal) throws SqlException- Throws:
SqlException
-
getTimestamp
final java.sql.Timestamp getTimestamp(int column, java.util.Calendar cal) throws SqlException- Throws:
SqlException
-
getString
final java.lang.String getString(int column) throws SqlException- Throws:
SqlException
-
getBytes
final byte[] getBytes(int column) throws SqlException- Throws:
SqlException
-
getBinaryStream
final java.io.InputStream getBinaryStream(int column) throws SqlException- Throws:
SqlException
-
getAsciiStream
final java.io.InputStream getAsciiStream(int column) throws SqlException- Throws:
SqlException
-
getCharacterStream
final java.io.Reader getCharacterStream(int column) throws SqlException- Throws:
SqlException
-
getBlob
final java.sql.Blob getBlob(int column) throws SqlException- Throws:
SqlException
-
getClob
final java.sql.Clob getClob(int column) throws SqlException- Throws:
SqlException
-
getArray
final java.sql.Array getArray(int column) throws SqlException- Throws:
SqlException
-
getRef
final java.sql.Ref getRef(int column) throws SqlException- Throws:
SqlException
-
getObject
final java.lang.Object getObject(int column) throws SqlException- Throws:
SqlException
-
allocateCharBuffer
public final void allocateCharBuffer()
-
getStringWithoutConvert
private java.lang.String getStringWithoutConvert(int position, int actualLength)
-
coercionError
private ColumnTypeConversionException coercionError(java.lang.String targetType, int sourceColumn)
-
nullDataForGC
public void nullDataForGC()
-
getColumnPrecision
private int getColumnPrecision(int column)
-
getColumnScale
private int getColumnScale(int column)
-
-