public class RepositoryResult<T> extends AbstractCloseableIteration<T,RepositoryException> implements Iterable<T>
Statement
,
Namespace
, or Resource
objects) that can be iterated
over. It keeps an open connection to the backend for lazy retrieval of individual results. Additionally it has some
utility methods to fetch all results and add them to a collection.
By default, a RepositoryResult is not necessarily a (mathematical) set: it may contain duplicate objects. Duplicate
filtering can be switched on
, but this should not be used lightly as the filtering
mechanism is potentially memory-intensive.
A RepositoryResult needs to be closed
after use to free up any resources (open connections, read
locks, etc.) it has on the underlying repository.
Constructor and Description |
---|
RepositoryResult(CloseableIteration<? extends T,RepositoryException> iter) |
Modifier and Type | Method and Description |
---|---|
<C extends Collection<T>> |
addTo(C collection)
Deprecated.
Use
Iterations.addAll(Iteration, Collection) instead. |
List<T> |
asList()
Deprecated.
Use
Iterations.asList(Iteration) instead. |
void |
enableDuplicateFilter()
Switches on duplicate filtering while iterating over objects.
|
protected void |
handleClose()
Called by
AbstractCloseableIteration.close() when it is called for the first time. |
boolean |
hasNext()
Returns true if the iteration has more elements.
|
Iterator<T> |
iterator() |
T |
next()
Returns the next element in the iteration.
|
void |
remove()
Removes from the underlying collection the last element returned by the iteration (optional operation).
|
close, isClosed
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public RepositoryResult(CloseableIteration<? extends T,RepositoryException> iter)
public boolean hasNext() throws RepositoryException
Iteration
Iteration.next()
would return an element rather than throwing a NoSuchElementException.)hasNext
in interface Iteration<T,RepositoryException>
RepositoryException
public T next() throws RepositoryException
Iteration
next
in interface Iteration<T,RepositoryException>
RepositoryException
public void remove() throws RepositoryException
Iteration
remove
in interface Iteration<T,RepositoryException>
RepositoryException
protected void handleClose() throws RepositoryException
AbstractCloseableIteration
AbstractCloseableIteration.close()
when it is called for the first time. This method is only called once on each iteration.
By default, this method does nothing.handleClose
in class AbstractCloseableIteration<T,RepositoryException>
RepositoryException
public void enableDuplicateFilter() throws RepositoryException
Set
and on calling next() or hasNext() will ignore any objects
that already occur in this Set.
Caution: use of this filtering mechanism is potentially memory-intensive.
RepositoryException
- if a problem occurred during initialization of the filter.@Deprecated public List<T> asList() throws RepositoryException
Iterations.asList(Iteration)
instead.List
containing all objects of this RepositoryResult in order of iteration. The
RepositoryResult is fully consumed and automatically closed by this operation.
Note: use this method with caution! It pulls the entire RepositoryResult in memory and as such is potentially very memory-intensive.
RepositoryException
- if a problem occurred during retrieval of the results.addTo(Collection)
@Deprecated public <C extends Collection<T>> C addTo(C collection) throws RepositoryException
Iterations.addAll(Iteration, Collection)
instead.RepositoryException
- if a problem occurred during retrieval of the results.Copyright © 2015-2022 Eclipse Foundation. All Rights Reserved.