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

java.lang.Object
  extended by org.cruxframework.crux.core.client.db.DBObject
      extended by org.cruxframework.crux.core.client.db.WSQLCursor<K,P,V>
Type Parameters:
K - The type of the key used to identify objects into the cursor.
V - The type of the objects referenced by this cursor
All Implemented Interfaces:
Cursor<K,V>

public abstract class WSQLCursor<K,P,V>
extends DBObject
implements Cursor<K,V>

Author:
Thiago da Rosa de Bustamante

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.cruxframework.crux.core.client.db.Cursor
Cursor.CursorDirection
 
Field Summary
protected  boolean autoIncrement
           
protected  DatabaseCursorCallback<K,V> callback
           
protected  K cursorKey
           
protected  Cursor.CursorDirection direction
           
protected  Array<String> indexColumnNames
           
protected  Array<String> keyPath
           
protected  WSQLKeyRange<K> keyRange
           
protected  int length
           
protected  String objectStoreName
           
protected  int offset
           
protected  SQLResultSet resultSet
           
protected  WSQLTransaction transaction
           
 
Fields inherited from class org.cruxframework.crux.core.client.db.DBObject
db, logger
 
Constructor Summary
protected WSQLCursor(WSQLAbstractDatabase db, WSQLKeyRange<K> range, String objectStoreName, boolean autoIncrement, Cursor.CursorDirection direction, WSQLTransaction transaction)
           
 
Method Summary
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)
           
protected abstract  void addPrimaryKeyToQuery(P key, StringBuilder sql, com.google.gwt.core.client.JsArrayMixed args)
           
 void advance(int count)
          Advance the cursor current position by a number of positions.
protected  void appendGroupColumns(StringBuilder sql)
           
 void continueCursor()
          Make cursor to go to the next element.
 void continueCursor(K key)
          Make cursor to go to the element referenced by the given key.
protected abstract  V decodeObject(String encodedObject)
           
 void delete()
          Delete the current value, pointed by the cursor, from the database.
protected abstract  void encodeObject(V object, WSQLAbstractObjectStore.EncodeCallback callback)
           
protected  void fireSuccess()
           
 Cursor.CursorDirection getDirection()
          Direction of iteration used by this cursor.
protected  SQLTransaction.SQLStatementErrorCallback getErrorHandler(Callback callback)
           
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  Array<String> getKeyPath()
           
 com.google.gwt.core.client.JsArrayMixed getNativeArrayKey()
          Return the cursor key, as a native javascript object.
protected abstract  P getPrimaryKey()
           
 V getValue()
          Return the value of record pointed by the cursor.
 boolean hasValue()
          Return true if cursor points to a valid value.
protected abstract  void setObjectKey(V object, P key)
           
protected  int size()
           
 void start(DatabaseCursorCallback<K,V> c)
           
 void update(V value)
          Update current record pointed by the cursor with the given value.
 
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.Cursor
getKey
 

Field Detail

direction

protected final Cursor.CursorDirection direction

transaction

protected final WSQLTransaction transaction

keyRange

protected WSQLKeyRange<K> keyRange

objectStoreName

protected String objectStoreName

offset

protected int offset

length

protected int length

resultSet

protected SQLResultSet resultSet

callback

protected DatabaseCursorCallback<K,V> callback

keyPath

protected Array<String> keyPath

indexColumnNames

protected Array<String> indexColumnNames

cursorKey

protected K cursorKey

autoIncrement

protected final boolean autoIncrement
Constructor Detail

WSQLCursor

protected WSQLCursor(WSQLAbstractDatabase db,
                     WSQLKeyRange<K> range,
                     String objectStoreName,
                     boolean autoIncrement,
                     Cursor.CursorDirection direction,
                     WSQLTransaction transaction)
Method Detail

start

public void start(DatabaseCursorCallback<K,V> c)

advance

public void advance(int count)
Description copied from interface: Cursor
Advance the cursor current position by a number of positions. Cursor callback onSuccess method will be called again, receiving the new value where cursor points after the advance.

Specified by:
advance in interface Cursor<K,V>
Parameters:
count - number of items to advance

continueCursor

public void continueCursor()
Description copied from interface: Cursor
Make cursor to go to the next element. Cursor callback onSuccess method will be called again, receiving the new value where cursor points after the advance.

Specified by:
continueCursor in interface Cursor<K,V>

continueCursor

public void continueCursor(K key)
Description copied from interface: Cursor
Make cursor to go to the element referenced by the given key. Cursor callback onSuccess method will be called again, receiving the new value where cursor points after the advance.

Specified by:
continueCursor in interface Cursor<K,V>
Parameters:
key - key of the element to be pointed by the cursor.

delete

public void delete()
Description copied from interface: Cursor
Delete the current value, pointed by the cursor, from the database.

Specified by:
delete in interface Cursor<K,V>

update

public void update(V value)
Description copied from interface: Cursor
Update current record pointed by the cursor with the given value.

Specified by:
update in interface Cursor<K,V>
Parameters:
value - new value to update

hasValue

public boolean hasValue()
Description copied from interface: Cursor
Return true if cursor points to a valid value.

Specified by:
hasValue in interface Cursor<K,V>
Returns:
true if cursor points to a valid value

size

protected int size()

getIndexesValuesForObject

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

appendGroupColumns

protected void appendGroupColumns(StringBuilder sql)

getErrorHandler

protected SQLTransaction.SQLStatementErrorCallback getErrorHandler(Callback callback)

getDirection

public Cursor.CursorDirection getDirection()
Description copied from interface: Cursor
Direction of iteration used by this cursor.

Specified by:
getDirection in interface Cursor<K,V>
Returns:
cursor direction

getValue

public V getValue()
Description copied from interface: Cursor
Return the value of record pointed by the cursor.

Specified by:
getValue in interface Cursor<K,V>
Returns:
value of the element pointed by the cursor

getNativeArrayKey

public com.google.gwt.core.client.JsArrayMixed getNativeArrayKey()
Description copied from interface: Cursor
Return the cursor key, as a native javascript object.

Specified by:
getNativeArrayKey in interface Cursor<K,V>
Returns:
cursor key.

fireSuccess

protected void fireSuccess()

setObjectKey

protected abstract void setObjectKey(V object,
                                     P key)

getIndexedColumnNames

protected abstract Array<String> getIndexedColumnNames()

getPrimaryKey

protected abstract P getPrimaryKey()

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)

addPrimaryKeyToQuery

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

encodeObject

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

decodeObject

protected abstract V decodeObject(String encodedObject)


Copyright © 2014. All rights reserved.