use of org.eclipse.rdf4j.query.TupleQueryResultHandlerException in project rdf4j by eclipse.
the class DAWGTestResultSetParser method reportSolution.
private void reportSolution(Resource solutionNode, List<String> bindingNames) throws RDFHandlerException, GraphUtilException {
MapBindingSet bindingSet = new MapBindingSet(bindingNames.size());
Iterator<Value> bindingIter = GraphUtil.getObjectIterator(graph, solutionNode, BINDING);
while (bindingIter.hasNext()) {
Value bindingNode = bindingIter.next();
if (bindingNode instanceof Resource) {
Binding binding = getBinding((Resource) bindingNode);
bindingSet.addBinding(binding);
} else {
throw new RDFHandlerException("Value for " + BINDING + " is not a resource: " + bindingNode);
}
}
try {
tqrHandler.handleSolution(bindingSet);
} catch (TupleQueryResultHandlerException e) {
throw new RDFHandlerException(e.getMessage(), e);
}
}
use of org.eclipse.rdf4j.query.TupleQueryResultHandlerException in project rdf4j by eclipse.
the class DAWGTestResultSetUtil method toGraph.
public static Graph toGraph(TupleQueryResult tqr) throws QueryEvaluationException {
Graph graph = new GraphImpl();
DAWGTestResultSetWriter writer = new DAWGTestResultSetWriter(new StatementCollector(graph));
try {
writer.startQueryResult(tqr.getBindingNames());
while (tqr.hasNext()) {
writer.handleSolution(tqr.next());
}
writer.endQueryResult();
} catch (TupleQueryResultHandlerException e) {
// StatementCollector, foud a bug?
throw new RuntimeException(e);
}
return graph;
}
use of org.eclipse.rdf4j.query.TupleQueryResultHandlerException in project rdf4j by eclipse.
the class DAWGTestResultSetWriter method startQueryResult.
/*---------*
* Methods *
*---------*/
@Override
public void startQueryResult(List<String> bindingNames) throws TupleQueryResultHandlerException {
try {
rdfHandler.startRDF();
resultSetNode = vf.createBNode();
bnodeMap.clear();
reportStatement(resultSetNode, RDF.TYPE, RESULTSET);
for (String bindingName : bindingNames) {
Literal bindingNameLit = vf.createLiteral(bindingName);
reportStatement(resultSetNode, RESULTVARIABLE, bindingNameLit);
}
} catch (RDFHandlerException e) {
throw new TupleQueryResultHandlerException(e);
}
}
use of org.eclipse.rdf4j.query.TupleQueryResultHandlerException in project rdf4j by eclipse.
the class BinaryQueryResultWriter method startDocument.
@Override
public void startDocument() throws TupleQueryResultHandlerException {
documentStarted = true;
try {
out.write(MAGIC_NUMBER);
out.writeInt(FORMAT_VERSION);
} catch (IOException e) {
throw new TupleQueryResultHandlerException(e);
}
}
use of org.eclipse.rdf4j.query.TupleQueryResultHandlerException in project rdf4j by eclipse.
the class BinaryQueryResultWriter method endQueryResult.
@Override
public void endQueryResult() throws TupleQueryResultHandlerException {
if (!tupleVariablesFound) {
throw new IllegalStateException("Could not end query result as startQueryResult was not called first.");
}
try {
out.writeByte(TABLE_END_RECORD_MARKER);
endDocument();
} catch (IOException e) {
throw new TupleQueryResultHandlerException(e);
}
}
Aggregations