Package tkrzw

Class Iterator

Object
Iterator

public class Iterator extends Object
Iterator for each record.
Note:
An iterator is made by the "makeIterator" method of DBM. Every unused iterator object should be destructed explicitly by the "destruct" method to free resources.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Destructs the object and releases resources.
    Initializes the iterator to indicate the first record.
    byte[][]
    get()
    Gets the key and the value of the current record of the iterator, witout status assingment.
    byte[][]
    get(Status status)
    Gets the key and the value of the current record of the iterator.
    byte[]
    Gets the key of the current record.
    Gets the key of the current record, as string data.
    Gets the key and the value of the current record, as string data, without status assignemnt.
    getString(Status status)
    Gets the key and the value of the current record, as string data.
    byte[]
    Gets the key of the current record.
    Gets the key of the current record, as string data.
    jump(byte[] key)
    Initializes the iterator to indicate a specific record.
    jump(String key)
    Initializes the iterator to indicate a specific record, with string data.
    jumpLower(byte[] key, boolean inclusive)
    Initializes the iterator to indicate the last record whose key is lower than a given key.
    jumpLower(String key, boolean inclusive)
    Initializes the iterator to indicate the last record whose key is lower, with string data.
    jumpUpper(byte[] key, boolean inclusive)
    Initializes the iterator to indicate the first record whose key is upper than a given key.
    jumpUpper(String key, boolean inclusive)
    Initializes the iterator to indicate the first record whose key is upper, with string data.
    Initializes the iterator to indicate the last record.
    Moves the iterator to the next record.
    Moves the iterator to the previous record.
    Removes the current record.
    set(byte[] value)
    Sets the value of the current record.
    set(String value)
    Sets the value of the current record, with string data.
    byte[][]
    Gets the current record and moves the iterator to the next record, witout status assingment.
    byte[][]
    step(Status status)
    Gets the current record and moves the iterator to the next record.
    Gets the current record and moves the iterator to the next record, as string data.
    Gets the current record and moves the iterator to the next record, as string data.
    Gets a string representation of the iterator.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details

    • destruct

      public void destruct()
      Destructs the object and releases resources.
    • first

      public Status first()
      Initializes the iterator to indicate the first record.
      Returns:
      The result status.
      Note:
      Even if there's no record, the operation doesn't fail.
    • last

      public Status last()
      Initializes the iterator to indicate the last record.
      Returns:
      The result status.
      Note:
      Even if there's no record, the operation doesn't fail. This method is suppoerted only by ordered databases.
    • jump

      public Status jump(byte[] key)
      Initializes the iterator to indicate a specific record.
      Parameters:
      key - The key of the record to look for.
      Returns:
      The result status.
      Note:
      Ordered databases can support "lower bound" jump; If there's no record with the same key, the iterator refers to the first record whose key is greater than the given key. The operation fails with unordered databases if there's no record with the same key.
    • jump

      public Status jump(String key)
      Initializes the iterator to indicate a specific record, with string data.
      Parameters:
      key - The key of the record to look for.
      Returns:
      The result status.
      Note:
      Ordered databases can support "lower bound" jump; If there's no record with the same key, the iterator refers to the first record whose key is greater than the given key. The operation fails with unordered databases if there's no record with the same key.
    • jumpLower

      public Status jumpLower(byte[] key, boolean inclusive)
      Initializes the iterator to indicate the last record whose key is lower than a given key.
      Parameters:
      key - The key to compare with.
      inclusive - If true, the considtion is inclusive: equal to or lower than the key.
      Returns:
      The result status.
      Note:
      Even if there's no matching record, the operation doesn't fail. This method is suppoerted only by ordered databases.
    • jumpLower

      public Status jumpLower(String key, boolean inclusive)
      Initializes the iterator to indicate the last record whose key is lower, with string data.
      Parameters:
      key - The key to compare with.
      inclusive - If true, the considtion is inclusive: equal to or lower than the key.
      Returns:
      The result status.
      Note:
      Even if there's no matching record, the operation doesn't fail. This method is suppoerted only by ordered databases.
    • jumpUpper

      public Status jumpUpper(byte[] key, boolean inclusive)
      Initializes the iterator to indicate the first record whose key is upper than a given key.
      Parameters:
      key - The key to compare with.
      inclusive - If true, the considtion is inclusive: equal to or upper than the key.
      Returns:
      The result status.
      Note:
      Even if there's no matching record, the operation doesn't fail. This method is suppoerted only by ordered databases.
    • jumpUpper

      public Status jumpUpper(String key, boolean inclusive)
      Initializes the iterator to indicate the first record whose key is upper, with string data.
      Parameters:
      key - The key to compare with.
      inclusive - If true, the considtion is inclusive: equal to or upper than the key.
      Returns:
      The result status.
      Note:
      Even if there's no matching record, the operation doesn't fail. This method is suppoerted only by ordered databases.
    • next

      public Status next()
      Moves the iterator to the next record.
      Returns:
      The result status.
      Note:
      If the current record is missing, the operation fails. Even if there's no next record, the operation doesn't fail.
    • previous

      public Status previous()
      Moves the iterator to the previous record.
      Returns:
      The result status.
      Note:
      If the current record is missing, the operation fails. Even if there's no previous record, the operation doesn't fail. This method is suppoerted only by ordered databases.
    • get

      public byte[][] get(Status status)
      Gets the key and the value of the current record of the iterator.
      Parameters:
      status - The status object to store the result status. If it is null, it is ignored.
      Returns:
      A pair of the key and the value of the current record, or null on failure.
    • get

      public byte[][] get()
      Gets the key and the value of the current record of the iterator, witout status assingment.
      Returns:
      A pair of the key and the value of the current record, or null on failure.
    • getString

      public String[] getString(Status status)
      Gets the key and the value of the current record, as string data.
      Parameters:
      status - The status object to store the result status. If it is null, it is ignored.
      Returns:
      A pair of the key and the value of the current record, or null on failure.
    • getString

      public String[] getString()
      Gets the key and the value of the current record, as string data, without status assignemnt.
      Returns:
      A pair of the key and the value of the current record, or null on failure.
    • getKey

      public byte[] getKey()
      Gets the key of the current record.
      Returns:
      The key of the current record, or null on failure.
    • getKeyString

      public String getKeyString()
      Gets the key of the current record, as string data.
      Returns:
      The key of the current record, or null on failure.
    • getValue

      public byte[] getValue()
      Gets the key of the current record.
      Returns:
      The key of the current record, or null on failure.
    • getValueString

      public String getValueString()
      Gets the key of the current record, as string data.
      Returns:
      The key of the current record, or null on failure.
    • set

      public Status set(byte[] value)
      Sets the value of the current record.
      Parameters:
      value - The value of the record.
      Returns:
      The result status.
    • set

      public Status set(String value)
      Sets the value of the current record, with string data.
      Parameters:
      value - The value of the record.
      Returns:
      The result status.
    • remove

      public Status remove()
      Removes the current record.
      Returns:
      The result status.
      Note:
      If possible, the iterator moves to the next record.
    • step

      public byte[][] step(Status status)
      Gets the current record and moves the iterator to the next record.
      Parameters:
      status - The status object to store the result status. If it is null, it is ignored.
      Returns:
      A pair of the key and the value of the current record, or null on failure.
    • step

      public byte[][] step()
      Gets the current record and moves the iterator to the next record, witout status assingment.
      Returns:
      A pair of the key and the value of the current record, or null on failure.
    • stepString

      public String[] stepString(Status status)
      Gets the current record and moves the iterator to the next record, as string data.
      Parameters:
      status - The status object to store the result status. If it is null, it is ignored.
      Returns:
      A pair of the key and the value of the current record, or null on failure.
    • stepString

      public String[] stepString()
      Gets the current record and moves the iterator to the next record, as string data.
      Returns:
      A pair of the key and the value of the current record, or null on failure.
    • toString

      public String toString()
      Gets a string representation of the iterator.
      Overrides:
      toString in class Object