use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.
the class ValuesHandlerTest method twoVarTwoBlocks.
@Test
public void twoVarTwoBlocks() {
Node n = NodeFactory.createLiteral("hello");
Node nn = NodeFactory.createLiteral("hola");
Node n2 = NodeFactory.createLiteral("there");
Node nn2 = NodeFactory.createLiteral("aqui");
Var v = Var.alloc("x");
Var v2 = Var.alloc("y");
handler.addValueVar(v, null);
handler.addValueVar(v2, null);
handler.addValueRow(Arrays.asList(n, n2));
handler.addValueRow(Arrays.asList(nn, nn2));
handler.build();
List<Var> vars = query.getValuesVariables();
assertEquals(2, vars.size());
assertTrue(vars.contains(v));
assertTrue(vars.contains(v2));
assertNotNull(query.getValuesData());
List<Binding> lb = query.getValuesData();
assertEquals(2, lb.size());
List<Node> ln = new ArrayList<Node>();
ln.add(n);
ln.add(nn);
List<Node> ln2 = new ArrayList<Node>();
ln2.add(n2);
ln2.add(nn2);
for (Binding b : lb) {
assertTrue(b.contains(v));
assertTrue(ln.contains(b.get(v)));
ln.remove(b.get(v));
assertTrue(b.contains(v2));
assertTrue(ln2.contains(b.get(v2)));
ln2.remove(b.get(v2));
}
}
use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.
the class ResultSetStream method nextSolution.
/** Moves onto the next result possibility.
* The returned object is actual the binding for this
* result.
*/
@Override
public QuerySolution nextSolution() {
if (queryExecutionIter == null)
// ( queryExecution != null && ! queryExecution.isActive() ) )
throw new NoSuchElementException(this.getClass() + ".next");
Binding binding = nextBinding();
currentQuerySolution = new ResultBinding(model, binding);
return currentQuerySolution;
}
use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.
the class QueryIter2LoopOnLeft method hasNextBinding.
@Override
protected final boolean hasNextBinding() {
if (slot != null)
return true;
while (getLeft().hasNext()) {
Binding bindingLeft = getLeft().nextBinding();
slot = getNextSlot(bindingLeft);
if (slot != null) {
slot = bindingLeft;
return true;
}
}
getLeft().close();
return false;
}
use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.
the class QueryIterProcessBinding method moveToNextBinding.
/**
* The next acceptable object in the iterator.
*
* @return The next acceptable object.
*/
@Override
public Binding moveToNextBinding() {
if (hasNext()) {
Binding r = nextBinding;
nextBinding = null;
return r;
}
throw new NoSuchElementException();
}
use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.
the class QueryIterProcessBinding method hasNextBinding.
/**
* Are there any more acceptable objects.
*
* @return true if there is another acceptable object.
*/
@Override
protected boolean hasNextBinding() {
// Needs to be idempotent.?
if (isFinished())
return false;
if (nextBinding != null)
return true;
// Null iterator.
if (getInput() == null)
throw new ARQInternalErrorException(Lib.className(this) + ": Null iterator");
while (getInput().hasNext()) {
// Skip forward until a binding to return is found.
Binding input = getInput().nextBinding();
Binding output = accept(input);
if (output != null) {
nextBinding = output;
return true;
}
}
nextBinding = null;
return false;
}
Aggregations