public class

SQLiteDirectCursor

extends AbstractCursor
java.lang.Object
   ↳ com.tencent.wcdb.AbstractCursor
     ↳ com.tencent.wcdb.database.SQLiteDirectCursor

Class Overview

Cursor implementation that acts directly on the underlying SQLite statement object.

Differ from the default implementation SQLiteCursor, which backed with a linear buffer called CursorWindow, this implementation maps directly to sqlite3_stmt, thus cost less memory and CPU time on certain situation.

Summary

[Expand]
Inherited Constants
From interface android.database.Cursor
From interface com.tencent.wcdb.Cursor
Fields
public static final SQLiteDatabase.CursorFactory FACTORY Static factory object of SQLiteDirectCursor.
Public Constructors
SQLiteDirectCursor(SQLiteCursorDriver driver, String editTable, SQLiteDirectQuery query)
Execute a query and provide access to its result set through a Cursor interface.
Public Methods
void close()
Closes the Cursor, releasing all of its resources and making it completely invalid.
void deactivate()
Deactivates the Cursor, making all calls on it fail until requery() is called.
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.
boolean moveToPosition(int position)
Move the cursor to an absolute position.
boolean requery()
Performs the query that created the cursor again, refreshing its contents.
[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

Fields

Public Constructors

public SQLiteDirectCursor (SQLiteCursorDriver driver, String editTable, SQLiteDirectQuery query)

Execute a query and provide access to its result set through a Cursor interface. For a query such as: SELECT name, birth, phone FROM myTable WHERE ... LIMIT 1,20 ORDER BY... the column names (name, birth, phone) would be in the projection argument and everything from FROM onward would be in the params argument.

Parameters
editTable the name of the table used for this query
query the SQLiteDirectQuery object associated with this cursor object.

Public Methods

public void close ()

Closes the Cursor, releasing all of its resources and making it completely invalid. Unlike deactivate() a call to requery() will not make the Cursor valid again.

public void deactivate ()

Deactivates the Cursor, making all calls on it fail until requery() is called. Inactive Cursors use fewer resources than active Cursors. Calling requery() will make the cursor active again.

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 boolean moveToPosition (int position)

Move the cursor to an absolute position. The valid range of values is -1 <= position <= count.

This method will return true if the request destination was reachable, otherwise, it returns false.

Parameters
position the zero-based position to move to.
Returns
  • whether the requested move fully succeeded.

public boolean requery ()

Performs the query that created the cursor again, refreshing its contents. This may be done at any time, including after a call to deactivate(). Since this method could execute a query on the database and potentially take a while, it could cause ANR if it is called on Main (UI) thread. A warning is printed if this method is being executed on Main thread.

Returns
  • true if the requery succeeded, false if not, in which case the cursor becomes invalid.