Package org.eclipse.rdf4j.query.impl
Class MutableTupleQueryResult
java.lang.Object
org.eclipse.rdf4j.query.impl.MutableTupleQueryResult
- All Implemented Interfaces:
AutoCloseable,Cloneable,Iterable<BindingSet>,Iterator<BindingSet>,CloseableIteration<BindingSet>,QueryResult<BindingSet>,TupleQueryResult
An implementation of the
TupleQueryResult interface that stores the complete query result in memory. The
query results in a MutableTupleQueryResult can be iterated over multiple times and can also be iterated over in
reverse order.- Author:
- Arjohn Kampman
-
Constructor Summary
ConstructorsConstructorDescriptionMutableTupleQueryResult(Collection<String> bindingNames, Collection<? extends BindingSet> bindingSets) Creates a query result table with the supplied binding names.MutableTupleQueryResult(Collection<String> bindingNames, CloseableIteration<? extends BindingSet> bindingSetIter) MutableTupleQueryResult(Collection<String> bindingNames, BindingSet... bindingSets) -
Method Summary
Modifier and TypeMethodDescriptionvoidMoves the cursor to the end of the query result, just after the last binding set.voidappend(BindingSet bindingSet) voidMoves the cursor to the start of the query result, just before the first binding set.voidclear()clone()voidclose()Closes this iteration, freeing any resources that it is holding.get(int index) Gets the names of the bindings, in order of projection.intgetIndex()booleanhasNext()Returnstrueif the query result has more elements.booleanvoidinsert(int index, BindingSet bindingSet) voidinsert(BindingSet bindingSet) Inserts the specified binding set into the list.next()Returns the next element in the query result.previous()voidremove()remove(int index) set(int index, BindingSet bindingSet) voidset(BindingSet bindingSet) voidsetIndex(int index) intsize()Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface java.util.Iterator
forEachRemainingMethods inherited from interface org.eclipse.rdf4j.query.QueryResult
iterator, stream
-
Constructor Details
-
MutableTupleQueryResult
-
MutableTupleQueryResult
public MutableTupleQueryResult(Collection<String> bindingNames, Collection<? extends BindingSet> bindingSets) Creates a query result table with the supplied binding names. The supplied list of binding names is assumed to be constant; care should be taken that the contents of this list doesn't change after supplying it to this solution.- Parameters:
bindingNames- The binding names, in order of projection.
-
MutableTupleQueryResult
public MutableTupleQueryResult(Collection<String> bindingNames, CloseableIteration<? extends BindingSet> bindingSetIter) throws E - Throws:
E extends Exception
-
MutableTupleQueryResult
- Throws:
QueryEvaluationException
-
-
Method Details
-
getBindingNames
Description copied from interface:TupleQueryResultGets the names of the bindings, in order of projection.- Specified by:
getBindingNamesin interfaceTupleQueryResult- Returns:
- The binding names, in order of projection.
-
size
public int size() -
get
-
getIndex
public int getIndex() -
setIndex
public void setIndex(int index) -
hasNext
public boolean hasNext()Description copied from interface:QueryResultReturnstrueif the query result has more elements. (In other words, returnstrueifQueryResult.next()would return an element rather than throwing aNoSuchElementException.)- Specified by:
hasNextin interfaceIterator<BindingSet>- Specified by:
hasNextin interfaceQueryResult<BindingSet>- Returns:
trueif the iteration has more elements.
-
next
Description copied from interface:QueryResultReturns the next element in the query result.- Specified by:
nextin interfaceIterator<BindingSet>- Specified by:
nextin interfaceQueryResult<BindingSet>- Returns:
- the next element in the query result.
-
hasPrevious
public boolean hasPrevious() -
previous
-
beforeFirst
public void beforeFirst()Moves the cursor to the start of the query result, just before the first binding set. After calling this method, the result can be iterated over from scratch. -
afterLast
public void afterLast()Moves the cursor to the end of the query result, just after the last binding set. -
insert
Inserts the specified binding set into the list. The binding set is inserted immediately before the next element that would be returned bynext(), if any, and after the next element that would be returned byprevious(), if any. (If the table contains no binding sets, the new element becomes the sole element on the table.) The new element is inserted before the implicit cursor: a subsequent call to next() would be unaffected, and a subsequent call to previous() would return the new binding set.- Parameters:
bindingSet- The binding set to insert.
-
insert
-
append
-
set
-
set
-
remove
public void remove()- Specified by:
removein interfaceIterator<BindingSet>
-
remove
-
clear
public void clear() -
close
public void close()Description copied from interface:CloseableIterationCloses this iteration, freeing any resources that it is holding. If the iteration has already been closed then invoking this method has no effect.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseableIteration<BindingSet>
-
clone
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-