Build 1.0_r1(from source)

android.database
Class MatrixCursor

java.lang.Object
  extended by android.database.AbstractCursor
      extended by android.database.MatrixCursor
All Implemented Interfaces:
CrossProcessCursor, Cursor

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
 class MatrixCursor.RowBuilder
          Builds a row, starting from the left-most column and adding one column value at a time.
 
Nested classes/interfaces inherited from class android.database.AbstractCursor
AbstractCursor.SelfContentObserver
 
Field Summary
 
Fields inherited from class android.database.AbstractCursor
mClosed, mContentObservable, mContentResolver, mCurrentRowID, mDataSetObservable, mPos, mRowIdColumnIndex, mUpdatedRows
 
Constructor Summary
MatrixCursor(String[] columnNames)
          Constructs a new cursor.
MatrixCursor(String[] columnNames, int initialCapacity)
          Constructs a new cursor with the given initial capacity.
 
Method Summary
 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.
 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.
 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.
 
Methods inherited from class android.database.AbstractCursor
abortUpdates, checkPosition, close, commitUpdates, commitUpdates, copyStringToBuffer, deactivate, deactivateInternal, deleteRow, fillWindow, finalize, getBlob, getColumnCount, getColumnIndex, getColumnIndexOrThrow, getColumnName, getExtras, getPosition, getUpdatedField, getWantsAllOnMoveCalls, getWindow, hasUpdates, isAfterLast, isBeforeFirst, isClosed, isFieldUpdated, isFirst, isLast, move, moveToFirst, moveToLast, moveToNext, moveToPosition, moveToPrevious, onChange, onMove, registerContentObserver, registerDataSetObserver, requery, respond, setNotificationUri, supportsUpdates, unregisterContentObserver, unregisterDataSetObserver, update, updateBlob, updateDouble, updateFloat, updateInt, updateLong, updateShort, updateString, updateToNull
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MatrixCursor

public MatrixCursor(String[] columnNames,
                    int initialCapacity)
Constructs a new cursor with the given initial capacity.

Parameters:
columnNames - names of the columns, the ordering of which determines column ordering elsewhere in this cursor
initialCapacity - in rows

MatrixCursor

public MatrixCursor(String[] columnNames)
Constructs a new cursor.

Parameters:
columnNames - names of the columns, the ordering of which determines column ordering elsewhere in this cursor
Method Detail

newRow

public 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 new row

addRow

public void addRow(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 specified at cursor construction time
Throws:
IllegalArgumentException - if columnValues.length != columnNames.length

addRow

public void addRow(Iterable<?> 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 specified at cursor construction time
Throws:
IllegalArgumentException - if columnValues.size() != columnNames.length

getCount

public int getCount()
Description copied from interface: Cursor
Returns the numbers of rows in the cursor.

Specified by:
getCount in interface Cursor
Specified by:
getCount in class AbstractCursor
Returns:
the number of rows in the cursor.

getColumnNames

public String[] getColumnNames()
Description copied from interface: Cursor
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.

Specified by:
getColumnNames in interface Cursor
Specified by:
getColumnNames in class AbstractCursor
Returns:
the names of the columns returned in this query.

getString

public String getString(int column)
Description copied from interface: Cursor
Returns the value of the requested column as a String.

If the native content of that column is not text the result will be the result of passing the column value to String.valueOf(x).

Specified by:
getString in interface Cursor
Specified by:
getString in class AbstractCursor
Parameters:
column - the zero-based index of the target column.
Returns:
the value of that column as a String.

getShort

public short getShort(int column)
Description copied from interface: Cursor
Returns the value of the requested column as a short.

If the native content of that column is not numeric the result will be the result of passing the column value to Short.valueOf(x).

Specified by:
getShort in interface Cursor
Specified by:
getShort in class AbstractCursor
Parameters:
column - the zero-based index of the target column.
Returns:
the value of that column as a short.

getInt

public int getInt(int column)
Description copied from interface: Cursor
Returns the value of the requested column as an int.

If the native content of that column is not numeric the result will be the result of passing the column value to Integer.valueOf(x).

Specified by:
getInt in interface Cursor
Specified by:
getInt in class AbstractCursor
Parameters:
column - the zero-based index of the target column.
Returns:
the value of that column as an int.

getLong

public long getLong(int column)
Description copied from interface: Cursor
Returns the value of the requested column as a long.

If the native content of that column is not numeric the result will be the result of passing the column value to Long.valueOf(x).

Specified by:
getLong in interface Cursor
Specified by:
getLong in class AbstractCursor
Parameters:
column - the zero-based index of the target column.
Returns:
the value of that column as a long.

getFloat

public float getFloat(int column)
Description copied from interface: Cursor
Returns the value of the requested column as a float.

If the native content of that column is not numeric the result will be the result of passing the column value to Float.valueOf(x).

Specified by:
getFloat in interface Cursor
Specified by:
getFloat in class AbstractCursor
Parameters:
column - the zero-based index of the target column.
Returns:
the value of that column as a float.

getDouble

public double getDouble(int column)
Description copied from interface: Cursor
Returns the value of the requested column as a double.

If the native content of that column is not numeric the result will be the result of passing the column value to Double.valueOf(x).

Specified by:
getDouble in interface Cursor
Specified by:
getDouble in class AbstractCursor
Parameters:
column - the zero-based index of the target column.
Returns:
the value of that column as a double.

isNull

public boolean isNull(int column)
Description copied from interface: Cursor
Returns true if the value in the indicated column is null.

Specified by:
isNull in interface Cursor
Specified by:
isNull in class AbstractCursor
Parameters:
column - the zero-based index of the target column.
Returns:
whether the column value is null.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature