kyotocabinet
Class Cursor

Object
  extended by Cursor

public class Cursor
extends Object

Interface of cursor to indicate a record.


Constructor Summary
Cursor(DB db)
          Create an instance.
 
Method Summary
 boolean accept(Visitor visitor, boolean writable, boolean step)
          Accept a visitor to the current record.
 DB db()
          Get the database object.
 void disable()
          Disable the cursor.
 Error error()
          Get the last happened error.
protected  void finalize()
          Release resources.
 String get_key_str(boolean step)
          Get the key of the current record.
 byte[] get_key(boolean step)
          Get the key of the current record.
 String[] get_str(boolean step)
          Get a pair of the key and the value of the current record.
 String get_value_str(boolean step)
          Get the value of the current record.
 byte[] get_value(boolean step)
          Get the value of the current record.
 byte[][] get(boolean step)
          Get a pair of the key and the value of the current record.
 boolean jump_back()
          Jump the cursor to the last record for backward scan.
 boolean jump_back(byte[] key)
          Jump the cursor to a record for backward scan.
 boolean jump_back(String key)
          Jump the cursor to a record for backward scan.
 boolean jump()
          Jump the cursor to the first record for forward scan.
 boolean jump(byte[] key)
          Jump the cursor to a record for forward scan.
 boolean jump(String key)
          Jump the cursor to a record for forward scan.
 boolean remove()
          Remove the current record.
 boolean set_value(byte[] value, boolean step)
          Set the value of the current record.
 boolean set_value(String value, boolean step)
          Set the value of the current record.
 boolean step_back()
          Step the cursor to the previous record.
 boolean step()
          Step the cursor to the next record.
 String toString()
          Get the string expression.
 
Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Cursor

public Cursor(DB db)
Create an instance.

Method Detail

accept

public boolean accept(Visitor visitor,
                      boolean writable,
                      boolean step)
Accept a visitor to the current record.

Parameters:
visitor - a visitor object which implements the Visitor interface.
writable - true for writable operation, or false for read-only operation.
step - true to move the cursor to the next record, or false for no move.
Returns:
true on success, or false on failure.
Note:
The operation for each record is performed atomically and other threads accessing the same record are blocked. To avoid deadlock, any explicit database operation must not be performed in this method.

db

public DB db()
Get the database object.

Returns:
the database object.

disable

public void disable()
Disable the cursor.

Note:
This method should be called explicitly when the cursor is no longer in use.

error

public Error error()
Get the last happened error.

Returns:
the last happened error.

finalize

protected void finalize()
Release resources.

Overrides:
finalize in class Object

get_key_str

public String get_key_str(boolean step)
Get the key of the current record. Equal to the original Cursor.get_key method except that the return value is String.

See Also:
get_key(boolean)

get_key

public byte[] get_key(boolean step)
Get the key of the current record.

Parameters:
step - true to move the cursor to the next record, or false for no move.
Returns:
the key of the current record, or null on failure.
Note:
If the cursor is invalidated, null is returned.

get_str

public String[] get_str(boolean step)
Get a pair of the key and the value of the current record. Equal to the original Cursor.get method except that the return value is String.

See Also:
get(boolean)

get_value_str

public String get_value_str(boolean step)
Get the value of the current record. Equal to the original Cursor.get_value method except that the return value is String.

See Also:
get_value(boolean)

get_value

public byte[] get_value(boolean step)
Get the value of the current record.

Parameters:
step - true to move the cursor to the next record, or false for no move.
Returns:
the value of the current record, or null on failure.
Note:
If the cursor is invalidated, null is returned.

get

public byte[][] get(boolean step)
Get a pair of the key and the value of the current record.

Parameters:
step - true to move the cursor to the next record, or false for no move.
Returns:
a pair of the key and the value of the current record, or null on failure.
Note:
If the cursor is invalidated, null is returned.

jump_back

public boolean jump_back()
Jump the cursor to the last record for backward scan.

Returns:
true on success, or false on failure.
Note:
This method is dedicated to tree databases. Some database types, especially hash databases, may provide a dummy implementation.

jump_back

public boolean jump_back(byte[] key)
Jump the cursor to a record for backward scan.

Parameters:
key - the key of the destination record.
Returns:
true on success, or false on failure.
Note:
This method is dedicated to tree databases. Some database types, especially hash databases, may provide a dummy implementation.

jump_back

public boolean jump_back(String key)
Jump the cursor to a record for backward scan. Equal to the original Cursor.jump_back method except that the parameter is String.

See Also:
jump_back(byte[])

jump

public boolean jump()
Jump the cursor to the first record for forward scan.

Returns:
true on success, or false on failure.

jump

public boolean jump(byte[] key)
Jump the cursor to a record for forward scan.

Parameters:
key - the key of the destination record.
Returns:
true on success, or false on failure.

jump

public boolean jump(String key)
Jump the cursor to a record for forward scan. Equal to the original Cursor.jump method except that the parameter is String.

See Also:
jump(byte[])

remove

public boolean remove()
Remove the current record.

Returns:
true on success, or false on failure.
Note:
If no record corresponds to the key, false is returned. The cursor is moved to the next record implicitly.

set_value

public boolean set_value(byte[] value,
                         boolean step)
Set the value of the current record.

Parameters:
value - the value.
step - true to move the cursor to the next record, or false for no move.
Returns:
true on success, or false on failure.

set_value

public boolean set_value(String value,
                         boolean step)
Set the value of the current record. Equal to the original Cursor.set_value method except that the parameter is String.

See Also:
set_value(byte[], boolean)

step_back

public boolean step_back()
Step the cursor to the previous record.

Returns:
true on success, or false on failure.
Note:
This method is dedicated to tree databases. Some database types, especially hash databases, may provide a dummy implementation.

step

public boolean step()
Step the cursor to the next record.

Returns:
true on success, or false on failure.

toString

public String toString()
Get the string expression.

Overrides:
toString in class Object
Returns:
the string expression.