org.cruxframework.crux.core.client.db
Class WSQLAbstractObjectStore<K,V>

java.lang.Object
  extended by org.cruxframework.crux.core.client.db.DBObject
      extended by org.cruxframework.crux.core.client.db.AbstractObjectStore<K,V>
          extended by org.cruxframework.crux.core.client.db.WSQLAbstractObjectStore<K,V>
All Implemented Interfaces:
ObjectStore<K,V>

public abstract class WSQLAbstractObjectStore<K,V>
extends AbstractObjectStore<K,V>

Author:
Thiago da Rosa de Bustamante

Nested Class Summary
static interface WSQLAbstractObjectStore.EncodeCallback
           
 
Field Summary
protected  WSQLAbstractDatabase db
           
protected  Array<String> indexAndKeyColumnNames
           
protected  Array<String> indexColumnNames
           
protected  Array<String> keyPath
           
protected  String name
           
protected  WSQLTransaction transaction
           
 
Fields inherited from class org.cruxframework.crux.core.client.db.DBObject
logger
 
Constructor Summary
protected WSQLAbstractObjectStore(WSQLAbstractDatabase db, String name, WSQLTransaction transaction)
           
 
Method Summary
 void add(V object, DatabaseWriteCallback<K> callback)
          Insert the given object into the store.
protected abstract  void addKeyRangeToQuery(KeyRange<K> range, StringBuilder sql, com.google.gwt.core.client.JsArrayMixed args)
           
protected abstract  void addKeyToQuery(K key, StringBuilder sql, com.google.gwt.core.client.JsArrayMixed args)
           
 void clear(DatabaseCallback callback)
          Clear this object store
 void count(DatabaseCountCallback callback)
          Return the number of items stored into this object store.
 void count(KeyRange<K> range, DatabaseCountCallback callback)
          Return the number of items stored into this object store in the given range.
 void createTable(SQLTransaction tx, DatabaseCallback callback)
           
protected abstract  V decodeObject(String encodedObject)
           
 void delete(K key, DatabaseDeleteCallback callback)
          Remove the object associated with the given key from the store.
 void delete(KeyRange<K> range, DatabaseDeleteCallback callback)
          Remove all the objects in the given range from the store.
protected abstract  void encodeObject(V object, WSQLAbstractObjectStore.EncodeCallback callback)
           
 void get(K key, DatabaseRetrieveCallback<V> callback)
          Retrieve the object associated with the given key from the store.
protected abstract  String getCreateTableSQL()
           
protected  SQLTransaction.SQLStatementErrorCallback getErrorHandler(Callback callback)
           
protected  Array<String> getIndexAndKeyColumnNames()
           
protected abstract  Array<String> getIndexedColumnNames()
           
protected  void getIndexesValuesForObject(com.google.gwt.core.client.JavaScriptObject object, Array<String> columnNames, com.google.gwt.core.client.JsArrayMixed output)
           
protected abstract  K getKey(V object)
           
protected abstract  Array<String> getKeyPath()
           
 String getObjectStoreName()
          Retrive the name associated with the storage.
protected  void insertObject(SQLTransaction tx, DatabaseWriteCallback<K> callback, K key, com.google.gwt.json.client.JSONObject encoded)
           
protected  void insertObject(V object, SQLTransaction tx, DatabaseWriteCallback<K> callback, K key)
           
 void openCursor(DatabaseCursorCallback<K,V> callback)
          Open a cursor to iterate over the object store.
 void openCursor(KeyRange<K> keyRange, DatabaseCursorCallback<K,V> callback)
          Open a cursor to iterate over the object store.
 void put(V object, DatabaseWriteCallback<K> callback)
          Update the given object into the storage.
protected  void reportError(String message)
           
protected  void runDatabaseSQL(DatabaseCallback callback, SQLTransaction tx, com.google.gwt.core.client.JsArrayMixed args, String sqlStatement)
           
protected  void runDeleteSQL(DatabaseDeleteCallback callback, SQLTransaction tx, com.google.gwt.core.client.JsArrayMixed args, String sqlStatement)
           
protected  void runInsertQL(DatabaseWriteCallback<K> callback, SQLTransaction tx, com.google.gwt.core.client.JsArrayMixed args, String sqlStatement, K key)
           
protected  void runSelectSQL(DatabaseRetrieveCallback<V> callback, SQLTransaction tx, com.google.gwt.core.client.JsArrayMixed args, String sqlStatement, K key)
           
protected  void runUpdateSQL(DatabaseWriteCallback<K> callback, SQLTransaction tx, com.google.gwt.core.client.JsArrayMixed args, String sqlStatement, K key, com.google.gwt.json.client.JSONObject encodedObject)
           
protected abstract  void setObjectKey(V object, K key)
           
protected  void updateObject(V object, SQLTransaction tx, DatabaseWriteCallback<K> callback, K key)
           
 
Methods inherited from class org.cruxframework.crux.core.client.db.AbstractObjectStore
add, delete, delete, put
 
Methods inherited from class org.cruxframework.crux.core.client.db.DBObject
reportError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.cruxframework.crux.core.client.db.ObjectStore
getIndex, getIndexNames, getKeyRangeFactory, isAutoIncrement, openCursor
 

Field Detail

name

protected final String name

transaction

protected final WSQLTransaction transaction

db

protected final WSQLAbstractDatabase db

indexAndKeyColumnNames

protected Array<String> indexAndKeyColumnNames

keyPath

protected Array<String> keyPath

indexColumnNames

protected Array<String> indexColumnNames
Constructor Detail

WSQLAbstractObjectStore

protected WSQLAbstractObjectStore(WSQLAbstractDatabase db,
                                  String name,
                                  WSQLTransaction transaction)
Method Detail

getObjectStoreName

public String getObjectStoreName()
Description copied from interface: ObjectStore
Retrive the name associated with the storage. It is the objectStore identifier.

Returns:

add

public void add(V object,
                DatabaseWriteCallback<K> callback)
Description copied from interface: ObjectStore
Insert the given object into the store.


put

public void put(V object,
                DatabaseWriteCallback<K> callback)
Description copied from interface: ObjectStore
Update the given object into the storage. If it does not exists, insert it.


get

public void get(K key,
                DatabaseRetrieveCallback<V> callback)
Description copied from interface: ObjectStore
Retrieve the object associated with the given key from the store. To read the object, use the method onSuccess from DatabaseRetrieveCallback.


delete

public void delete(KeyRange<K> range,
                   DatabaseDeleteCallback callback)
Description copied from interface: ObjectStore
Remove all the objects in the given range from the store.


delete

public void delete(K key,
                   DatabaseDeleteCallback callback)
Description copied from interface: ObjectStore
Remove the object associated with the given key from the store.


clear

public void clear(DatabaseCallback callback)
Description copied from interface: ObjectStore
Clear this object store


createTable

public void createTable(SQLTransaction tx,
                        DatabaseCallback callback)

count

public void count(DatabaseCountCallback callback)
Description copied from interface: ObjectStore
Return the number of items stored into this object store.


count

public void count(KeyRange<K> range,
                  DatabaseCountCallback callback)
Description copied from interface: ObjectStore
Return the number of items stored into this object store in the given range.


openCursor

public void openCursor(DatabaseCursorCallback<K,V> callback)
Description copied from interface: ObjectStore
Open a cursor to iterate over the object store.


openCursor

public void openCursor(KeyRange<K> keyRange,
                       DatabaseCursorCallback<K,V> callback)
Description copied from interface: ObjectStore
Open a cursor to iterate over the object store.


insertObject

protected void insertObject(V object,
                            SQLTransaction tx,
                            DatabaseWriteCallback<K> callback,
                            K key)

insertObject

protected void insertObject(SQLTransaction tx,
                            DatabaseWriteCallback<K> callback,
                            K key,
                            com.google.gwt.json.client.JSONObject encoded)

updateObject

protected void updateObject(V object,
                            SQLTransaction tx,
                            DatabaseWriteCallback<K> callback,
                            K key)

getIndexAndKeyColumnNames

protected Array<String> getIndexAndKeyColumnNames()

getIndexesValuesForObject

protected void getIndexesValuesForObject(com.google.gwt.core.client.JavaScriptObject object,
                                         Array<String> columnNames,
                                         com.google.gwt.core.client.JsArrayMixed output)

runUpdateSQL

protected void runUpdateSQL(DatabaseWriteCallback<K> callback,
                            SQLTransaction tx,
                            com.google.gwt.core.client.JsArrayMixed args,
                            String sqlStatement,
                            K key,
                            com.google.gwt.json.client.JSONObject encodedObject)

runInsertQL

protected void runInsertQL(DatabaseWriteCallback<K> callback,
                           SQLTransaction tx,
                           com.google.gwt.core.client.JsArrayMixed args,
                           String sqlStatement,
                           K key)

runDeleteSQL

protected void runDeleteSQL(DatabaseDeleteCallback callback,
                            SQLTransaction tx,
                            com.google.gwt.core.client.JsArrayMixed args,
                            String sqlStatement)

runSelectSQL

protected void runSelectSQL(DatabaseRetrieveCallback<V> callback,
                            SQLTransaction tx,
                            com.google.gwt.core.client.JsArrayMixed args,
                            String sqlStatement,
                            K key)

runDatabaseSQL

protected void runDatabaseSQL(DatabaseCallback callback,
                              SQLTransaction tx,
                              com.google.gwt.core.client.JsArrayMixed args,
                              String sqlStatement)

getErrorHandler

protected SQLTransaction.SQLStatementErrorCallback getErrorHandler(Callback callback)

reportError

protected void reportError(String message)

getIndexedColumnNames

protected abstract Array<String> getIndexedColumnNames()

getKeyPath

protected abstract Array<String> getKeyPath()

addKeyRangeToQuery

protected abstract void addKeyRangeToQuery(KeyRange<K> range,
                                           StringBuilder sql,
                                           com.google.gwt.core.client.JsArrayMixed args)

addKeyToQuery

protected abstract void addKeyToQuery(K key,
                                      StringBuilder sql,
                                      com.google.gwt.core.client.JsArrayMixed args)

getKey

protected abstract K getKey(V object)

setObjectKey

protected abstract void setObjectKey(V object,
                                     K key)

decodeObject

protected abstract V decodeObject(String encodedObject)

encodeObject

protected abstract void encodeObject(V object,
                                     WSQLAbstractObjectStore.EncodeCallback callback)

getCreateTableSQL

protected abstract String getCreateTableSQL()


Copyright © 2014. All rights reserved.