Package com.coyotegulch.jisp
Class BTreeIterator
java.lang.Object
com.coyotegulch.jisp.BTreeIterator
- All Implemented Interfaces:
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:
-
Constructor Summary
ConstructorsConstructorDescriptionBTreeIterator
(BTreeIndex index) Creates a newBTreeIterator
for a given index and database.BTreeIterator
(BTreeIterator iterator) Creates a newBTreeIterator
that points to the same location as an existingBtreeIterator
. -
Method Summary
Modifier and TypeMethodDescriptiongetKey()
Returns the keyObject
currently associated with this iterator.long
Returns the reference (usually a file pointer) currently associated with this iterator.void
Sets this iterator's state to invalid.boolean
isValid()
Checks to see if this iterator is valid.boolean
Moves this iterator to the first key and reference in sequence.boolean
moveLast()
Moves this iterator to the last key and reference in sequence.boolean
moveNext()
Moves this iterator to the next key and reference in sequence.boolean
Moves this iterator to the previous key and reference in sequence.boolean
Moves this iterator to point to the givenkey
.boolean
Moves this iterator to point to the givenkey
.
-
Constructor Details
-
BTreeIterator
Creates a newBTreeIterator
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.* classClassNotFoundException
- for a casting error, usually when a persistent object or index does match the expected type- See Also:
-
BTreeIterator
Creates a newBTreeIterator
that points to the same location as an existingBtreeIterator
.- Parameters:
iterator
- the iterator to be copied.- Throws:
IOException
- when an I/O exception is thrown by an underlying java.io.* classClassNotFoundException
- for a casting error, usually when a persistent object or index does match the expected type- See Also:
-
-
Method Details
-
getRecPtr
Returns the reference (usually a file pointer) currently associated with this iterator.- Specified by:
getRecPtr
in interfaceIndexIterator
- Returns:
- the record
Object
currently referenced by this iterator, or -1 if the iterator is invalid - Throws:
IOException
-
getKey
Returns the keyObject
currently associated with this iterator.- Specified by:
getKey
in interfaceIndexIterator
- 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
-
moveNext
Moves this iterator to the next key and reference in sequence.- Specified by:
moveNext
in interfaceIndexIterator
- Returns:
true
if the operation was successful;false
otherwise.- Throws:
IOException
- when an I/O exception is thrown by an underlying java.io.* classClassNotFoundException
- for a casting error, usually when a persistent object or index does match the expected type
-
movePrevious
Moves this iterator to the previous key and reference in sequence.- Specified by:
movePrevious
in interfaceIndexIterator
- Returns:
true
if the operation was successful;false
otherwise.- Throws:
IOException
- when an I/O exception is thrown by an underlying java.io.* classClassNotFoundException
- for a casting error, usually when a persistent object or index does match the expected typeBTreeException
- when an error occurs during B-Tree processing
-
moveFirst
Moves this iterator to the first key and reference in sequence.- Specified by:
moveFirst
in interfaceIndexIterator
- Returns:
true
if the operation was successful;false
otherwise.- Throws:
IOException
- when an I/O exception is thrown by an underlying java.io.* classClassNotFoundException
- for a casting error, usually when a persistent object or index does match the expected typeBTreeException
- when an error occurs during B-Tree processing
-
moveLast
Moves this iterator to the last key and reference in sequence.- Specified by:
moveLast
in interfaceIndexIterator
- Returns:
true
if the operation was successful;false
otherwise.- Throws:
IOException
- when an I/O exception is thrown by an underlying java.io.* classClassNotFoundException
- for a casting error, usually when a persistent object or index does match the expected typeBTreeException
- when an error occurs during B-Tree processing
-
moveTo
Moves this iterator to point to the givenkey
.- Specified by:
moveTo
in interfaceIndexIterator
- 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.* classClassNotFoundException
- for a casting error, usually when a persistent object or index does match the expected typeBTreeException
- when an error occurs during B-Tree processing
-
moveTo
Moves this iterator to point to the givenkey
.- Specified by:
moveTo
in interfaceIndexIterator
- Parameters:
key
- key identifier to findacceptNext
- 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.* classClassNotFoundException
- for a casting error, usually when a persistent object or index does match the expected typeBTreeException
- when an error occurs during B-Tree processing
-
isValid
public boolean isValid()Checks to see if this iterator is valid.- Specified by:
isValid
in interfaceIndexIterator
- Returns:
true
if the iterator is valid;false
if it is invalid.
-
invalidate
public void invalidate()Sets this iterator's state to invalid.
-