FileDocCategorySizeDatePackage
CursorWindow.javaAPI DocAndroid 1.5 API13603Wed May 06 22:41:54 BST 2009android.database

CursorWindow

public class CursorWindow extends android.database.sqlite.SQLiteClosable implements android.os.Parcelable
A buffer containing multiple cursor rows.

Fields Summary
private int
nWindow
The pointer to the native window class
private int
mStartPos
public static final Parcelable.Creator
CREATOR
Constructors Summary
public CursorWindow(boolean localWindow)
Creates a new empty window.

param
localWindow true if this window will be used in this process only

        mStartPos = 0;
        native_init(localWindow);
    
private CursorWindow(android.os.Parcel source)

        IBinder nativeBinder = source.readStrongBinder();
        mStartPos = source.readInt();

        native_init(nativeBinder);
    
Methods Summary
public booleanallocRow()
Allocate a row in cursor window

return
false if cursor window is out of memory

        acquireReference();
        try {
            return allocRow_native();
        } finally {
            releaseReference();
        }
    
private native booleanallocRow_native()

public voidclear()
Clears out the existing contents of the window, making it safe to reuse for new data. Note that the number of columns in the window may NOT change across a call to clear().

        acquireReference();
        try {
            mStartPos = 0;        
            native_clear();
        } finally {
            releaseReference();
        }
    
public voidclose()
Cleans up the native resources associated with the window.

        releaseReference();
    
private native voidclose_native()

public voidcopyStringToBuffer(int row, int col, CharArrayBuffer buffer)
copy the text for the given field in the provided char array.

param
row the row to read from, row - getStartPosition() being the actual row in the window
param
col the column to read from
param
buffer the CharArrayBuffer to copy the text into, If the requested string is larger than the buffer a new char buffer will be created to hold the string. and assigne to CharArrayBuffer.data

        if (buffer == null) {
            throw new IllegalArgumentException("CharArrayBuffer should not be null");
        }
        if (buffer.data == null) {
            buffer.data = new char[64];
        }
        acquireReference();
        try {
            char[] newbuf = copyStringToBuffer_native(
                    row - mStartPos, col, buffer.data.length, buffer);
            if (newbuf != null) {
                buffer.data = newbuf;
            }
        } finally {
            releaseReference();
        }
    
private native char[]copyStringToBuffer_native(int row, int col, int bufferSize, CharArrayBuffer buffer)

public intdescribeContents()

        return 0;
    
protected voidfinalize()

        // Just in case someone forgot to call close...
        close_native();
    
public voidfreeLastRow()
Free the last row

        acquireReference();
        try {
            freeLastRow_native();
        } finally {
            releaseReference();
        }
    
private native voidfreeLastRow_native()

public byte[]getBlob(int row, int col)
Returns a byte array for the given field.

param
row the row to read from, row - getStartPosition() being the actual row in the window
param
col the column to read from
return
a String value for the given field

        acquireReference();
        try {
            return getBlob_native(row - mStartPos, col);
        } finally {
            releaseReference();
        }
    
private native byte[]getBlob_native(int row, int col)

public doublegetDouble(int row, int col)
Returns a double for the given field. row is 0 based

param
row the row to read from, row - getStartPosition() being the actual row in the window
param
col the column to read from
return
a double value for the given field

        acquireReference();
        try {
            return getDouble_native(row - mStartPos, col);
        } finally {
            releaseReference();
        }
    
private native doublegetDouble_native(int row, int col)

public floatgetFloat(int row, int col)
Returns a float for the given field. row is 0 based

param
row the row to read from, row - getStartPosition() being the actual row in the window
param
col the column to read from
return
a float value for the given field

        acquireReference();
        try {
            return (float) getDouble_native(row - mStartPos, col);
        } finally {
            releaseReference();
        }
    
public intgetInt(int row, int col)
Returns an int for the given field.

param
row the row to read from, row - getStartPosition() being the actual row in the window
param
col the column to read from
return
an int value for the given field

        acquireReference();
        try {
            return (int) getLong_native(row - mStartPos, col);
        } finally {
            releaseReference();
        }
    
public longgetLong(int row, int col)
Returns a long for the given field. row is 0 based

param
row the row to read from, row - getStartPosition() being the actual row in the window
param
col the column to read from
return
a long value for the given field

        acquireReference();
        try {
            return getLong_native(row - mStartPos, col);
        } finally {
            releaseReference();
        }
    
private native longgetLong_native(int row, int col)

public intgetNumRows()
Returns the number of rows in this window.

return
the number of rows in this window.

        acquireReference();
        try {
            return getNumRows_native();
        } finally {
            releaseReference();
        }
    
private native intgetNumRows_native()

public shortgetShort(int row, int col)
Returns a short for the given field. row is 0 based

param
row the row to read from, row - getStartPosition() being the actual row in the window
param
col the column to read from
return
a short value for the given field

        acquireReference();
        try {
            return (short) getLong_native(row - mStartPos, col);
        } finally {
            releaseReference();
        }
    
public intgetStartPosition()
Returns the starting position of this window within the entire Cursor's result set.

return
the starting position of this window within the entire Cursor's result set.

        return mStartPos;
    
public java.lang.StringgetString(int row, int col)
Returns a String for the given field.

param
row the row to read from, row - getStartPosition() being the actual row in the window
param
col the column to read from
return
a String value for the given field

        acquireReference();
        try {
            return getString_native(row - mStartPos, col);
        } finally {
            releaseReference();
        }
    
private native java.lang.StringgetString_native(int row, int col)

public booleanisBlob(int row, int col)
Checks if a field contains either a blob or is null.

param
row the row to read from, row - getStartPosition() being the actual row in the window
param
col the column to read from
return
{@code true} if given field is {@code NULL} or a blob

        acquireReference();
        try {
            return isBlob_native(row - mStartPos, col);
        } finally {
            releaseReference();
        }
    
private native booleanisBlob_native(int row, int col)

public booleanisNull(int row, int col)
Returns {@code true} if given field is {@code NULL}.

param
row the row to read from, row - getStartPosition() being the actual row in the window
param
col the column to read from
return
{@code true} if given field is {@code NULL}

        acquireReference();
        try {
            return isNull_native(row - mStartPos, col);
        } finally {
            releaseReference();
        }
    
private native booleanisNull_native(int row, int col)

private native voidnative_clear()
Clears out the native side of things

private native android.os.IBindernative_getBinder()
Get the binder for the native side of the window

private native voidnative_init(boolean localOnly)
Does the native side initialization for an empty window

private native voidnative_init(android.os.IBinder nativeBinder)
Does the native side initialization with an existing binder from another process

public static android.database.CursorWindownewFromParcel(android.os.Parcel p)


         
        return CREATOR.createFromParcel(p);
    
protected voidonAllReferencesReleased()

        close_native();        
    
public booleanputBlob(byte[] value, int row, int col)
copy byte array to cursor window

param
value
param
row
param
col
return
false if fail to copy

        acquireReference();
        try {
            return putBlob_native(value, row - mStartPos, col);
        } finally {
            releaseReference();
        }
    
private native booleanputBlob_native(byte[] value, int row, int col)

public booleanputDouble(double value, int row, int col)
Copy double to cursor window

param
value
param
row
param
col
return
false if fail to copy

        acquireReference();
        try {
            return putDouble_native(value, row - mStartPos, col);
        } finally {
            releaseReference();
        }
    
private native booleanputDouble_native(double value, int row, int col)

public booleanputLong(long value, int row, int col)
Copy integer to cursor window

param
value
param
row
param
col
return
false if fail to copy

        acquireReference();
        try {
            return putLong_native(value, row - mStartPos, col);
        } finally {
            releaseReference();
        }
    
private native booleanputLong_native(long value, int row, int col)

public booleanputNull(int row, int col)
Set the [row, col] value to NULL

param
row
param
col
return
false if fail to copy

        acquireReference();
        try {
            return putNull_native(row - mStartPos, col);
        } finally {
            releaseReference();
        }
    
private native booleanputNull_native(int row, int col)

public booleanputString(java.lang.String value, int row, int col)
Copy String to cursor window

param
value
param
row
param
col
return
false if fail to copy

        acquireReference();
        try {
            return putString_native(value, row - mStartPos, col);
        } finally {
            releaseReference();
        }
    
private native booleanputString_native(java.lang.String value, int row, int col)

public booleansetNumColumns(int columnNum)
Set number of Columns

param
columnNum
return
true if success

        acquireReference();
        try {
            return setNumColumns_native(columnNum);
        } finally {
            releaseReference();
        }
    
private native booleansetNumColumns_native(int columnNum)

public voidsetStartPosition(int pos)
Set the start position of cursor window

param
pos

        mStartPos = pos;
    
public voidwriteToParcel(android.os.Parcel dest, int flags)

        dest.writeStrongBinder(native_getBinder());
        dest.writeInt(mStartPos);