T
- the type of objects that this Search
searches forpublic interface Search<T>
extends java.lang.Cloneable
next()
and previous()
methods to gather the next or previous object of this search. If true
is returned, the next/previous found object can be retrieved by
getCurrentObject()
.Index
Modifier and Type | Method and Description |
---|---|
Search<T> |
clone()
Creates and returns a copy of this search.
|
void |
close()
Closes this search indicating that no objects will be retrieved.
|
T |
getCurrentObject()
Returns the object found by the last search.
|
boolean |
next()
Searches for the next object (forward search) and returns false
if none is found.
|
boolean |
previous()
Searches for the previous object (backward search) and returns false
if none is found.
|
boolean |
skip(int count)
Skips
count objects using next() or previous()
search and returns false if count objects cannot be skipped. |
T getCurrentObject() throws java.lang.IllegalStateException
next()
or previous()
has returned true, this method returns the matching
object. If false has been returned, this method throws an IllegalStateException
.java.lang.IllegalStateException
- if there is no current object (next/previous method was not called or returned false)boolean next() throws java.lang.IllegalStateException
getCurrentObject()
.java.lang.IllegalStateException
- if there was a problem retrieving the next object from the underlying storageboolean previous() throws java.lang.IllegalStateException
getCurrentObject()
.java.lang.IllegalStateException
- if there was a problem retrieving the next object from the underlying storageboolean skip(int count) throws java.lang.IllegalStateException
count
objects using next()
or previous()
search and returns false if count
objects cannot be skipped.
Otherwise, the found object can be retrieved by getCurrentObject()
.
Note that this is equivalent to calling next()
or previous()
while true is returned up to count
times. So if the
method returns false, the getCurrentObject()
may not return
a valid object.
count
- number of objects to skip,
i.e. the number of calls to next()
if count is positive
or previous()
if count is negativecount
objects has been skippedjava.lang.IllegalStateException
- if there was a problem retrieving the next/previous object from the underlying storageSearch<T> clone() throws java.lang.CloneNotSupportedException
next()
or previous()
will return the same values as for the original search.
In practice, the cloned search is often used to do the search in both directions from the same starting point.
java.lang.CloneNotSupportedException
- if this search cannot be clonedvoid close()
next()
, previous()
, etc.) should not be called.