public void endRDF()
throws RDFHandlerException
{
Set<Resource> resultSetNodes = model.filter(null, RDF.TYPE, RESULTSET).subjects();
if (resultSetNodes.size() != 1) {
throw new RDFHandlerException("Expected 1 subject of type ResultSet, found: "
+ resultSetNodes.size());
}
Resource resultSetNode = resultSetNodes.iterator().next();
try {
List<String> bindingNames = getBindingNames(resultSetNode);
tqrHandler.startQueryResult(bindingNames);
for (Value solutionNode : model.filter(resultSetNode, SOLUTION, null).objects()) {
if (solutionNode instanceof Resource) {
reportSolution((Resource)solutionNode, bindingNames);
}
else {
throw new RDFHandlerException("Value for " + SOLUTION + " is not a resource: " + solutionNode);
}
}
tqrHandler.endQueryResult();
}
catch (TupleQueryResultHandlerException e) {
throw new RDFHandlerException(e.getMessage(), e);
}
}