public class

MatrixCursor

extends AbstractCursor
java.lang.Object
   ↳ com.tencent.wcdb.AbstractCursor
     ↳ com.tencent.wcdb.MatrixCursor

Class Overview

A mutable cursor implementation backed by an array of Objects. Use newRow() to add rows. Automatically expands internal capacity as needed.

Summary

Nested Classes
class MatrixCursor.RowBuilder Builds a row, starting from the left-most column and adding one column value at a time. 
[Expand]
Inherited Constants
From interface android.database.Cursor
From interface com.tencent.wcdb.Cursor
Public Constructors
MatrixCursor(String[] columnNames, int initialCapacity)
Constructs a new cursor with the given initial capacity.
MatrixCursor(String[] columnNames)
Constructs a new cursor.
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.
void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer)
Retrieves the requested column text and stores it in the buffer provided.
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.
void registerContentObserver(ContentObserver observer)
Register an observer that is called when changes happen to the content backing this cursor.
void registerDataSetObserver(DataSetObserver observer)
Register an observer that is called when changes happen to the contents of the this cursors data set, for example, when the data set is changed via requery(), deactivate(), or close().
void unregisterContentObserver(ContentObserver observer)
Unregister an observer that has previously been registered with this cursor via registerContentObserver(ContentObserver).
void unregisterDataSetObserver(DataSetObserver observer)
Unregister an observer that has previously been registered with this cursor via registerContentObserver(ContentObserver).
[Expand]
Inherited Methods
From class com.tencent.wcdb.AbstractCursor
From class java.lang.Object
From interface android.database.Cursor
From interface com.tencent.wcdb.CrossProcessCursor
From interface com.tencent.wcdb.Cursor
From interface java.io.Closeable
From interface java.lang.AutoCloseable

Public Constructors

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

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

Public Methods

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

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

public void copyStringToBuffer (int columnIndex, CharArrayBuffer buffer)

Retrieves the requested column text and stores it in the buffer provided. If the buffer size is not sufficient, a new char buffer will be allocated and assigned to CharArrayBuffer.data

Parameters
columnIndex the zero-based index of the target column. if the target column is null, return buffer
buffer the buffer to copy the text into.

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 the zero-based index of the target column.
Returns
  • the value of that column as a byte array.

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
  • the names of the columns returned in this query.

public int getCount ()

Returns the numbers of rows in the cursor.

Returns
  • the number of rows in the cursor.

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 the zero-based index of the target column.
Returns
  • the value of that column as a double.

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 the zero-based index of the target column.
Returns
  • the value of that column as a float.

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 the zero-based index of the target column.
Returns
  • the value of that column as an int.

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 the zero-based index of the target column.
Returns
  • the value of that column as a long.

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 the zero-based index of the target column.
Returns
  • the value of that column as a short.

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 the zero-based index of the target column.
Returns
  • the value of that column as a String.

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.

Returned column types are

Parameters
column the zero-based index of the target column.
Returns
  • column value type

public boolean isNull (int column)

Returns true if the value in the indicated column is null.

Parameters
column the zero-based index of the target column.
Returns
  • whether the column value is null.

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

public void registerContentObserver (ContentObserver observer)

Register an observer that is called when changes happen to the content backing this cursor. Typically the data set won't change until requery() is called.

Parameters
observer the object that gets notified when the content backing the cursor changes.

public void registerDataSetObserver (DataSetObserver observer)

Register an observer that is called when changes happen to the contents of the this cursors data set, for example, when the data set is changed via requery(), deactivate(), or close().

Parameters
observer the object that gets notified when the cursors data set changes.

public void unregisterContentObserver (ContentObserver observer)

Unregister an observer that has previously been registered with this cursor via registerContentObserver(ContentObserver).

Parameters
observer the object to unregister.

public void unregisterDataSetObserver (DataSetObserver observer)

Unregister an observer that has previously been registered with this cursor via registerContentObserver(ContentObserver).

Parameters
observer the object to unregister.