com.coyotegulch.jisp

Class BTreeIterator

public class BTreeIterator extends Object implements IndexIterator

BTreeIterator defines an object that references a specific object relative to other objects in an ObjectIndex. In many ways, a BTreeIterator is analogous to the "cursors" found in SQL-type databases; it is essentially a movable reference to elements in an index, and it can be moved forward and backward through the list of keys.

See Also: ObjectIndex IndexedObjectDatabase

Constructor Summary
BTreeIterator(BTreeIndex index)
Creates a new BTreeIterator for a given index and database.
BTreeIterator(BTreeIterator iterator)
Creates a new BTreeIterator that points to the same location as an existing BtreeIterator.
Method Summary
ObjectgetKey()
Returns the key Object currently associated with this iterator.
longgetRecPtr()
Returns the reference (usually a file pointer) currently associated with this iterator.
voidinvalidate()
Sets this iterator's state to invalid.
booleanisValid()
Checks to see if this iterator is valid.
booleanmoveFirst()
Moves this iterator to the first key and reference in sequence.
booleanmoveLast()
Moves this iterator to the last key and reference in sequence.
booleanmoveNext()
Moves this iterator to the next key and reference in sequence.
booleanmovePrevious()
Moves this iterator to the previous key and reference in sequence.
booleanmoveTo(KeyObject key)
Moves this iterator to point to the given key.
booleanmoveTo(KeyObject key, boolean acceptNext)
Moves this iterator to point to the given key.

Constructor Detail

BTreeIterator

public BTreeIterator(BTreeIndex index)
Creates a new BTreeIterator for a given index and database.

Parameters: index the index to which this iterator is attached.

Throws: IOException when an I/O exception is thrown by an underlying java.io.* class ClassNotFoundException for a casting error, usually when a persistent object or index does match the expected type

See Also: BTreeIndex

BTreeIterator

public BTreeIterator(BTreeIterator iterator)
Creates a new BTreeIterator that points to the same location as an existing BtreeIterator.

Parameters: iterator the iterator to be copied.

Throws: IOException when an I/O exception is thrown by an underlying java.io.* class ClassNotFoundException for a casting error, usually when a persistent object or index does match the expected type

See Also: BTreeIndex

Method Detail

getKey

public Object getKey()
Returns the key Object currently associated with this iterator.

Returns: the key Object currently referenced by this iterator, or null if the iterator is invalid

Throws: IOException when an I/O exception is thrown by an underlying java.io.* class

getRecPtr

public long getRecPtr()
Returns the reference (usually a file pointer) currently associated with this iterator.

Returns: the record Object currently referenced by this iterator, or -1 if the iterator is invalid

invalidate

public void invalidate()
Sets this iterator's state to invalid.

isValid

public boolean isValid()
Checks to see if this iterator is valid.

Returns: true if the iterator is valid; false if it is invalid.

moveFirst

public boolean moveFirst()
Moves this iterator to the first key and reference in sequence.

Returns: true if the operation was successful; false otherwise.

Throws: IOException when an I/O exception is thrown by an underlying java.io.* class ClassNotFoundException for a casting error, usually when a persistent object or index does match the expected type BTreeException when an error occurs during B-Tree processing

moveLast

public boolean moveLast()
Moves this iterator to the last key and reference in sequence.

Returns: true if the operation was successful; false otherwise.

Throws: IOException when an I/O exception is thrown by an underlying java.io.* class ClassNotFoundException for a casting error, usually when a persistent object or index does match the expected type BTreeException when an error occurs during B-Tree processing

moveNext

public boolean moveNext()
Moves this iterator to the next key and reference in sequence.

Returns: true if the operation was successful; false otherwise.

Throws: IOException when an I/O exception is thrown by an underlying java.io.* class ClassNotFoundException for a casting error, usually when a persistent object or index does match the expected type

movePrevious

public boolean movePrevious()
Moves this iterator to the previous key and reference in sequence.

Returns: true if the operation was successful; false otherwise.

Throws: IOException when an I/O exception is thrown by an underlying java.io.* class ClassNotFoundException for a casting error, usually when a persistent object or index does match the expected type BTreeException when an error occurs during B-Tree processing

moveTo

public boolean moveTo(KeyObject key)
Moves this iterator to point to the given key.

Parameters: key key identifier to find

Returns: true if the operation was successful; false otherwise.

Throws: IOException when an I/O exception is thrown by an underlying java.io.* class ClassNotFoundException for a casting error, usually when a persistent object or index does match the expected type BTreeException when an error occurs during B-Tree processing

moveTo

public boolean moveTo(KeyObject key, boolean acceptNext)
Moves this iterator to point to the given key.

Parameters: key key identifier to find acceptNext when true, allows the search to return the next record in sequence if an exact match is not found

Returns: true if the operation was successful; false otherwise.

Throws: IOException when an I/O exception is thrown by an underlying java.io.* class ClassNotFoundException for a casting error, usually when a persistent object or index does match the expected type BTreeException when an error occurs during B-Tree processing