Class EmptyCursor<K,V>
- java.lang.Object
-
- org.opends.server.backends.pluggable.spi.EmptyCursor<K,V>
-
- Type Parameters:
K- Type of the simulated record's keyV- Type of the simulated record's value
- All Implemented Interfaces:
Closeable,AutoCloseable,Cursor<K,V>,SequentialCursor<K,V>
public final class EmptyCursor<K,V> extends Object implements Cursor<K,V>
Implementation of an emptyCursor, for simulating no records to cursor on.Cursor behaves as follows:
- Positioning to a key or index will fail, returning
false. - Reading the key or value will return
null. - Deleting the current element is not supported,
UnsupportedOperationExceptionwill be thrown.
-
-
Constructor Summary
Constructors Constructor Description EmptyCursor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description KgetKey()Returns the key of the record on which this cursor is currently positioned.booleanisValid()Check whether this cursor is currently pointing to a valid record.booleannext()Moves this cursor to the next record in the tree.booleanpositionToIndex(int index)Positions the cursor to the specified index within the tree.booleanpositionToKey(K key)Positions the cursor to the provided key if it exists in the tree.booleanpositionToKeyOrNext(K key)Positions the cursor to the provided key if it exists in the tree, or else the lesser key greater than the provided key in the tree.booleanpositionToLastKey()Positions the cursor to the last key in the tree.booleanprevious()Moves this cursor to the previous record in the tree.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.opends.server.backends.pluggable.spi.SequentialCursor
close, delete, getValue
-
-
-
-
Method Detail
-
positionToKey
public boolean positionToKey(K key)
Description copied from interface:CursorPositions the cursor to the provided key if it exists in the tree.Positioning the cursor is required before calling
SequentialCursor.isValid().- Specified by:
positionToKeyin interfaceCursor<K,V>- Parameters:
key- the key where to position the cursor- Returns:
trueif the cursor could be positioned to the key,falseotherwise
-
positionToKeyOrNext
public boolean positionToKeyOrNext(K key)
Description copied from interface:CursorPositions the cursor to the provided key if it exists in the tree, or else the lesser key greater than the provided key in the tree.Positioning the cursor is required before calling
SequentialCursor.isValid().- Specified by:
positionToKeyOrNextin interfaceCursor<K,V>- Parameters:
key- the key where to position the cursor- Returns:
trueif the cursor could be positioned to the key or the next one,falseotherwise
-
positionToLastKey
public boolean positionToLastKey()
Description copied from interface:CursorPositions the cursor to the last key in the tree.Positioning the cursor is required before calling
SequentialCursor.isValid().- Specified by:
positionToLastKeyin interfaceCursor<K,V>- Returns:
trueif the cursor could be positioned to the last key,falseotherwise
-
positionToIndex
public boolean positionToIndex(int index)
Description copied from interface:CursorPositions the cursor to the specified index within the tree. Implementations may take advantage of optimizations provided by the underlying storage, such as counted B-Trees.Positioning the cursor is required before calling
SequentialCursor.isValid().- Specified by:
positionToIndexin interfaceCursor<K,V>- Parameters:
index- the index where the cursor should be positioned, (0 is the first record).- Returns:
trueif the cursor could be positioned to the index,falseotherwise
-
previous
public boolean previous()
Description copied from interface:CursorMoves this cursor to the previous record in the tree.
-
next
public boolean next()
Description copied from interface:SequentialCursorMoves this cursor to the next record in the tree.No data is available before calling
next()on a new cursor.- Specified by:
nextin interfaceSequentialCursor<K,V>- Returns:
trueif the cursor has moved to the next record,falseif no next record exists leaving cursor in undefined state.
-
isValid
public boolean isValid()
Description copied from interface:SequentialCursorCheck whether this cursor is currently pointing to a valid record.Before calling
isValid()the cursor must be positioned by callingSequentialCursor.next().- Specified by:
isValidin interfaceSequentialCursor<K,V>- Returns:
trueif the cursor is pointing to a valid entry,falseif cursor is not pointing to a valid entry
-
getKey
public K getKey() throws NoSuchElementException
Description copied from interface:SequentialCursorReturns the key of the record on which this cursor is currently positioned.- Specified by:
getKeyin interfaceSequentialCursor<K,V>- Returns:
- the current record's key.
- Throws:
NoSuchElementException- if the cursor is not valid.
-
-