T
- public abstract class Cursor<T> extends Object implements AutoCloseable, Iterator<T>
Constructor and Description |
---|
Cursor() |
Modifier and Type | Method and Description |
---|---|
void |
abort()
Aborts execution.
|
<T2> Cursor<T2> |
adapt(com.google.common.base.Function<T,T2> converter) |
List<T> |
allSolutions() |
protected abstract void |
basicAbort() |
protected List<T> |
basicAllSolutions()
The default implementation for obtaining all the solutions consists on just making use of the existing next() method
However, children could override this in case many calls to next() are more expensive that obtaining all the results of the query at once (e.g., a findall/3 query in Prolog)
|
protected abstract void |
basicClose() |
protected abstract T |
basicNext()
Returns the next available element in the cursor.
|
protected T |
basicOneSolutionOrThrow() |
protected List<T> |
basicSolutionsRange(long from,
long to) |
protected T |
cachedNext() |
void |
close() |
Cursor<T> |
filter(com.google.common.base.Predicate<T> predicate) |
void |
finalize() |
CursorState |
getState() |
boolean |
hasNext()
Answers if there are still rows in the cursor.
|
boolean |
hasSolution() |
abstract boolean |
isAbortable() |
boolean |
isExhausted() |
boolean |
isOpen() |
boolean |
isReady() |
protected List<T> |
iterativeAllSolutions() |
T |
next()
Answers the next solution.
|
protected void |
nonSynchronizedClose() |
List<T> |
nSolutions(long n) |
long |
numberOfSolutions() |
com.google.common.base.Optional<T> |
oneSolution() |
T |
oneSolutionOrThrow() |
void |
remove() |
protected void |
setState(CursorState state) |
List<T> |
solutionsRange(long from,
long to) |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
public CursorState getState()
protected void setState(CursorState state)
public long numberOfSolutions()
IllegalStateException
- if the cursor state is not READY.public boolean hasSolution()
IllegalStateException
- if the cursor state is not READY.public com.google.common.base.Optional<T> oneSolution()
IllegalStateException
- if the cursor state is not READY.public T oneSolutionOrThrow()
IllegalStateException
- if the cursor state is not READY.NoSuchElementException
- if there are no solutions to the query.protected T basicOneSolutionOrThrow()
public List<T> nSolutions(long n)
n
- the number of solutions the method should return or until exhaustion of the solutions (whatever happens first).IllegalStateException
- if the cursor state is not READY.public List<T> solutionsRange(long from, long to)
from
- the (0-based) index (inclusive) of the first solutionto
- the (0-based) index (exclusive) of the last solutionIllegalStateException
- if the cursor state is not READY.public List<T> allSolutions()
IllegalStateException
- if the cursor state is not READY.protected List<T> basicAllSolutions()
public boolean isReady()
public boolean isOpen()
public boolean isExhausted()
public void abort()
IllegalStateException
- if the cursor is not open.public abstract boolean isAbortable()
public void close()
close
in interface AutoCloseable
protected void nonSynchronizedClose()
public boolean hasNext()
public T next()
next
in interface Iterator<T>
NoSuchElementException
- if there are no more elements in the cursor.protected T cachedNext()
protected abstract void basicAbort()
protected abstract void basicClose()
protected abstract T basicNext()
Copyright © 2014. All rights reserved.