public abstract class AbstractDatabase extends Object implements Database
| Modifier and Type | Field and Description |
|---|---|
protected DatabaseErrorHandler |
errorHandler |
protected static Logger |
logger |
protected DBMessages |
messages |
protected String |
name |
protected int |
version |
| Constructor and Description |
|---|
AbstractDatabase() |
| Modifier and Type | Method and Description |
|---|---|
<V> void |
add(List<V> objects,
String objectStoreName,
DatabaseCallback callback)
Insert all objects into its associated objectStore.
|
<V> void |
add(V[] objects,
String objectStoreName,
DatabaseCallback callback)
Insert all objects into its associated objectStore.
|
protected abstract Transaction |
createTransaction(String[] storeNames,
Transaction.Mode mode) |
<K> void |
delete(KeyRange<K> keys,
String objectStoreName,
DatabaseCallback callback)
Remove all objects in the given range from its associated objectStore.
|
<K> void |
delete(K key,
String objectStoreName,
DatabaseCallback callback)
Remove the object associated with the given key from its associated objectStore.
|
protected abstract void |
doOpen(DatabaseCallback callback) |
<K,V> void |
get(K key,
String objectStoreName,
DatabaseRetrieveCallback<V> callback)
Retrieve the object associated with the given key from its associated objectStore.
|
String |
getName()
Retrieve the database name.
|
Transaction |
getTransaction(String[] storeNames,
Transaction.Mode mode)
Create a new transaction targeting the given objectStores.
|
Transaction |
getTransaction(String[] storeNames,
Transaction.Mode mode,
Transaction.TransactionCallback callback)
Create a new transaction targeting the given objectStores.
|
int |
getVersion()
Retrieve the database version.
|
void |
open(DatabaseCallback callback)
Open the database.
|
<V> void |
put(List<V> objects,
String objectStoreName,
DatabaseCallback callback)
Update all received objects into its associated objectStore.
|
<V> void |
put(V[] objects,
String objectStoreName,
DatabaseCallback callback)
Update all received objects into its associated objectStore.
|
void |
setDefaultErrorHandler(DatabaseErrorHandler errorHandler)
Sets an error handler to be called to handle uncaught errors.
|
void |
setName(String newName)
Change the database name.
|
void |
setVersion(int newVersion)
Change the database version.
|
void |
useIndexedDB()
Forces Crux to use Indexed DB implementation for its database.
|
void |
useWebSQL()
Forces Crux to use WEB SQL implementation for its database.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclose, delete, isOpen, isSupportedprotected static Logger logger
protected DBMessages messages
protected DatabaseErrorHandler errorHandler
protected String name
protected int version
public String getName()
Database@DatabaseDef annotationpublic void setName(String newName) throws DatabaseException
DatabasesetName in interface DatabasenewName - new database nameDatabaseExceptionpublic int getVersion()
Database@DatabaseDef annotationgetVersion in interface Databasepublic void setVersion(int newVersion)
throws DatabaseException
DatabasesetVersion in interface DatabasenewVersion - new database versionDatabaseExceptionpublic void open(DatabaseCallback callback)
Databasepublic Transaction getTransaction(String[] storeNames, Transaction.Mode mode)
DatabasegetTransaction in interface DatabasestoreNames - stores referenced by the transaction. You can not use any object store inside your transaction if it is not listed here.mode - transaction mode. See Mode for available modespublic Transaction getTransaction(String[] storeNames, Transaction.Mode mode, Transaction.TransactionCallback callback)
DatabasegetTransaction in interface DatabasestoreNames - stores referenced by the transaction. You can not use any object store inside your transaction if it is not listed here.mode - transaction mode. See Mode for available modescallback - called when operation is completedpublic <V> void add(V[] objects,
String objectStoreName,
DatabaseCallback callback)
DatabaseDatabaseException is threwpublic <V> void add(List<V> objects, String objectStoreName, DatabaseCallback callback)
DatabaseDatabaseException is threwpublic <V> void put(V[] objects,
String objectStoreName,
DatabaseCallback callback)
DatabaseDatabaseException is threwpublic <V> void put(List<V> objects, String objectStoreName, DatabaseCallback callback)
DatabaseDatabaseException is threwpublic <K,V> void get(K key,
String objectStoreName,
DatabaseRetrieveCallback<V> callback)
DatabaseDatabaseException is threwpublic <K> void delete(K key,
String objectStoreName,
DatabaseCallback callback)
DatabaseDatabaseException is threwpublic <K> void delete(KeyRange<K> keys, String objectStoreName, DatabaseCallback callback)
DatabaseDatabaseException is threwpublic void setDefaultErrorHandler(DatabaseErrorHandler errorHandler)
DatabasesetDefaultErrorHandler in interface DatabaseerrorHandler - the error handlerpublic void useIndexedDB()
DatabaseuseIndexedDB in interface Databasepublic void useWebSQL()
Databaseprotected abstract void doOpen(DatabaseCallback callback)
protected abstract Transaction createTransaction(String[] storeNames, Transaction.Mode mode)
Copyright © 2015. All rights reserved.