Methods Summary |
---|
public boolean | allocRow()Allocates a new row at the end of this cursor window.
acquireReference();
try {
return nativeAllocRow(mWindowPtr);
} finally {
releaseReference();
}
|
public void | clear()Clears out the existing contents of the window, making it safe to reuse
for new data.
The start position ({@link #getStartPosition()}), number of rows ({@link #getNumRows()}),
and number of columns in the cursor are all reset to zero.
acquireReference();
try {
mStartPos = 0;
nativeClear(mWindowPtr);
} finally {
releaseReference();
}
|
public void | copyStringToBuffer(int row, int column, CharArrayBuffer buffer)Copies the text of the field at the specified row and column index into
a {@link CharArrayBuffer}.
The buffer is populated as follows:
- If the buffer is too small for the value to be copied, then it is
automatically resized.
- If the field is of type {@link Cursor#FIELD_TYPE_NULL}, then the buffer
is set to an empty string.
- If the field is of type {@link Cursor#FIELD_TYPE_STRING}, then the buffer
is set to the contents of the string.
- If the field is of type {@link Cursor#FIELD_TYPE_INTEGER}, then the buffer
is set to a string representation of the integer in decimal, obtained by formatting the
value with the
printf family of functions using
format specifier %lld .
- If the field is of type {@link Cursor#FIELD_TYPE_FLOAT}, then the buffer is
set to a string representation of the floating-point value in decimal, obtained by
formatting the value with the
printf family of functions using
format specifier %g .
- If the field is of type {@link Cursor#FIELD_TYPE_BLOB}, then a
{@link SQLiteException} is thrown.
if (buffer == null) {
throw new IllegalArgumentException("CharArrayBuffer should not be null");
}
acquireReference();
try {
nativeCopyStringToBuffer(mWindowPtr, row - mStartPos, column, buffer);
} finally {
releaseReference();
}
|
public int | describeContents()
return 0;
|
private void | dispose()
if (mCloseGuard != null) {
mCloseGuard.close();
}
if (mWindowPtr != 0) {
recordClosingOfWindow(mWindowPtr);
nativeDispose(mWindowPtr);
mWindowPtr = 0;
}
|
protected void | finalize()
try {
if (mCloseGuard != null) {
mCloseGuard.warnIfOpen();
}
dispose();
} finally {
super.finalize();
}
|
public void | freeLastRow()Frees the last row in this cursor window.
acquireReference();
try {
nativeFreeLastRow(mWindowPtr);
} finally {
releaseReference();
}
|
public byte[] | getBlob(int row, int column)Gets the value of the field at the specified row and column index as a byte array.
The result is determined as follows:
- If the field is of type {@link Cursor#FIELD_TYPE_NULL}, then the result
is
null .
- If the field is of type {@link Cursor#FIELD_TYPE_BLOB}, then the result
is the blob value.
- If the field is of type {@link Cursor#FIELD_TYPE_STRING}, then the result
is the array of bytes that make up the internal representation of the
string value.
- If the field is of type {@link Cursor#FIELD_TYPE_INTEGER} or
{@link Cursor#FIELD_TYPE_FLOAT}, then a {@link SQLiteException} is thrown.
acquireReference();
try {
return nativeGetBlob(mWindowPtr, row - mStartPos, column);
} finally {
releaseReference();
}
|
public double | getDouble(int row, int column)Gets the value of the field at the specified row and column index as a
double .
The result is determined as follows:
- If the field is of type {@link Cursor#FIELD_TYPE_NULL}, then the result
is
0.0 .
- If the field is of type {@link Cursor#FIELD_TYPE_STRING}, then the result
is the value obtained by parsing the string value with
strtod .
- If the field is of type {@link Cursor#FIELD_TYPE_INTEGER}, then the result
is the integer value converted to a
double .
- If the field is of type {@link Cursor#FIELD_TYPE_FLOAT}, then the result
is the
double value.
- If the field is of type {@link Cursor#FIELD_TYPE_BLOB}, then a
{@link SQLiteException} is thrown.
acquireReference();
try {
return nativeGetDouble(mWindowPtr, row - mStartPos, column);
} finally {
releaseReference();
}
|
public float | getFloat(int row, int column)Gets the value of the field at the specified row and column index as a
float .
The result is determined by invoking {@link #getDouble} and converting the
result to float .
return (float) getDouble(row, column);
|
public int | getInt(int row, int column)Gets the value of the field at the specified row and column index as an
int .
The result is determined by invoking {@link #getLong} and converting the
result to int .
return (int) getLong(row, column);
|
public long | getLong(int row, int column)Gets the value of the field at the specified row and column index as a long .
The result is determined as follows:
- If the field is of type {@link Cursor#FIELD_TYPE_NULL}, then the result
is
0L .
- If the field is of type {@link Cursor#FIELD_TYPE_STRING}, then the result
is the value obtained by parsing the string value with
strtoll .
- If the field is of type {@link Cursor#FIELD_TYPE_INTEGER}, then the result
is the
long value.
- If the field is of type {@link Cursor#FIELD_TYPE_FLOAT}, then the result
is the floating-point value converted to a
long .
- If the field is of type {@link Cursor#FIELD_TYPE_BLOB}, then a
{@link SQLiteException} is thrown.
acquireReference();
try {
return nativeGetLong(mWindowPtr, row - mStartPos, column);
} finally {
releaseReference();
}
|
public java.lang.String | getName()Gets the name of this cursor window, never null.
return mName;
|
public int | getNumRows()Gets the number of rows in this window.
acquireReference();
try {
return nativeGetNumRows(mWindowPtr);
} finally {
releaseReference();
}
|
public short | getShort(int row, int column)Gets the value of the field at the specified row and column index as a
short .
The result is determined by invoking {@link #getLong} and converting the
result to short .
return (short) getLong(row, column);
|
public int | getStartPosition()Gets the start position of this cursor window.
The start position is the zero-based index of the first row that this window contains
relative to the entire result set of the {@link Cursor}.
return mStartPos;
|
public java.lang.String | getString(int row, int column)Gets the value of the field at the specified row and column index as a string.
The result is determined as follows:
- If the field is of type {@link Cursor#FIELD_TYPE_NULL}, then the result
is
null .
- If the field is of type {@link Cursor#FIELD_TYPE_STRING}, then the result
is the string value.
- If the field is of type {@link Cursor#FIELD_TYPE_INTEGER}, then the result
is a string representation of the integer in decimal, obtained by formatting the
value with the
printf family of functions using
format specifier %lld .
- If the field is of type {@link Cursor#FIELD_TYPE_FLOAT}, then the result
is a string representation of the floating-point value in decimal, obtained by
formatting the value with the
printf family of functions using
format specifier %g .
- If the field is of type {@link Cursor#FIELD_TYPE_BLOB}, then a
{@link SQLiteException} is thrown.
acquireReference();
try {
return nativeGetString(mWindowPtr, row - mStartPos, column);
} finally {
releaseReference();
}
|
public int | getType(int row, int column)Returns the type of the field at the specified row and column index.
The returned field types are:
- {@link Cursor#FIELD_TYPE_NULL}
- {@link Cursor#FIELD_TYPE_INTEGER}
- {@link Cursor#FIELD_TYPE_FLOAT}
- {@link Cursor#FIELD_TYPE_STRING}
- {@link Cursor#FIELD_TYPE_BLOB}
acquireReference();
try {
return nativeGetType(mWindowPtr, row - mStartPos, column);
} finally {
releaseReference();
}
|
public boolean | isBlob(int row, int column)Returns true if the field at the specified row and column index
has type {@link Cursor#FIELD_TYPE_BLOB} or {@link Cursor#FIELD_TYPE_NULL}.
int type = getType(row, column);
return type == Cursor.FIELD_TYPE_BLOB || type == Cursor.FIELD_TYPE_NULL;
|
public boolean | isFloat(int row, int column)Returns true if the field at the specified row and column index
has type {@link Cursor#FIELD_TYPE_FLOAT}.
return getType(row, column) == Cursor.FIELD_TYPE_FLOAT;
|
public boolean | isLong(int row, int column)Returns true if the field at the specified row and column index
has type {@link Cursor#FIELD_TYPE_INTEGER}.
return getType(row, column) == Cursor.FIELD_TYPE_INTEGER;
|
public boolean | isNull(int row, int column)Returns true if the field at the specified row and column index
has type {@link Cursor#FIELD_TYPE_NULL}.
return getType(row, column) == Cursor.FIELD_TYPE_NULL;
|
public boolean | isString(int row, int column)Returns true if the field at the specified row and column index
has type {@link Cursor#FIELD_TYPE_STRING} or {@link Cursor#FIELD_TYPE_NULL}.
int type = getType(row, column);
return type == Cursor.FIELD_TYPE_STRING || type == Cursor.FIELD_TYPE_NULL;
|
private static native boolean | nativeAllocRow(long windowPtr)
|
private static native void | nativeClear(long windowPtr)
|
private static native void | nativeCopyStringToBuffer(long windowPtr, int row, int column, CharArrayBuffer buffer)
|
private static native long | nativeCreate(java.lang.String name, int cursorWindowSize)
|
private static native long | nativeCreateFromParcel(android.os.Parcel parcel)
|
private static native void | nativeDispose(long windowPtr)
|
private static native void | nativeFreeLastRow(long windowPtr)
|
private static native byte[] | nativeGetBlob(long windowPtr, int row, int column)
|
private static native double | nativeGetDouble(long windowPtr, int row, int column)
|
private static native long | nativeGetLong(long windowPtr, int row, int column)
|
private static native java.lang.String | nativeGetName(long windowPtr)
|
private static native int | nativeGetNumRows(long windowPtr)
|
private static native java.lang.String | nativeGetString(long windowPtr, int row, int column)
|
private static native int | nativeGetType(long windowPtr, int row, int column)
|
private static native boolean | nativePutBlob(long windowPtr, byte[] value, int row, int column)
|
private static native boolean | nativePutDouble(long windowPtr, double value, int row, int column)
|
private static native boolean | nativePutLong(long windowPtr, long value, int row, int column)
|
private static native boolean | nativePutNull(long windowPtr, int row, int column)
|
private static native boolean | nativePutString(long windowPtr, java.lang.String value, int row, int column)
|
private static native boolean | nativeSetNumColumns(long windowPtr, int columnNum)
|
private static native void | nativeWriteToParcel(long windowPtr, android.os.Parcel parcel)
|
public static android.database.CursorWindow | newFromParcel(android.os.Parcel p)
return CREATOR.createFromParcel(p);
|
protected void | onAllReferencesReleased()
dispose();
|
private java.lang.String | printStats()
StringBuilder buff = new StringBuilder();
int myPid = Process.myPid();
int total = 0;
SparseIntArray pidCounts = new SparseIntArray();
synchronized (sWindowToPidMap) {
int size = sWindowToPidMap.size();
if (size == 0) {
// this means we are not in the ContentProvider.
return "";
}
for (int indx = 0; indx < size; indx++) {
int pid = sWindowToPidMap.valueAt(indx);
int value = pidCounts.get(pid);
pidCounts.put(pid, ++value);
}
}
int numPids = pidCounts.size();
for (int i = 0; i < numPids;i++) {
buff.append(" (# cursors opened by ");
int pid = pidCounts.keyAt(i);
if (pid == myPid) {
buff.append("this proc=");
} else {
buff.append("pid " + pid + "=");
}
int num = pidCounts.get(pid);
buff.append(num + ")");
total += num;
}
// limit the returned string size to 1000
String s = (buff.length() > 980) ? buff.substring(0, 980) : buff.toString();
return "# Open Cursors=" + total + s;
|
public boolean | putBlob(byte[] value, int row, int column)Copies a byte array into the field at the specified row and column index.
acquireReference();
try {
return nativePutBlob(mWindowPtr, value, row - mStartPos, column);
} finally {
releaseReference();
}
|
public boolean | putDouble(double value, int row, int column)Puts a double-precision floating point value into the field at the
specified row and column index.
acquireReference();
try {
return nativePutDouble(mWindowPtr, value, row - mStartPos, column);
} finally {
releaseReference();
}
|
public boolean | putLong(long value, int row, int column)Puts a long integer into the field at the specified row and column index.
acquireReference();
try {
return nativePutLong(mWindowPtr, value, row - mStartPos, column);
} finally {
releaseReference();
}
|
public boolean | putNull(int row, int column)Puts a null value into the field at the specified row and column index.
acquireReference();
try {
return nativePutNull(mWindowPtr, row - mStartPos, column);
} finally {
releaseReference();
}
|
public boolean | putString(java.lang.String value, int row, int column)Copies a string into the field at the specified row and column index.
acquireReference();
try {
return nativePutString(mWindowPtr, value, row - mStartPos, column);
} finally {
releaseReference();
}
|
private void | recordClosingOfWindow(long window)
synchronized (sWindowToPidMap) {
if (sWindowToPidMap.size() == 0) {
// this means we are not in the ContentProvider.
return;
}
sWindowToPidMap.delete(window);
}
|
private void | recordNewWindow(int pid, long window)
synchronized (sWindowToPidMap) {
sWindowToPidMap.put(window, pid);
if (Log.isLoggable(STATS_TAG, Log.VERBOSE)) {
Log.i(STATS_TAG, "Created a new Cursor. " + printStats());
}
}
|
public boolean | setNumColumns(int columnNum)Sets the number of columns in this window.
This method must be called before any rows are added to the window, otherwise
it will fail to set the number of columns if it differs from the current number
of columns.
acquireReference();
try {
return nativeSetNumColumns(mWindowPtr, columnNum);
} finally {
releaseReference();
}
|
public void | setStartPosition(int pos)Sets the start position of this cursor window.
The start position is the zero-based index of the first row that this window contains
relative to the entire result set of the {@link Cursor}.
mStartPos = pos;
|
public java.lang.String | toString()
return getName() + " {" + Long.toHexString(mWindowPtr) + "}";
|
public void | writeToParcel(android.os.Parcel dest, int flags)
acquireReference();
try {
dest.writeInt(mStartPos);
nativeWriteToParcel(mWindowPtr, dest);
} finally {
releaseReference();
}
if ((flags & Parcelable.PARCELABLE_WRITE_RETURN_VALUE) != 0) {
releaseReference();
}
|