FileDocCategorySizeDatePackage
AbstractWindowedCursor.javaAPI DocAndroid 5.1 API5872Thu Mar 12 22:22:10 GMT 2015android.database

AbstractWindowedCursor

public abstract class AbstractWindowedCursor extends AbstractCursor
A base class for Cursors that store their data in {@link 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 {@link #onMove(int, int)}, allocating a new cursor window if necessary. During {@link #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.

Fields Summary
protected CursorWindow
mWindow
The cursor window owned by this cursor.
Constructors Summary
Methods Summary
protected voidcheckPosition()

        super.checkPosition();
        
        if (mWindow == null) {
            throw new StaleDataException("Attempting to access a closed CursorWindow." +
                    "Most probable cause: cursor is deactivated prior to calling this method.");
        }
    
protected voidclearOrCreateWindow(java.lang.String name)
If there is a window, clear it. Otherwise, creates a new window.

param
name The window name.
hide

        if (mWindow == null) {
            mWindow = new CursorWindow(name);
        } else {
            mWindow.clear();
        }
    
protected voidcloseWindow()
Closes the cursor window and sets {@link #mWindow} to null.

hide

        if (mWindow != null) {
            mWindow.close();
            mWindow = null;
        }
    
public voidcopyStringToBuffer(int columnIndex, CharArrayBuffer buffer)

        checkPosition();
        mWindow.copyStringToBuffer(mPos, columnIndex, buffer);
    
public byte[]getBlob(int columnIndex)

        checkPosition();
        return mWindow.getBlob(mPos, columnIndex);
    
public doublegetDouble(int columnIndex)

        checkPosition();
        return mWindow.getDouble(mPos, columnIndex);
    
public floatgetFloat(int columnIndex)

        checkPosition();
        return mWindow.getFloat(mPos, columnIndex);
    
public intgetInt(int columnIndex)

        checkPosition();
        return mWindow.getInt(mPos, columnIndex);
    
public longgetLong(int columnIndex)

        checkPosition();
        return mWindow.getLong(mPos, columnIndex);
    
public shortgetShort(int columnIndex)

        checkPosition();
        return mWindow.getShort(mPos, columnIndex);
    
public java.lang.StringgetString(int columnIndex)

        checkPosition();
        return mWindow.getString(mPos, columnIndex);
    
public intgetType(int columnIndex)

        checkPosition();
        return mWindow.getType(mPos, columnIndex);
    
public CursorWindowgetWindow()

        return mWindow;
    
public booleanhasWindow()
Returns true if the cursor has an associated cursor window.

return
True if the cursor has an associated cursor window.

        return mWindow != null;
    
public booleanisBlob(int columnIndex)

deprecated
Use {@link #getType}

        return getType(columnIndex) == Cursor.FIELD_TYPE_BLOB;
    
public booleanisFloat(int columnIndex)

deprecated
Use {@link #getType}

        return getType(columnIndex) == Cursor.FIELD_TYPE_FLOAT;
    
public booleanisLong(int columnIndex)

deprecated
Use {@link #getType}

        return getType(columnIndex) == Cursor.FIELD_TYPE_INTEGER;
    
public booleanisNull(int columnIndex)

        checkPosition();
        return mWindow.getType(mPos, columnIndex) == Cursor.FIELD_TYPE_NULL;
    
public booleanisString(int columnIndex)

deprecated
Use {@link #getType}

        return getType(columnIndex) == Cursor.FIELD_TYPE_STRING;
    
protected voidonDeactivateOrClose()

hide

        super.onDeactivateOrClose();
        closeWindow();
    
public voidsetWindow(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.

param
window The new cursor window, typically a remote cursor window.

        if (window != mWindow) {
            closeWindow();
            mWindow = window;
        }