Build 1.0_r1(from source)

android.database.sqlite
Class SQLiteProgram

java.lang.Object
  extended by android.database.sqlite.SQLiteClosable
      extended by android.database.sqlite.SQLiteProgram
Direct Known Subclasses:
SQLiteQuery, SQLiteStatement

public abstract class SQLiteProgram
extends SQLiteClosable

A base class for compiled SQLite programs.


Field Summary
protected  SQLiteDatabase mDatabase
          The database this program is compiled against.
protected  int nHandle
          Native linkage, do not modify.
protected  int nStatement
          Native linkage, do not modify.
(package private) static String TAG
           
 
Constructor Summary
SQLiteProgram(SQLiteDatabase db, String sql)
           
 
Method Summary
 void bindBlob(int index, byte[] value)
          Bind a byte array value to this statement.
 void bindDouble(int index, double value)
          Bind a double value to this statement.
 void bindLong(int index, long value)
          Bind a long value to this statement.
 void bindNull(int index)
          Bind a NULL value to this statement.
 void bindString(int index, String value)
          Bind a String value to this statement.
 void clearBindings()
          Clears all existing bindings.
 void close()
          Release this program's resources, making it invalid.
protected  void compile(String sql, boolean forceCompilation)
          Compiles the given SQL into a SQLite byte code program using sqlite3_prepare_v2().
protected  void finalize()
          Make sure that the native resource is cleaned up.
 int getUniqueId()
          Returns a unique identifier for this program.
protected  void native_bind_blob(int index, byte[] value)
           
protected  void native_bind_double(int index, double value)
           
protected  void native_bind_long(int index, long value)
           
protected  void native_bind_null(int index)
           
protected  void native_bind_string(int index, String value)
           
protected  void native_compile(String sql)
          Compiles SQL into a SQLite program.
protected  void native_finalize()
           
protected  void onAllReferencesReleased()
           
protected  void onAllReferencesReleasedFromContainer()
           
 
Methods inherited from class android.database.sqlite.SQLiteClosable
acquireReference, releaseReference, releaseReferenceFromContainer
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAG

static final String TAG
See Also:
Constant Field Values

mDatabase

protected SQLiteDatabase mDatabase
The database this program is compiled against.


nHandle

protected int nHandle
Native linkage, do not modify. This comes from the database and should not be modified in here or in the native code.


nStatement

protected int nStatement
Native linkage, do not modify. When non-0 this holds a reference to a valid sqlite3_statement object. It is only updated by the native code, but may be checked in this class when the database lock is held to determine if there is a valid native-side program or not.

Constructor Detail

SQLiteProgram

SQLiteProgram(SQLiteDatabase db,
              String sql)
Method Detail

onAllReferencesReleased

protected void onAllReferencesReleased()
Specified by:
onAllReferencesReleased in class SQLiteClosable

onAllReferencesReleasedFromContainer

protected void onAllReferencesReleasedFromContainer()
Overrides:
onAllReferencesReleasedFromContainer in class SQLiteClosable

getUniqueId

public final int getUniqueId()
Returns a unique identifier for this program.

Returns:
a unique identifier for this program

compile

protected void compile(String sql,
                       boolean forceCompilation)
Compiles the given SQL into a SQLite byte code program using sqlite3_prepare_v2(). If this method has been called previously without a call to close and forCompilation is set to false the previous compilation will be used. Setting forceCompilation to true will always re-compile the program and should be done if you pass differing SQL strings to this method.

Note: this method acquires the database lock.

Parameters:
sql - the SQL string to compile
forceCompilation - forces the SQL to be recompiled in the event that there is an existing compiled SQL program already around

bindNull

public void bindNull(int index)
Bind a NULL value to this statement. The value remains bound until clearBindings() is called.

Parameters:
index - The 1-based index to the parameter to bind null to

bindLong

public void bindLong(int index,
                     long value)
Bind a long value to this statement. The value remains bound until clearBindings() is called.

Parameters:
index - The 1-based index to the parameter to bind
value - The value to bind

bindDouble

public void bindDouble(int index,
                       double value)
Bind a double value to this statement. The value remains bound until clearBindings() is called.

Parameters:
index - The 1-based index to the parameter to bind
value - The value to bind

bindString

public void bindString(int index,
                       String value)
Bind a String value to this statement. The value remains bound until clearBindings() is called.

Parameters:
index - The 1-based index to the parameter to bind
value - The value to bind

bindBlob

public void bindBlob(int index,
                     byte[] value)
Bind a byte array value to this statement. The value remains bound until clearBindings() is called.

Parameters:
index - The 1-based index to the parameter to bind
value - The value to bind

clearBindings

public void clearBindings()
Clears all existing bindings. Unset bindings are treated as NULL.


close

public void close()
Release this program's resources, making it invalid.


finalize

protected void finalize()
Make sure that the native resource is cleaned up.

Overrides:
finalize in class Object

native_compile

protected final void native_compile(String sql)
Compiles SQL into a SQLite program.

The database lock must be held when calling this method.

Parameters:
sql - The SQL to compile.

native_finalize

protected final void native_finalize()

native_bind_null

protected final void native_bind_null(int index)

native_bind_long

protected final void native_bind_long(int index,
                                      long value)

native_bind_double

protected final void native_bind_double(int index,
                                        double value)

native_bind_string

protected final void native_bind_string(int index,
                                        String value)

native_bind_blob

protected final void native_bind_blob(int index,
                                      byte[] value)

Build 1.0_r1(from source)

Please submit a feedback, bug or feature