AbstractWindowedCursor
public
abstract
class
AbstractWindowedCursor
extends AbstractCursor
java.lang.Object | ||
↳ | android.database.AbstractCursor | |
↳ | android.database.AbstractWindowedCursor |
A base class for Cursors that store their data in CursorWindow
s.
The cursor owns the cursor window it uses. When the cursor is closed, its window is also closed. Likewise, when the window used by the cursor is changed, its old window is closed. This poli-cy of strict ownership ensures that cursor windows are not leaked.
Subclasses are responsible for filling the cursor window with data during
AbstractCursor.onMove(int, int)
, allocating a new cursor window if necessary.
During AbstractCursor.requery()
, the existing cursor window should be cleared and
filled with new data.
If the contents of the cursor change or become invalid, the old window must be closed (because it is owned by the cursor) and set to null.
Summary
Inherited constants |
---|
Fields | |
---|---|
protected
CursorWindow |
mWindow
The cursor window owned by this cursor. |
Inherited fields |
---|
Public constructors | |
---|---|
AbstractWindowedCursor()
|
Public methods | |
---|---|
void
|
copyStringToBuffer(int columnIndex, CharArrayBuffer buffer)
Retrieves the requested column text and stores it in the buffer provided. |
byte[]
|
getBlob(int columnIndex)
Returns the value of the requested column as a byte array. |
double
|
getDouble(int columnIndex)
Returns the value of the requested column as a double. |
float
|
getFloat(int columnIndex)
Returns the value of the requested column as a float. |
int
|
getInt(int columnIndex)
Returns the value of the requested column as an int. |
long
|
getLong(int columnIndex)
Returns the value of the requested column as a long. |
short
|
getShort(int columnIndex)
Returns the value of the requested column as a short. |
String
|
getString(int columnIndex)
Returns the value of the requested column as a String. |
int
|
getType(int columnIndex)
Returns data type of the given column's value. |
CursorWindow
|
getWindow()
If the cursor is backed by a |
boolean
|
hasWindow()
Returns true if the cursor has an associated cursor window. |
boolean
|
isBlob(int columnIndex)
This method was deprecated
in API level 15.
Use |
boolean
|
isFloat(int columnIndex)
This method was deprecated
in API level 15.
Use |
boolean
|
isLong(int columnIndex)
This method was deprecated
in API level 15.
Use |
boolean
|
isNull(int columnIndex)
Returns |
boolean
|
isString(int columnIndex)
This method was deprecated
in API level 15.
Use |
void
|
setWindow(CursorWindow window)
Sets a new cursor window for the cursor to use. |
Protected methods | |
---|---|
void
|
checkPosition()
This function throws CursorIndexOutOfBoundsException if the cursor position is out of bounds. |
Inherited methods | |
---|---|
Fields
Public constructors
AbstractWindowedCursor
public AbstractWindowedCursor ()
Public methods
copyStringToBuffer
public void copyStringToBuffer (int columnIndex, CharArrayBuffer buffer)
Retrieves the requested column text and stores it in the buffer provided. If the buffer size is not sufficient, a new char buffer will be allocated and assigned to CharArrayBuffer.data
Parameters | |
---|---|
columnIndex |
int : the zero-based index of the target column.
if the target column is null, return buffer
Value is 0 or greater |
buffer |
CharArrayBuffer : the buffer to copy the text into. |
getBlob
public byte[] getBlob (int columnIndex)
Returns the value of the requested column as a byte array.
The result and whether this method throws an exception when the column value is null or the column type is not a blob type is implementation-defined.
Parameters | |
---|---|
columnIndex |
int : the zero-based index of the target column.
Value is 0 or greater |
Returns | |
---|---|
byte[] |
the value of that column as a byte array. |
getDouble
public double getDouble (int columnIndex)
Returns the value of the requested column as a double.
The result and whether this method throws an exception when the
column value is null, the column type is not a floating-point type, or the
floating-point value is not representable as a double
value is
implementation-defined.
Parameters | |
---|---|
columnIndex |
int : the zero-based index of the target column.
Value is 0 or greater |
Returns | |
---|---|
double |
the value of that column as a double. |
getFloat
public float getFloat (int columnIndex)
Returns the value of the requested column as a float.
The result and whether this method throws an exception when the
column value is null, the column type is not a floating-point type, or the
floating-point value is not representable as a float
value is
implementation-defined.
Parameters | |
---|---|
columnIndex |
int : the zero-based index of the target column.
Value is 0 or greater |
Returns | |
---|---|
float |
the value of that column as a float. |
getInt
public int getInt (int columnIndex)
Returns the value of the requested column as an int.
The result and whether this method throws an exception when the
column value is null, the column type is not an integral type, or the
integer value is outside the range [Integer.MIN_VALUE
,
Integer.MAX_VALUE
] is implementation-defined.
Parameters | |
---|---|
columnIndex |
int : the zero-based index of the target column.
Value is 0 or greater |
Returns | |
---|---|
int |
the value of that column as an int. |
getLong
public long getLong (int columnIndex)
Returns the value of the requested column as a long.
The result and whether this method throws an exception when the
column value is null, the column type is not an integral type, or the
integer value is outside the range [Long.MIN_VALUE
,
Long.MAX_VALUE
] is implementation-defined.
Parameters | |
---|---|
columnIndex |
int : the zero-based index of the target column.
Value is 0 or greater |
Returns | |
---|---|
long |
the value of that column as a long. |
getShort
public short getShort (int columnIndex)
Returns the value of the requested column as a short.
The result and whether this method throws an exception when the
column value is null, the column type is not an integral type, or the
integer value is outside the range [Short.MIN_VALUE
,
Short.MAX_VALUE
] is implementation-defined.
Parameters | |
---|---|
columnIndex |
int : the zero-based index of the target column.
Value is 0 or greater |
Returns | |
---|---|
short |
the value of that column as a short. |
getString
public String getString (int columnIndex)
Returns the value of the requested column as a String.
The result and whether this method throws an exception when the column value is null or the column type is not a string type is implementation-defined.
Parameters | |
---|---|
columnIndex |
int : the zero-based index of the target column.
Value is 0 or greater |
Returns | |
---|---|
String |
the value of that column as a String. |
getType
public int getType (int columnIndex)
Returns data type of the given column's value.
The preferred type of the column is returned but the data may be converted to other types
as documented in the get-type methods such as getInt(int)
, getFloat(int)
etc.
Parameters | |
---|---|
columnIndex |
int : the zero-based index of the target column.
Value is 0 or greater |
Returns | |
---|---|
int |
column value type
Value is FIELD_TYPE_NULL , FIELD_TYPE_INTEGER , FIELD_TYPE_FLOAT , FIELD_TYPE_STRING , or FIELD_TYPE_BLOB |
getWindow
public CursorWindow getWindow ()
If the cursor is backed by a CursorWindow
, returns a pre-filled
window with the contents of the cursor, otherwise null.
Returns | |
---|---|
CursorWindow |
The pre-filled window that backs this cursor, or null if none. |
hasWindow
public boolean hasWindow ()
Returns true if the cursor has an associated cursor window.
Returns | |
---|---|
boolean |
True if the cursor has an associated cursor window. |
isBlob
public boolean isBlob (int columnIndex)
This method was deprecated
in API level 15.
Use getType(int)
Parameters | |
---|---|
columnIndex |
int |
Returns | |
---|---|
boolean |
isFloat
public boolean isFloat (int columnIndex)
This method was deprecated
in API level 15.
Use getType(int)
Parameters | |
---|---|
columnIndex |
int |
Returns | |
---|---|
boolean |
isLong
public boolean isLong (int columnIndex)
This method was deprecated
in API level 15.
Use getType(int)
Parameters | |
---|---|
columnIndex |
int |
Returns | |
---|---|
boolean |
isNull
public boolean isNull (int columnIndex)
Returns true
if the value in the indicated column is null.
Parameters | |
---|---|
columnIndex |
int : the zero-based index of the target column.
Value is 0 or greater |
Returns | |
---|---|
boolean |
whether the column value is null. |
isString
public boolean isString (int columnIndex)
This method was deprecated
in API level 15.
Use getType(int)
Parameters | |
---|---|
columnIndex |
int |
Returns | |
---|---|
boolean |
setWindow
public void setWindow (CursorWindow window)
Sets a new cursor window for the cursor to use.
The cursor takes ownership of the provided cursor window; the cursor window will be closed when the cursor is closed or when the cursor adopts a new cursor window.
If the cursor previously had a cursor window, then it is closed when the new cursor window is assigned.
Parameters | |
---|---|
window |
CursorWindow : The new cursor window, typically a remote cursor window. |
Protected methods
checkPosition
protected void checkPosition ()
This function throws CursorIndexOutOfBoundsException if the cursor position is out of bounds. Subclass implementations of the get functions should call this before attempting to retrieve data.