Methods Summary |
---|
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.
if (-1 == mPos || getCount() == mPos) {
throw new CursorIndexOutOfBoundsException(mPos, getCount());
}
|
public void | close()
mClosed = true;
mContentObservable.unregisterAll();
onDeactivateOrClose();
|
public void | copyStringToBuffer(int columnIndex, CharArrayBuffer buffer)
// Default implementation, uses getString
String result = getString(columnIndex);
if (result != null) {
char[] data = buffer.data;
if (data == null || data.length < result.length()) {
buffer.data = result.toCharArray();
} else {
result.getChars(0, result.length(), data, 0);
}
buffer.sizeCopied = result.length();
} else {
buffer.sizeCopied = 0;
}
|
public void | deactivate()
onDeactivateOrClose();
|
public void | fillWindow(int position, CursorWindow window)
DatabaseUtils.cursorFillWindow(this, position, window);
|
protected void | finalize()
if (mSelfObserver != null && mSelfObserverRegistered == true) {
mContentResolver.unregisterContentObserver(mSelfObserver);
}
try {
if (!mClosed) close();
} catch(Exception e) { }
|
public byte[] | getBlob(int column)
throw new UnsupportedOperationException("getBlob is not supported");
|
public int | getColumnCount()
return getColumnNames().length;
|
public int | getColumnIndex(java.lang.String columnName)
// Hack according to bug 903852
final int periodIndex = columnName.lastIndexOf('.");
if (periodIndex != -1) {
Exception e = new Exception();
Log.e(TAG, "requesting column name with table name -- " + columnName, e);
columnName = columnName.substring(periodIndex + 1);
}
String columnNames[] = getColumnNames();
int length = columnNames.length;
for (int i = 0; i < length; i++) {
if (columnNames[i].equalsIgnoreCase(columnName)) {
return i;
}
}
if (false) {
if (getCount() > 0) {
Log.w("AbstractCursor", "Unknown column " + columnName);
}
}
return -1;
|
public int | getColumnIndexOrThrow(java.lang.String columnName)
final int index = getColumnIndex(columnName);
if (index < 0) {
throw new IllegalArgumentException("column '" + columnName + "' does not exist");
}
return index;
|
public java.lang.String | getColumnName(int columnIndex)
return getColumnNames()[columnIndex];
|
public abstract java.lang.String[] | getColumnNames()
|
public abstract int | getCount()
|
public abstract double | getDouble(int column)
|
public android.os.Bundle | getExtras()
return mExtras;
|
public abstract float | getFloat(int column)
|
public abstract int | getInt(int column)
|
public abstract long | getLong(int column)
|
public android.net.Uri | getNotificationUri()
synchronized (mSelfObserverLock) {
return mNotifyUri;
}
|
public final int | getPosition()
return mPos;
|
public abstract short | getShort(int column)
|
public abstract java.lang.String | getString(int column)
|
public int | getType(int column)
/* -------------------------------------------------------- */
/* These need to be implemented by subclasses */
// Reflects the assumption that all commonly used field types (meaning everything
// but blobs) are convertible to strings so it should be safe to call
// getString to retrieve them.
return FIELD_TYPE_STRING;
|
protected java.lang.Object | getUpdatedField(int columnIndex)
return null;
|
public boolean | getWantsAllOnMoveCalls()
return false;
|
public CursorWindow | getWindow()If the cursor is backed by a {@link CursorWindow}, returns a pre-filled
window with the contents of the cursor, otherwise null.
return null;
|
public final boolean | isAfterLast()
if (getCount() == 0) {
return true;
}
return mPos == getCount();
|
public final boolean | isBeforeFirst()
if (getCount() == 0) {
return true;
}
return mPos == -1;
|
public boolean | isClosed()
return mClosed;
|
protected boolean | isFieldUpdated(int columnIndex)
return false;
|
public final boolean | isFirst()
return mPos == 0 && getCount() != 0;
|
public final boolean | isLast()
int cnt = getCount();
return mPos == (cnt - 1) && cnt != 0;
|
public abstract boolean | isNull(int column)
|
public final boolean | move(int offset)
return moveToPosition(mPos + offset);
|
public final boolean | moveToFirst()
return moveToPosition(0);
|
public final boolean | moveToLast()
return moveToPosition(getCount() - 1);
|
public final boolean | moveToNext()
return moveToPosition(mPos + 1);
|
public final boolean | moveToPosition(int position)
// Make sure position isn't past the end of the cursor
final int count = getCount();
if (position >= count) {
mPos = count;
return false;
}
// Make sure position isn't before the beginning of the cursor
if (position < 0) {
mPos = -1;
return false;
}
// Check for no-op moves, and skip the rest of the work for them
if (position == mPos) {
return true;
}
boolean result = onMove(mPos, position);
if (result == false) {
mPos = -1;
} else {
mPos = position;
if (mRowIdColumnIndex != -1) {
mCurrentRowID = Long.valueOf(getLong(mRowIdColumnIndex));
}
}
return result;
|
public final boolean | moveToPrevious()
return moveToPosition(mPos - 1);
|
protected void | onChange(boolean selfChange)Subclasses must call this method when they finish committing updates to notify all
observers.
synchronized (mSelfObserverLock) {
mContentObservable.dispatchChange(selfChange, null);
if (mNotifyUri != null && selfChange) {
mContentResolver.notifyChange(mNotifyUri, mSelfObserver);
}
}
|
protected void | onDeactivateOrClose()
if (mSelfObserver != null) {
mContentResolver.unregisterContentObserver(mSelfObserver);
mSelfObserverRegistered = false;
}
mDataSetObservable.notifyInvalidated();
|
public boolean | onMove(int oldPosition, int newPosition)This function is called every time the cursor is successfully scrolled
to a new position, giving the subclass a chance to update any state it
may have. If it returns false the move function will also do so and the
cursor will scroll to the beforeFirst position.
return true;
|
public void | registerContentObserver(ContentObserver observer)
mContentObservable.registerObserver(observer);
|
public void | registerDataSetObserver(DataSetObserver observer)
mDataSetObservable.registerObserver(observer);
|
public boolean | requery()
if (mSelfObserver != null && mSelfObserverRegistered == false) {
mContentResolver.registerContentObserver(mNotifyUri, true, mSelfObserver);
mSelfObserverRegistered = true;
}
mDataSetObservable.notifyChanged();
return true;
|
public android.os.Bundle | respond(android.os.Bundle extras)
return Bundle.EMPTY;
|
public void | setExtras(android.os.Bundle extras)Sets a {@link Bundle} that will be returned by {@link #getExtras()}. null will
be converted into {@link Bundle#EMPTY}.
mExtras = (extras == null) ? Bundle.EMPTY : extras;
|
public void | setNotificationUri(android.content.ContentResolver cr, android.net.Uri notifyUri)Specifies a content URI to watch for changes.
setNotificationUri(cr, notifyUri, UserHandle.myUserId());
|
public void | setNotificationUri(android.content.ContentResolver cr, android.net.Uri notifyUri, int userHandle)
synchronized (mSelfObserverLock) {
mNotifyUri = notifyUri;
mContentResolver = cr;
if (mSelfObserver != null) {
mContentResolver.unregisterContentObserver(mSelfObserver);
}
mSelfObserver = new SelfContentObserver(this);
mContentResolver.registerContentObserver(mNotifyUri, true, mSelfObserver, userHandle);
mSelfObserverRegistered = true;
}
|
public void | unregisterContentObserver(ContentObserver observer)
// cursor will unregister all observers when it close
if (!mClosed) {
mContentObservable.unregisterObserver(observer);
}
|
public void | unregisterDataSetObserver(DataSetObserver observer)
mDataSetObservable.unregisterObserver(observer);
|