Package org.eclipse.rdf4j.query.impl
Class MutableTupleQueryResult
- java.lang.Object
-
- org.eclipse.rdf4j.query.impl.MutableTupleQueryResult
-
- All Implemented Interfaces:
java.lang.AutoCloseable,java.lang.Cloneable,java.lang.Iterable<BindingSet>,CloseableIteration<BindingSet,QueryEvaluationException>,Iteration<BindingSet,QueryEvaluationException>,QueryResult<BindingSet>,TupleQueryResult
public class MutableTupleQueryResult extends java.lang.Object implements TupleQueryResult, java.lang.Cloneable
An implementation of theTupleQueryResultinterface 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.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<java.lang.String>bindingNamesprivate java.util.List<BindingSet>bindingSetsprivate intcurrentIndexThe index of the next element that will be returned by a call tonext().private intlastReturnedThe index of the last element that was returned by a call tonext()orprevious().
-
Constructor Summary
Constructors Constructor Description MutableTupleQueryResult(java.util.Collection<java.lang.String> bindingNames, java.util.Collection<? extends BindingSet> bindingSets)Creates a query result table with the supplied binding names.MutableTupleQueryResult(java.util.Collection<java.lang.String> bindingNames, CloseableIteration<? extends BindingSet,E> bindingSetIter)MutableTupleQueryResult(java.util.Collection<java.lang.String> bindingNames, Iteration<? extends BindingSet,E> bindingSetIter)Deprecated, for removal: This API element is subject to removal in a future version.MutableTupleQueryResult(java.util.Collection<java.lang.String> bindingNames, BindingSet... bindingSets)MutableTupleQueryResult(TupleQueryResult tqr)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterLast()Moves the cursor to the end of the query result, just after the last binding set.voidappend(BindingSet bindingSet)voidbeforeFirst()Moves the cursor to the start of the query result, just before the first binding set.voidclear()MutableTupleQueryResultclone()voidclose()Closes this iteration, freeing any resources that it is holding.BindingSetget(int index)java.util.List<java.lang.String>getBindingNames()Gets the names of the bindings, in order of projection.intgetIndex()booleanhasNext()Returnstrueif the query result has more elements.booleanhasPrevious()voidinsert(int index, BindingSet bindingSet)voidinsert(BindingSet bindingSet)Inserts the specified binding set into the list.BindingSetnext()Returns the next element in the query result.BindingSetprevious()voidremove()Removes from the underlying collection the last element returned by the iteration (optional operation).BindingSetremove(int index)BindingSetset(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, wait
-
Methods inherited from interface org.eclipse.rdf4j.query.QueryResult
iterator, stream
-
-
-
-
Field Detail
-
bindingNames
private final java.util.Set<java.lang.String> bindingNames
-
bindingSets
private final java.util.List<BindingSet> bindingSets
-
currentIndex
private int currentIndex
The index of the next element that will be returned by a call tonext().
-
lastReturned
private int lastReturned
The index of the last element that was returned by a call tonext()orprevious(). Equal to -1 if there is no such element.
-
-
Constructor Detail
-
MutableTupleQueryResult
public MutableTupleQueryResult(java.util.Collection<java.lang.String> bindingNames, BindingSet... bindingSets)
-
MutableTupleQueryResult
public MutableTupleQueryResult(java.util.Collection<java.lang.String> bindingNames, java.util.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
@Deprecated(since="4.1.0", forRemoval=true) public MutableTupleQueryResult(java.util.Collection<java.lang.String> bindingNames, Iteration<? extends BindingSet,E> bindingSetIter) throws E extends java.lang.ExceptionDeprecated, for removal: This API element is subject to removal in a future version.- Throws:
E extends java.lang.Exception
-
MutableTupleQueryResult
public MutableTupleQueryResult(java.util.Collection<java.lang.String> bindingNames, CloseableIteration<? extends BindingSet,E> bindingSetIter) throws E extends java.lang.Exception- Throws:
E extends java.lang.Exception
-
MutableTupleQueryResult
public MutableTupleQueryResult(TupleQueryResult tqr) throws QueryEvaluationException
- Throws:
QueryEvaluationException
-
-
Method Detail
-
getBindingNames
public java.util.List<java.lang.String> 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
public BindingSet get(int index)
-
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 interfaceIteration<BindingSet,QueryEvaluationException>- Specified by:
hasNextin interfaceQueryResult<BindingSet>- Returns:
trueif the iteration has more elements.
-
next
public BindingSet next()
Description copied from interface:QueryResultReturns the next element in the query result.- Specified by:
nextin interfaceIteration<BindingSet,QueryEvaluationException>- Specified by:
nextin interfaceQueryResult<BindingSet>- Returns:
- the next element in the query result.
-
hasPrevious
public boolean hasPrevious()
-
previous
public BindingSet 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
public void insert(BindingSet bindingSet)
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
public void insert(int index, BindingSet bindingSet)
-
append
public void append(BindingSet bindingSet)
-
set
public void set(BindingSet bindingSet)
-
set
public BindingSet set(int index, BindingSet bindingSet)
-
remove
public void remove()
Description copied from interface:IterationRemoves from the underlying collection the last element returned by the iteration (optional operation). This method can be called only once per call to next.- Specified by:
removein interfaceIteration<BindingSet,QueryEvaluationException>
-
remove
public BindingSet remove(int index)
-
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 interfacejava.lang.AutoCloseable- Specified by:
closein interfaceCloseableIteration<BindingSet,QueryEvaluationException>
-
clone
public MutableTupleQueryResult clone() throws java.lang.CloneNotSupportedException
- Overrides:
clonein classjava.lang.Object- Throws:
java.lang.CloneNotSupportedException
-
-