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 Agent
agent_
private boolean
allRowsReceivedFromServer_
static int
BYTES
int[]
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_
int
columns_
protected int
currentRowPosition_
byte[]
dataBuffer_
java.io.ByteArrayOutputStream
dataBufferStream_
int[]
fdocaLength_
boolean
hasLobs_
boolean[]
isNull_
(package private) static java.nio.charset.Charset
ISO_8859_1
private boolean
isRowUpdated_
(package private) boolean
isUpdateDeleteHole_
(package private) java.util.ArrayList<java.lang.Boolean>
isUpdateDeleteHoleCache_
int[]
jdbcTypes_
int
lastValidBytePosition_
(package private) int
maxFieldSize_
private int
nextRowPosition_
static int
NULL_TERMINATED_BYTES
static int
NULL_TERMINATED_STRING
boolean[]
nullable_
int
position_
private java.util.Calendar
recyclableCalendar_
private static java.lang.Boolean
ROW_IS_NOT_NULL
(package private) static java.lang.Boolean
ROW_IS_NULL
(package private) long
rowsRead_
static int
STRING
(package private) static java.nio.charset.Charset
UTF_16BE
(package private) static java.nio.charset.Charset
UTF_8
static int
VARIABLE_SHORT_STRING
static int
VARIABLE_STRING
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
allocateCharBuffer()
boolean
allRowsReceivedFromServer()
Returntrue
if all rows are received from the server.protected abstract boolean
calculateColumnOffsetsForRow_(int row, boolean allowServerFetch)
Calculate the column offsets for a row.protected abstract void
clearLobData_()
private ColumnTypeConversionException
coercionError(java.lang.String targetType, int sourceColumn)
(package private) boolean
currentRowPositionIsEqualToNextRowPosition()
(package private) boolean
dataBufferHasUnprocessedData()
private long
get_BIGINT(int column)
private boolean
get_BOOLEAN(int column)
private byte[]
get_CHAR_FOR_BIT_DATA(int column)
private java.math.BigDecimal
get_DECIMAL(int column)
private double
get_DOUBLE(int column)
private float
get_FLOAT(int column)
protected int
get_INTEGER(int column)
private short
get_SMALLINT(int column)
private java.lang.Object
get_UDT(int column)
private byte[]
get_VARCHAR_FOR_BIT_DATA(int column)
(package private) java.sql.Array
getArray(int column)
(package private) java.io.InputStream
getAsciiStream(int column)
(package private) java.math.BigDecimal
getBigDecimal(int column)
(package private) java.io.InputStream
getBinaryStream(int column)
(package private) java.sql.Blob
getBlob(int column)
abstract ClientBlob
getBlobColumn_(int column, Agent agent, boolean toBePublished)
Returns aBlob
object.(package private) boolean
getBoolean(int column)
(package private) byte
getByte(int column)
(package private) byte[]
getBytes(int column)
private java.lang.String
getCHAR(int column)
(package private) java.io.Reader
getCharacterStream(int column)
(package private) java.sql.Clob
getClob(int column)
abstract ClientClob
getClobColumn_(int column, Agent agent, boolean toBePublished)
Returns aClob
object.private int
getColumnPrecision(int column)
private int
getColumnScale(int column)
(package private) java.sql.Date
getDate(int column, java.util.Calendar cal)
private java.sql.Date
getDATE(int column, java.util.Calendar cal)
private java.sql.Date
getDateFromTIMESTAMP(int column, java.util.Calendar cal)
(package private) double
getDouble(int column)
private double
getDoubleFromDECIMAL(int column)
(package private) float
getFloat(int column)
(package private) int
getInt(int column)
boolean
getIsRowUpdated()
Get updated status for this row.boolean
getIsUpdateDeleteHole()
Get deleted status for this row.(package private) CallableLocatorProcedures
getLocatorProcedures()
Returns a reference to the locator procedures.(package private) long
getLong(int column)
private long
getLongFromDECIMAL(int column, java.lang.String targetType)
protected abstract void
getMoreData_()
(package private) java.lang.Object
getObject(int column)
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.(package private) java.sql.Ref
getRef(int column)
(package private) short
getShort(int column)
(package private) java.lang.String
getString(int column)
private java.lang.String
getStringFromDATE(int column)
private java.lang.String
getStringFromTIME(int column)
private java.lang.String
getStringFromTIMESTAMP(int column)
private java.lang.String
getStringWithoutConvert(int position, int actualLength)
(package private) java.sql.Time
getTime(int column, java.util.Calendar cal)
private java.sql.Time
getTIME(int column, java.util.Calendar cal)
private java.sql.Time
getTimeFromTIMESTAMP(int column, java.util.Calendar cal)
(package private) java.sql.Timestamp
getTimestamp(int column, java.util.Calendar cal)
private java.sql.Timestamp
getTIMESTAMP(int column, java.util.Calendar cal)
private java.sql.Timestamp
getTimestampFromDATE(int column, java.util.Calendar cal)
private java.sql.Timestamp
getTimestampFromTIME(int column, java.util.Calendar cal)
private java.lang.String
getVARCHAR(int column)
void
incrementRowsReadEvent()
protected abstract int
locator(int column)
Returns the locator for the specified LOB column, orLob.INVALID_LOCATOR
if the LOB was not sent as a locator.protected void
makeNextRowPositionCurrent()
protected void
markNextRowPosition()
boolean
next()
Makes the next row the current row.void
nullDataForGC()
void
resetDataBuffer()
void
setAllRowsReceivedFromServer(boolean b)
Set the value of value of allRowsReceivedFromServer_.void
setIsRowUpdated(boolean isRowUpdated)
Keep track of updated status for this row.void
setIsUpdataDeleteHole(int row, boolean isRowNull)
void
setNumberOfColumns(int numberOfColumns)
protected boolean
stepNext(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 SqlException
Makes 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:
true
if current row position is valid- Throws:
SqlException
- if an error occurs
-
next
public boolean next() throws SqlException
Makes the next row the current row. Returns true if the current row position is a valid row position.- Returns:
true
if 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
- aboolean
value indicating whether all rows are received from the server
-
allRowsReceivedFromServer
public final boolean allRowsReceivedFromServer()
Returntrue
if all rows are received from the server.- Returns:
true
if 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, DisconnectException
Calculate the column offsets for a row.- Parameters:
row
- row indexallowServerFetch
- if true, allow fetching more data from server- Returns:
true
if the current row position is a valid row position.- Throws:
SqlException
DisconnectException
-
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_LOCATOR
if 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_LOCATOR
otherwise.
-
getBlobColumn_
public abstract ClientBlob getBlobColumn_(int column, Agent agent, boolean toBePublished) throws SqlException
Returns aBlob
object.- 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 theBlob
fails
-
getClobColumn_
public abstract ClientClob getClobColumn_(int column, Agent agent, boolean toBePublished) throws SqlException
Returns aClob
object.- Parameters:
column
- 1-based column indexagent
- associated agenttoBePublished
- whether the Clob will be published to the user- Returns:
- A
java.sql.Clob
object. - Throws:
SqlException
- if getting theClob
fails
-
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)
-
-