MatrixCursor
public
class
MatrixCursor
extends AbstractCursor
java.lang.Object | ||
↳ | android.database.AbstractCursor | |
↳ | android.database.MatrixCursor |
A mutable cursor implementation backed by an array of Object
s. Use
newRow()
to add rows. Automatically expands internal capacity
as needed.
Summary
Nested classes | |
---|---|
class |
MatrixCursor.RowBuilder
Builds a row of values using either of these approaches:
|
Inherited constants |
---|
Inherited fields |
---|
Public constructors | |
---|---|
MatrixCursor(String[] columnNames)
Constructs a new cursor. |
|
MatrixCursor(String[] columnNames, int initialCapacity)
Constructs a new cursor with the given initial capacity. |
Public methods | |
---|---|
void
|
addRow(Object[] columnValues)
Adds a new row to the end with the given column values. |
void
|
addRow(Iterable<?> 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 |
MatrixCursor.RowBuilder
|
newRow()
Adds a new row to the end and returns a builder for that row. |
Inherited methods | |
---|---|
Public constructors
MatrixCursor
public MatrixCursor (String[] columnNames)
Constructs a new cursor.
Parameters | |
---|---|
columnNames |
String : names of the columns, the ordering of which
determines column ordering elsewhere in this cursor |
MatrixCursor
public MatrixCursor (String[] columnNames, int initialCapacity)
Constructs a new cursor with the given initial capacity.
Parameters | |
---|---|
columnNames |
String : names of the columns, the ordering of which
determines column ordering elsewhere in this cursor |
initialCapacity |
int : in rows |
Public methods
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 |
Object : 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 |
Iterable : in the same order as the the column names specified
at cursor construction time |
Throws | |
---|---|
IllegalArgumentException |
if columnValues.size() !=
columnNames.length |
getBlob
public byte[] getBlob (int column)
Returns the value of the requested column as a byte array.
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.
Parameters | |
---|---|
column |
int : the zero-based index of the target column.
Value is 0 or greater |
Returns | |
---|---|
byte[] |
the value of that column as a byte array. |
getColumnNames
public 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.
Returns | |
---|---|
String[] |
the names of the columns returned in this query. |
getCount
public int getCount ()
Returns the numbers of rows in the cursor.
Returns | |
---|---|
int |
the number of rows in the cursor. Value is 0 or greater |
getDouble
public double getDouble (int column)
Returns the value of the requested column as a double.
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.
Parameters | |
---|---|
column |
int : the zero-based index of the target column.
Value is 0 or greater |
Returns | |
---|---|
double |
the value of that column as a double. |
getFloat
public float getFloat (int column)
Returns the value of the requested column as a float.
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.
Parameters | |
---|---|
column |
int : the zero-based index of the target column.
Value is 0 or greater |
Returns | |
---|---|
float |
the value of that column as a float. |
getInt
public int getInt (int column)
Returns the value of the requested column as an int.
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.
Parameters | |
---|---|
column |
int : the zero-based index of the target column.
Value is 0 or greater |
Returns | |
---|---|
int |
the value of that column as an int. |
getLong
public long getLong (int column)
Returns the value of the requested column as a long.
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.
Parameters | |
---|---|
column |
int : the zero-based index of the target column.
Value is 0 or greater |
Returns | |
---|---|
long |
the value of that column as a long. |
getShort
public short getShort (int column)
Returns the value of the requested column as a short.
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.
Parameters | |
---|---|
column |
int : the zero-based index of the target column.
Value is 0 or greater |
Returns | |
---|---|
short |
the value of that column as a short. |
getString
public String getString (int column)
Returns the value of the requested column as a String.
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.
Parameters | |
---|---|
column |
int : the zero-based index of the target column.
Value is 0 or greater |
Returns | |
---|---|
String |
the value of that column as a String. |
getType
public int getType (int column)
Returns data type of the given column's value.
The preferred type of the column is returned but the data may be converted to other types
as documented in the get-type methods such as getInt(int)
, getFloat(int)
etc.
Parameters | |
---|---|
column |
int : the zero-based index of the target column.
Value is 0 or greater |
Returns | |
---|---|
int |
column value type
Value is FIELD_TYPE_NULL , FIELD_TYPE_INTEGER , FIELD_TYPE_FLOAT , FIELD_TYPE_STRING , or FIELD_TYPE_BLOB |
isNull
public boolean isNull (int column)
Returns true
if the value in the indicated column is null.
Parameters | |
---|---|
column |
int : the zero-based index of the target column.
Value is 0 or greater |
Returns | |
---|---|
boolean |
whether the column value is null. |
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 | |
---|---|
MatrixCursor.RowBuilder |
builder which can be used to set the column values for the new row |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
TMZ Celebrity News – Breaking Stories, Videos & Gossip
Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.
Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.
🎥 Watch TMZ Live
TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.
- Exclusive TMZ interviews and court updates
- Viral celebrity videos and candid photos
- Trending gossip and entertainment news