Class MatrixCursor
-
- All Implemented Interfaces:
-
android.database.Cursor,java.io.Closeable,java.lang.AutoCloseable
public class MatrixCursor extends AbstractCursor
A mutable cursor implementation backed by an array of
Objects. Use newRow to add rows. Automatically expands internal capacity as needed.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classMatrixCursor.RowBuilderBuilds a row, starting from the left-most column and adding one column value at a time. Follows the same ordering as the column names specified at cursor construction time.
-
Field Summary
Fields Modifier and Type Field Description public final Array<String>columnNamespublic final static intFIELD_TYPE_BLOBpublic final static intFIELD_TYPE_FLOATpublic final static intFIELD_TYPE_INTEGERpublic final static intFIELD_TYPE_NULLpublic final static intFIELD_TYPE_STRING
-
Constructor Summary
Constructors Constructor Description MatrixCursor(Array<String> columnNames, int initialCapacity)Constructs a new cursor with the given initial capacity. MatrixCursor(Array<String> columnNames)Constructs a new cursor.
-
Method Summary
Modifier and Type Method Description Array<String>getColumnNames()MatrixCursor.RowBuildernewRow()Adds a new row to the end and returns a builder for that row. voidaddRow(Array<Object> columnValues)Adds a new row to the end with the given column values. voidaddRow(Iterable<out Object> columnValues)Adds a new row to the end with the given column values. voidfillWindow(int position, CursorWindow window)intgetCount()StringgetString(int column)shortgetShort(int column)intgetInt(int column)longgetLong(int column)floatgetFloat(int column)doublegetDouble(int column)intgetType(int column)booleanonMove(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. booleanisNull(int column)-
Methods inherited from class net.zetetic.database.AbstractCursor
close, copyStringToBuffer, deactivate, getBlob, getColumnCount, getColumnIndex, getColumnIndexOrThrow, getColumnName, getExtras, getNotificationUri, getPosition, getWantsAllOnMoveCalls, isAfterLast, isBeforeFirst, isClosed, isFirst, isLast, move, moveToFirst, moveToLast, moveToNext, moveToPosition, moveToPrevious, registerContentObserver, registerDataSetObserver, requery, respond, setExtras, setNotificationUri, unregisterContentObserver, unregisterDataSetObserver -
Methods inherited from class android.database.Cursor
close, copyStringToBuffer, deactivate, getBlob, getColumnCount, getColumnIndex, getColumnIndexOrThrow, getColumnName, getColumnNames, getCount, getDouble, getExtras, getFloat, getInt, getLong, getNotificationUri, getNotificationUris, getPosition, getShort, getString, getType, getWantsAllOnMoveCalls, isAfterLast, isBeforeFirst, isClosed, isFirst, isLast, isNull, move, moveToFirst, moveToLast, moveToNext, moveToPosition, moveToPrevious, registerContentObserver, registerDataSetObserver, requery, respond, setExtras, setNotificationUri, setNotificationUris, unregisterContentObserver, unregisterDataSetObserver -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getColumnNames
Array<String> getColumnNames()
-
newRow
MatrixCursor.RowBuilder newRow()
Adds a new row to the end and returns a builder for that row. Not safe for concurrent use.
- Returns:
builder which can be used to set the column values for the newrow
-
addRow
void addRow(Array<Object> columnValues)
Adds a new row to the end with the given column values. Not safe for concurrent use.
- Parameters:
columnValues- in the same order as the the column names specifiedat cursor construction time
-
addRow
void addRow(Iterable<out Object> columnValues)
Adds a new row to the end with the given column values. Not safe for concurrent use.
- Parameters:
columnValues- in the same order as the the column names specifiedat cursor construction time
-
fillWindow
void fillWindow(int position, CursorWindow window)
-
getCount
int getCount()
-
getShort
short getShort(int column)
-
getInt
int getInt(int column)
-
getLong
long getLong(int column)
-
getFloat
float getFloat(int column)
-
getDouble
double getDouble(int column)
-
getType
int getType(int column)
-
onMove
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.
This function should be called by methods such as moveToPosition, so it will typically not be called from outside of the cursor class itself.
- Parameters:
oldPosition- The position that we're moving from.newPosition- The position that we're moving to.- Returns:
True if the move is successful, false otherwise.
-
isNull
boolean isNull(int column)
-
-
-
-