org.cruxframework.crux.core.client.db
Interface ObjectStore<K,V>

Type Parameters:
K - The type of the key used to identify objects into the store.
V - The type of the objects stored into the store. You can inform JavaScriptObject to this type and insert any valid javascript object into the store. Different javascript objects can be inserted into the store.
All Known Implementing Classes:
AbstractObjectStore, IDXAbstractObjectStore, WSQLAbstractObjectStore

public interface ObjectStore<K,V>

Represents an ObjectStore on Crux Database. ObjectStores are collections of objects inserted into the Database.

Author:
Thiago da Rosa de Bustamante

Method Summary
 void add(V object)
          Insert the given object into the store.
 void add(V object, DatabaseWriteCallback<K> callback)
          Insert the given object into the store.
 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 delete(K key)
          Remove the object associated with the given key from the store.
 void delete(K key, DatabaseDeleteCallback callback)
          Remove the object associated with the given key from the store.
 void delete(KeyRange<K> keyRange)
          Remove all the objects in the given range from the store.
 void delete(KeyRange<K> keyRange, DatabaseDeleteCallback callback)
          Remove all the objects in the given range from the store.
 void get(K key, DatabaseRetrieveCallback<V> callback)
          Retrieve the object associated with the given key from the store.
<I> Index<K,I,V>
getIndex(String name)
          Retrieve the index for the given name
 String[] getIndexNames()
          Return the names of the indexes associated with this object store.
 KeyRangeFactory<K> getKeyRangeFactory()
          Retrieve a factory to create KeyRange objects used by this object store.
 String getObjectStoreName()
          Retrive the name associated with the storage.
 boolean isAutoIncrement()
          Return true if this object store auto increments its keys.
 void openCursor(DatabaseCursorCallback<K,V> callback)
          Open a cursor to iterate over the object store.
 void openCursor(KeyRange<K> keyRange, Cursor.CursorDirection direction, 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)
          Update the given object into the storage.
 void put(V object, DatabaseWriteCallback<K> callback)
          Update the given object into the storage.
 

Method Detail

getObjectStoreName

String getObjectStoreName()
Retrive the name associated with the storage. It is the objectStore identifier.

Returns:

add

void add(V object)
Insert the given object into the store.

Parameters:
object -

add

void add(V object,
         DatabaseWriteCallback<K> callback)
Insert the given object into the store.

Parameters:
object -
callback -

put

void put(V object)
Update the given object into the storage. If it does not exists, insert it.

Parameters:
object -

put

void put(V object,
         DatabaseWriteCallback<K> callback)
Update the given object into the storage. If it does not exists, insert it.

Parameters:
object -
callback -

get

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

Parameters:
key -
callback -

delete

void delete(K key)
Remove the object associated with the given key from the store.

Parameters:
key -

delete

void delete(K key,
            DatabaseDeleteCallback callback)
Remove the object associated with the given key from the store.

Parameters:
key -
callback -

delete

void delete(KeyRange<K> keyRange)
Remove all the objects in the given range from the store.

Parameters:
keyRange -

delete

void delete(KeyRange<K> keyRange,
            DatabaseDeleteCallback callback)
Remove all the objects in the given range from the store.

Parameters:
keyRange -
callback -

getIndexNames

String[] getIndexNames()
Return the names of the indexes associated with this object store.

Returns:

isAutoIncrement

boolean isAutoIncrement()
Return true if this object store auto increments its keys.

Returns:

clear

void clear(DatabaseCallback callback)
Clear this object store

Parameters:
callback -

openCursor

void openCursor(DatabaseCursorCallback<K,V> callback)
Open a cursor to iterate over the object store.

Parameters:
callback -

openCursor

void openCursor(KeyRange<K> keyRange,
                DatabaseCursorCallback<K,V> callback)
Open a cursor to iterate over the object store.

Parameters:
keyRange -
callback -

openCursor

void openCursor(KeyRange<K> keyRange,
                Cursor.CursorDirection direction,
                DatabaseCursorCallback<K,V> callback)
Open a cursor to iterate over the object store.

Parameters:
keyRange -
direction -
callback -

count

void count(DatabaseCountCallback callback)
Return the number of items stored into this object store.

Parameters:
callback -

count

void count(KeyRange<K> range,
           DatabaseCountCallback callback)
Return the number of items stored into this object store in the given range.

Parameters:
range -
callback -

getIndex

<I> Index<K,I,V> getIndex(String name)
Retrieve the index for the given name

Parameters:
name -
Returns:

getKeyRangeFactory

KeyRangeFactory<K> getKeyRangeFactory()
Retrieve a factory to create KeyRange objects used by this object store.

Returns:


Copyright © 2014. All rights reserved.