public abstract class AbstractDataSource extends Object implements AutoCloseable, SQLContext
Base class for data source
| Modifier and Type | Class and Description |
|---|---|
static interface |
AbstractDataSource.AbstractExecutable<E extends BindDaoFactory>
Interface for database operations.
|
static interface |
AbstractDataSource.OnErrorListener |
static class |
AbstractDataSource.TypeStatus |
| Modifier and Type | Field and Description |
|---|---|
protected SQLContextImpl |
context |
boolean |
logEnabled |
String |
name
|
protected AbstractDataSource.OnErrorListener |
onErrorListener |
protected DataSourceOptions |
options |
protected android.database.sqlite.SQLiteOpenHelper |
sqliteHelper |
protected ThreadLocal<AbstractDataSource.TypeStatus> |
status |
protected int |
version
database version
|
protected boolean |
versionChanged
if true, database was update during this application run
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractDataSource(String name,
int version,
DataSourceOptions options) |
| Modifier and Type | Method and Description |
|---|---|
protected List<SQLiteUpdateTask> |
buildTaskList(int previousVersion,
int currentVersion) |
abstract void |
clearCompiledStatements()
used to clear prepared statements
|
void |
close() |
KriptonContentValues |
contentValues(android.database.sqlite.SQLiteStatement compiledStatement) |
KriptonContentValues |
contentValuesForContentProvider(android.content.ContentValues values) |
KriptonContentValues |
contentValuesForUpdate(android.database.sqlite.SQLiteStatement compiledStatement) |
SQLContext |
context() |
protected void |
createHelper(DataSourceOptions options) |
android.database.sqlite.SQLiteDatabase |
database()
Return database object or runtimeexception if no database is opened.
|
protected SQLiteUpdateTask |
findPopulateTaskList(int currentVersion) |
AbstractDataSource.OnErrorListener |
getOnErrorListener()
Get error listener, in transations
|
int |
getVersion() |
boolean |
isLogEnabled() |
boolean |
isOpen()
return true if database is already opened.
|
boolean |
isOpenInWriteMode()
return true if database is already opened in write mode.
|
boolean |
isUpgradedVersion() |
abstract void |
onConfigure(android.database.sqlite.SQLiteDatabase database) |
abstract void |
onCreate(android.database.sqlite.SQLiteDatabase database) |
void |
onDowngrade(android.database.sqlite.SQLiteDatabase db,
int oldVersion,
int newVersion) |
void |
onUpgrade(android.database.sqlite.SQLiteDatabase db,
int oldVersion,
int newVersion) |
android.database.sqlite.SQLiteDatabase |
openReadOnlyDatabase()
Open a read only database.
|
android.database.sqlite.SQLiteDatabase |
openWritableDatabase()
open a writable database.
|
void |
setOnErrorListener(AbstractDataSource.OnErrorListener onErrorListener)
Set error listener for transactions
|
void |
setOptions(DataSourceOptions options)
Define options for data source.
|
StringBuilder |
sqlBuilder() |
protected AbstractDataSource.OnErrorListener onErrorListener
public boolean logEnabled
public final String name
protected DataSourceOptions options
protected android.database.sqlite.SQLiteOpenHelper sqliteHelper
protected SQLContextImpl context
protected ThreadLocal<AbstractDataSource.TypeStatus> status
protected boolean versionChanged
protected int version
database version
protected AbstractDataSource(String name, int version, DataSourceOptions options)
public AbstractDataSource.OnErrorListener getOnErrorListener()
public void setOnErrorListener(AbstractDataSource.OnErrorListener onErrorListener)
onErrorListener - public abstract void clearCompiledStatements()
public SQLContext context()
public KriptonContentValues contentValuesForUpdate(android.database.sqlite.SQLiteStatement compiledStatement)
contentValuesForUpdate in interface SQLContextpublic KriptonContentValues contentValues(android.database.sqlite.SQLiteStatement compiledStatement)
contentValues in interface SQLContextpublic KriptonContentValues contentValuesForContentProvider(android.content.ContentValues values)
contentValuesForContentProvider in interface SQLContextpublic StringBuilder sqlBuilder()
sqlBuilder in interface SQLContextpublic boolean isLogEnabled()
isLogEnabled in interface SQLContextpublic int getVersion()
public void close()
close in interface AutoCloseableprotected SQLiteUpdateTask findPopulateTaskList(int currentVersion)
protected List<SQLiteUpdateTask> buildTaskList(int previousVersion, int currentVersion)
protected void createHelper(DataSourceOptions options)
public android.database.sqlite.SQLiteDatabase database()
Return database object or runtimeexception if no database is opened.
database in interface SQLContextpublic boolean isOpen()
return true if database is already opened.
public boolean isOpenInWriteMode()
return true if database is already opened in write mode.
public boolean isUpgradedVersion()
public abstract void onConfigure(android.database.sqlite.SQLiteDatabase database)
public abstract void onCreate(android.database.sqlite.SQLiteDatabase database)
public void onDowngrade(android.database.sqlite.SQLiteDatabase db,
int oldVersion,
int newVersion)
public void onUpgrade(android.database.sqlite.SQLiteDatabase db,
int oldVersion,
int newVersion)
public android.database.sqlite.SQLiteDatabase openReadOnlyDatabase()
Open a read only database.
public android.database.sqlite.SQLiteDatabase openWritableDatabase()
open a writable database.
public void setOptions(DataSourceOptions options)
options - optionsCopyright © 2017. All rights reserved.