org.apache.directory.mavibot.btree

## Class TupleCursor<K,V>

- java.lang.Object
- - org.apache.directory.mavibot.btree.TupleCursor<K,V>

- Type Parameters:
    `K` - The type for the Key
    `V` - The type for the stored value
  Direct Known Subclasses:
    EmptyTupleCursor

      public class TupleCursor<K,V>
      extends Object

  A Cursor is used to fetch elements in a BTree and is returned by the
  Author:
    Apache Directory Project
  See Also:
    `method. The cursor must be closed when the user is done with it.

    `

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `depth` The stack's depth
    `protected org.apache.directory.mavibot.btree.ParentPos<K,V>[]` | `stack` The stack of pages from the root down to the leaf
    `protected ReadTransaction<K,V>` | `transaction` The transaction used for this cursor

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `TupleCursor()` Creates a new instance of Cursor.
    `` | `TupleCursor(ReadTransaction<K,V> transaction, org.apache.directory.mavibot.btree.ParentPos<K,V>[] stack, int depth)` Creates a new instance of Cursor, starting on a page at a given position.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterLast()` Change the position in the current cursor to set it after the last key
    `void` | `beforeFirst()` Change the position in the current cursor before the first key
    `void` | `close()`
    `long` | `getCreationDate()` Get the creation date
    `long` | `getRevision()` Get the current revision
    `boolean` | `hasNext()` Tells if the cursor can return a next element
    `boolean` | `hasNextKey()` Tells if the cursor can return a next key
    `boolean` | `hasPrev()` Tells if the cursor can return a previous element
    `boolean` | `hasPrevKey()` Tells if the cursor can return a previous key
    `Tuple<K,V>` | `next()` Find the next key/value
    `Tuple<K,V>` | `nextKey()` Get the next non-duplicate key.
    `Tuple<K,V>` | `prev()` Find the previous key/value
    `Tuple<K,V>` | `prevKey()` Get the previous non-duplicate key.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### stack

          protected org.apache.directory.mavibot.btree.ParentPos<K,V>[] stack

      The stack of pages from the root down to the leaf

    - #### depth

          protected int depth

      The stack's depth

    - #### transaction

          protected ReadTransaction<K,V> transaction

      The transaction used for this cursor

  - ### Constructor Detail

    - #### TupleCursor

          protected TupleCursor()

      Creates a new instance of Cursor.

    - #### TupleCursor

          public TupleCursor(ReadTransaction<K,V> transaction,
                     org.apache.directory.mavibot.btree.ParentPos<K,V>[] stack,
                     int depth)

      Creates a new instance of Cursor, starting on a page at a given position.
      Parameters:
        `transaction` - The transaction this operation is protected by
        `stack` - The stack of parent's from root to this page

  - ### Method Detail

    - #### afterLast

          public void afterLast()
                         throws IOException

      Change the position in the current cursor to set it after the last key
      Throws:
        `IOException`

    - #### beforeFirst

          public void beforeFirst()
                           throws IOException

      Change the position in the current cursor before the first key
      Throws:
        `IOException`

    - #### hasNext

          public boolean hasNext()
                          throws EndOfFileExceededException,
                                 IOException

      Tells if the cursor can return a next element
      Returns:
        true if there are some more elements
      Throws:
        `IOException`
        `EndOfFileExceededException`

    - #### next

          public Tuple<K,V> next()
                          throws EndOfFileExceededException,
                                 IOException

      Find the next key/value
      Returns:
        A Tuple containing the found key and value
      Throws:
        `IOException`
        `EndOfFileExceededException`

    - #### nextKey

          public Tuple<K,V> nextKey()
                             throws EndOfFileExceededException,
                                    IOException

      Get the next non-duplicate key. If the BTree contains :
      - <1,0>
      - <1,1>
      - <1,2>
      - <2,0>
      - <2,1>
      and cursor is present at <1,1> then the returned tuple will be <2,0> (not <1,2>)
      Returns:
        A Tuple containing the found key and value
      Throws:
        `EndOfFileExceededException`
        `IOException`

    - #### hasNextKey

          public boolean hasNextKey()
                             throws EndOfFileExceededException,
                                    IOException

      Tells if the cursor can return a next key
      Returns:
        true if there are some more keys
      Throws:
        `IOException`
        `EndOfFileExceededException`

    - #### hasPrev

          public boolean hasPrev()
                          throws EndOfFileExceededException,
                                 IOException

      Tells if the cursor can return a previous element
      Returns:
        true if there are some more elements
      Throws:
        `IOException`
        `EndOfFileExceededException`

    - #### prev

          public Tuple<K,V> prev()
                          throws EndOfFileExceededException,
                                 IOException

      Find the previous key/value
      Returns:
        A Tuple containing the found key and value
      Throws:
        `IOException`
        `EndOfFileExceededException`

    - #### prevKey

          public Tuple<K,V> prevKey()
                             throws EndOfFileExceededException,
                                    IOException

      Get the previous non-duplicate key. If the BTree contains :
      - <1,0>
      - <1,1>
      - <1,2>
      - <2,0>
      - <2,1>
      and cursor is present at <2,1> then the returned tuple will be <1,0> (not <2,0>)
      Returns:
        A Tuple containing the found key and value
      Throws:
        `EndOfFileExceededException`
        `IOException`

    - #### hasPrevKey

          public boolean hasPrevKey()
                             throws EndOfFileExceededException,
                                    IOException

      Tells if the cursor can return a previous key
      Returns:
        true if there are some more keys
      Throws:
        `IOException`
        `EndOfFileExceededException`

    - #### close

          public void close()

    - #### getCreationDate

          public long getCreationDate()

      Get the creation date
      Returns:
        The creation date for this cursor

    - #### getRevision

          public long getRevision()

      Get the current revision
      Returns:
        The revision this cursor is based on

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2012–2015 Apache Mavibot Project Parent. All rights reserved.