public abstract class AbstractWindowedCursor extends AbstractCursor
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 policy 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.
AbstractCursor.SelfContentObserver
Modifier and Type | Field and Description |
---|---|
protected CursorWindow |
mWindow
The cursor window owned by this cursor.
|
mClosed, mContentResolver, mCurrentRowID, mPos, mRowIdColumnIndex, mUpdatedRows
FIELD_TYPE_BLOB, FIELD_TYPE_FLOAT, FIELD_TYPE_INTEGER, FIELD_TYPE_NULL, FIELD_TYPE_STRING
Constructor and Description |
---|
AbstractWindowedCursor() |
Modifier and Type | Method and Description |
---|---|
protected void |
checkPosition()
This function throws CursorIndexOutOfBoundsException if
the cursor position is out of bounds.
|
protected void |
clearOrCreateWindow(String name)
If there is a window, clear it.
|
protected void |
closeWindow()
Closes the cursor window and sets
mWindow to null. |
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
CursorWindow , returns a pre-filled
window with the contents of the cursor, otherwise null. |
boolean |
hasWindow()
Returns true if the cursor has an associated cursor window.
|
boolean |
isBlob(int columnIndex)
Deprecated.
Use
getType(int) |
boolean |
isFloat(int columnIndex)
Deprecated.
Use
getType(int) |
boolean |
isLong(int columnIndex)
Deprecated.
Use
getType(int) |
boolean |
isNull(int columnIndex)
Returns
true if the value in the indicated column is null. |
boolean |
isString(int columnIndex)
Deprecated.
Use
getType(int) |
protected void |
onDeactivateOrClose() |
void |
setWindow(CursorWindow window)
Sets a new cursor window for the cursor to use.
|
close, deactivate, fillWindow, finalize, getColumnCount, getColumnIndex, getColumnIndexOrThrow, getColumnName, getColumnNames, getCount, getExtras, getNotificationUri, getPosition, getUpdatedField, getWantsAllOnMoveCalls, isAfterLast, isBeforeFirst, isClosed, isFieldUpdated, isFirst, isLast, move, moveToFirst, moveToLast, moveToNext, moveToPosition, moveToPrevious, onChange, onMove, registerContentObserver, registerDataSetObserver, requery, respond, setExtras, setNotificationUri, setNotificationUri, unregisterContentObserver, unregisterDataSetObserver
protected CursorWindow mWindow
public byte[] getBlob(int columnIndex)
Cursor
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.
getBlob
in interface Cursor
getBlob
in class AbstractCursor
columnIndex
- the zero-based index of the target column.public String getString(int columnIndex)
Cursor
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.
getString
in interface Cursor
getString
in class AbstractCursor
columnIndex
- the zero-based index of the target column.public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer)
Cursor
copyStringToBuffer
in interface Cursor
copyStringToBuffer
in class AbstractCursor
columnIndex
- the zero-based index of the target column.
if the target column is null, return bufferbuffer
- the buffer to copy the text into.public short getShort(int columnIndex)
Cursor
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.
getShort
in interface Cursor
getShort
in class AbstractCursor
columnIndex
- the zero-based index of the target column.public int getInt(int columnIndex)
Cursor
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.
getInt
in interface Cursor
getInt
in class AbstractCursor
columnIndex
- the zero-based index of the target column.public long getLong(int columnIndex)
Cursor
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.
getLong
in interface Cursor
getLong
in class AbstractCursor
columnIndex
- the zero-based index of the target column.public float getFloat(int columnIndex)
Cursor
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.
getFloat
in interface Cursor
getFloat
in class AbstractCursor
columnIndex
- the zero-based index of the target column.public double getDouble(int columnIndex)
Cursor
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.
getDouble
in interface Cursor
getDouble
in class AbstractCursor
columnIndex
- the zero-based index of the target column.public boolean isNull(int columnIndex)
Cursor
true
if the value in the indicated column is null.isNull
in interface Cursor
isNull
in class AbstractCursor
columnIndex
- the zero-based index of the target column.@Deprecated public boolean isBlob(int columnIndex)
getType(int)
@Deprecated public boolean isString(int columnIndex)
getType(int)
@Deprecated public boolean isLong(int columnIndex)
getType(int)
@Deprecated public boolean isFloat(int columnIndex)
getType(int)
public int getType(int columnIndex)
Cursor
Cursor.getInt(int)
, Cursor.getFloat(int)
etc.
Returned column types are
getType
in interface Cursor
getType
in class AbstractCursor
columnIndex
- the zero-based index of the target column.protected void checkPosition()
AbstractCursor
checkPosition
in class AbstractCursor
public CursorWindow getWindow()
AbstractCursor
CursorWindow
, returns a pre-filled
window with the contents of the cursor, otherwise null.getWindow
in interface CrossProcessCursor
getWindow
in class AbstractCursor
public void setWindow(CursorWindow window)
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.
window
- The new cursor window, typically a remote cursor window.public boolean hasWindow()
protected void closeWindow()
mWindow
to null.protected void clearOrCreateWindow(String name)
name
- The window name.protected void onDeactivateOrClose()
onDeactivateOrClose
in class AbstractCursor