use of org.eclipse.rdf4j.common.iteration.ConvertingIteration in project rdf4j by eclipse.
the class SPARQLConnection method toStatementIteration.
/**
* Converts a {@link TupleQueryResult} resulting from the {@link #EVERYTHING_WITH_GRAPH} to a statement by
* using the respective values from the {@link BindingSet} or (if provided) the ones from the arguments.
*
* @param iter
* the {@link TupleQueryResult}
* @param subj
* the subject {@link Resource} used as input or <code>null</code> if wildcard was used
* @param pred
* the predicate {@link IRI} used as input or <code>null</code> if wildcard was used
* @param obj
* the object {@link Value} used as input or <code>null</code> if wildcard was used
* @return the converted iteration
*/
protected Iteration<Statement, QueryEvaluationException> toStatementIteration(TupleQueryResult iter, final Resource subj, final IRI pred, final Value obj) {
return new ConvertingIteration<BindingSet, Statement, QueryEvaluationException>(iter) {
@Override
protected Statement convert(BindingSet b) throws QueryEvaluationException {
Resource s = subj == null ? (Resource) b.getValue("s") : subj;
IRI p = pred == null ? (IRI) b.getValue("p") : pred;
Value o = obj == null ? b.getValue("o") : obj;
Resource ctx = (Resource) b.getValue("ctx");
return SimpleValueFactory.getInstance().createStatement(s, p, o, ctx);
}
};
}
Aggregations