public class MatrixCursor extends AbstractCursor
Object
s. Use
newRow()
to add rows. Automatically expands internal capacity
as needed.Modifier and Type | Class and Description |
---|---|
class |
MatrixCursor.RowBuilder
Builds a row of values using either of these approaches:
Values can be added with explicit column ordering using
MatrixCursor.RowBuilder.add(Object) , which starts from the left-most column and adds one
column value at a time. |
AbstractCursor.SelfContentObserver
mClosed, mContentResolver, mCurrentRowID, mPos, mRowIdColumnIndex, mUpdatedRows
FIELD_TYPE_BLOB, FIELD_TYPE_FLOAT, FIELD_TYPE_INTEGER, FIELD_TYPE_NULL, FIELD_TYPE_STRING
Constructor and Description |
---|
MatrixCursor(String[] columnNames)
Constructs a new cursor.
|
MatrixCursor(String[] columnNames,
int initialCapacity)
Constructs a new cursor with the given initial capacity.
|
Modifier and Type | Method and Description |
---|---|
void |
addRow(Iterable<?> columnValues)
Adds a new row to the end with the given column values.
|
void |
addRow(Object[] columnValues)
Adds a new row to the end with the given column values.
|
byte[] |
getBlob(int column)
Returns the value of the requested column as a byte array.
|
String[] |
getColumnNames()
Returns a string array holding the names of all of the columns in the
result set in the order in which they were listed in the result.
|
int |
getCount()
Returns the numbers of rows in the cursor.
|
double |
getDouble(int column)
Returns the value of the requested column as a double.
|
float |
getFloat(int column)
Returns the value of the requested column as a float.
|
int |
getInt(int column)
Returns the value of the requested column as an int.
|
long |
getLong(int column)
Returns the value of the requested column as a long.
|
short |
getShort(int column)
Returns the value of the requested column as a short.
|
String |
getString(int column)
Returns the value of the requested column as a String.
|
int |
getType(int column)
Returns data type of the given column's value.
|
boolean |
isNull(int column)
Returns
true if the value in the indicated column is null. |
MatrixCursor.RowBuilder |
newRow()
Adds a new row to the end and returns a builder for that row.
|
checkPosition, close, copyStringToBuffer, deactivate, fillWindow, finalize, getColumnCount, getColumnIndex, getColumnIndexOrThrow, getColumnName, getExtras, getNotificationUri, getPosition, getUpdatedField, getWantsAllOnMoveCalls, getWindow, isAfterLast, isBeforeFirst, isClosed, isFieldUpdated, isFirst, isLast, move, moveToFirst, moveToLast, moveToNext, moveToPosition, moveToPrevious, onChange, onDeactivateOrClose, onMove, registerContentObserver, registerDataSetObserver, requery, respond, setExtras, setNotificationUri, setNotificationUri, unregisterContentObserver, unregisterDataSetObserver
public MatrixCursor(String[] columnNames, int initialCapacity)
columnNames
- names of the columns, the ordering of which
determines column ordering elsewhere in this cursorinitialCapacity
- in rowspublic MatrixCursor(String[] columnNames)
columnNames
- names of the columns, the ordering of which
determines column ordering elsewhere in this cursorpublic MatrixCursor.RowBuilder newRow()
public void addRow(Object[] columnValues)
columnValues
- in the same order as the the column names specified
at cursor construction timeIllegalArgumentException
- if columnValues.length !=
columnNames.length
public void addRow(Iterable<?> columnValues)
columnValues
- in the same order as the the column names specified
at cursor construction timeIllegalArgumentException
- if columnValues.size() !=
columnNames.length
public int getCount()
Cursor
getCount
in interface Cursor
getCount
in class AbstractCursor
public String[] getColumnNames()
Cursor
getColumnNames
in interface Cursor
getColumnNames
in class AbstractCursor
public String getString(int column)
Cursor
The result and whether this method throws an exception when the column value is null or the column type is not a string type is implementation-defined.
getString
in interface Cursor
getString
in class AbstractCursor
column
- the zero-based index of the target column.public short getShort(int column)
Cursor
The result and whether this method throws an exception when the
column value is null, the column type is not an integral type, or the
integer value is outside the range [Short.MIN_VALUE
,
Short.MAX_VALUE
] is implementation-defined.
getShort
in interface Cursor
getShort
in class AbstractCursor
column
- the zero-based index of the target column.public int getInt(int column)
Cursor
The result and whether this method throws an exception when the
column value is null, the column type is not an integral type, or the
integer value is outside the range [Integer.MIN_VALUE
,
Integer.MAX_VALUE
] is implementation-defined.
getInt
in interface Cursor
getInt
in class AbstractCursor
column
- the zero-based index of the target column.public long getLong(int column)
Cursor
The result and whether this method throws an exception when the
column value is null, the column type is not an integral type, or the
integer value is outside the range [Long.MIN_VALUE
,
Long.MAX_VALUE
] is implementation-defined.
getLong
in interface Cursor
getLong
in class AbstractCursor
column
- the zero-based index of the target column.public float getFloat(int column)
Cursor
The result and whether this method throws an exception when the
column value is null, the column type is not a floating-point type, or the
floating-point value is not representable as a float
value is
implementation-defined.
getFloat
in interface Cursor
getFloat
in class AbstractCursor
column
- the zero-based index of the target column.public double getDouble(int column)
Cursor
The result and whether this method throws an exception when the
column value is null, the column type is not a floating-point type, or the
floating-point value is not representable as a double
value is
implementation-defined.
getDouble
in interface Cursor
getDouble
in class AbstractCursor
column
- the zero-based index of the target column.public byte[] getBlob(int column)
Cursor
The result and whether this method throws an exception when the column value is null or the column type is not a blob type is implementation-defined.
getBlob
in interface Cursor
getBlob
in class AbstractCursor
column
- the zero-based index of the target column.public int getType(int column)
Cursor
Cursor.getInt(int)
, Cursor.getFloat(int)
etc.
Returned column types are
getType
in interface Cursor
getType
in class AbstractCursor
column
- the zero-based index of the target column.public boolean isNull(int column)
Cursor
true
if the value in the indicated column is null.isNull
in interface Cursor
isNull
in class AbstractCursor
column
- the zero-based index of the target column.