public void removeBinding(String name) { delegate.removeBinding(name); }
public void removeBinding(String name) { query.removeBinding(name); }
public void removeBinding(String name) { query.removeBinding(name); }
public CloseableIteration<BindingSet, QueryEvaluationException> evaluate( Dataset dataset, BindingSet bindings) throws QueryEvaluationException { if (query == null) { return null; } try { synchronized (query) { for (String name : variables.keySet()) { if (bindings.hasBinding(name)) { Value value = bindings.getValue(name); query.setBinding(variables.get(name), value); } else { query.removeBinding(variables.get(name)); } } query.setDataset(dataset); TupleQueryResult result = query.evaluate(); return new InsertBindingSetCursor(result, bindings); } } catch (IllegalArgumentException e) { // query does not support BNode bindings return null; } }
public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Dataset dataset, BindingSet bindings) throws QueryEvaluationException { CloseableIteration<BindingSet, QueryEvaluationException> rval = null; if (query != null) { try { synchronized (query) { for (String name : variables.keySet()) { if (bindings.hasBinding(name)) { Value value = bindings.getValue(name); query.setBinding(variables.get(name), value); } else { query.removeBinding(variables.get(name)); } } query.setDataset(dataset); TupleQueryResult result = query.evaluate(); rval = new InsertBindingSetCursor(result, bindings); } } catch (IllegalArgumentException e) { // NOPMD // query does not support BNode bindings } } return rval; }
@Test public void testTupleQueryBindings() throws Exception { final TupleQuery tq = con.prepareTupleQuery(QueryLanguage.SPARQL, "select * where {?s ?p ?o}"); tq.setBinding("s", s); tq.setBinding("p", p); tq.setBinding("o", o); { assertEquals(s,tq.getBindings().getBinding("s").getValue()); assertEquals(p,tq.getBindings().getBinding("p").getValue()); assertEquals(o,tq.getBindings().getBinding("o").getValue()); tq.removeBinding("o"); assertFalse(tq.getBindings().hasBinding("o")); TupleQueryResult tqr = tq.evaluate(); try { assertEquals(EncodeDecodeValue.encodeValue(s),remote.data.opts.getRequestParam("$s")); assertEquals(EncodeDecodeValue.encodeValue(p),remote.data.opts.getRequestParam("$p")); assertEquals(null,remote.data.opts.getRequestParam("$o")); assertEquals(EncodeDecodeValue.encodeValue(s),remote.data.request.getParams().get("$s").getValue()); assertEquals(EncodeDecodeValue.encodeValue(p),remote.data.request.getParams().get("$p").getValue()); assertEquals(null,remote.data.request.getParams().get("$o")); } finally { tqr.close(); } tq.clearBindings(); assertEquals(0,tq.getBindings().size()); } }