@Override public void startDocument() throws TupleQueryResultHandlerException { documentStarted = true; try { out.write(MAGIC_NUMBER); out.writeInt(FORMAT_VERSION); } catch (IOException e) { throw new TupleQueryResultHandlerException(e); } }
response.sendError(SC_INTERNAL_SERVER_ERROR, "Serialization error: " + e.getMessage());
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); } }
@Override public void startDocument() throws TupleQueryResultHandlerException { documentStarted = true; try { out.write(MAGIC_NUMBER); out.writeInt(FORMAT_VERSION); } catch (IOException e) { throw new TupleQueryResultHandlerException(e); } }
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); } }
@Override public void startDocument() throws TupleQueryResultHandlerException { documentStarted = true; try { out.write(MAGIC_NUMBER); out.writeInt(FORMAT_VERSION); } catch (IOException e) { throw new TupleQueryResultHandlerException(e); } }
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); } }
@Override public void endQueryResult() throws TupleQueryResultHandlerException { if (bindingNames == null) { throw new IllegalStateException( "Could not end query result as startQueryResult was not called first."); } try { writer.flush(); } catch (IOException e) { throw new TupleQueryResultHandlerException(e); } }
@Override public void endRDF() throws RDFHandlerException { try { Resource resultSetNode = GraphUtil.getUniqueSubject(graph, RDF.TYPE, RESULTSET); List<String> bindingNames = getBindingNames(resultSetNode); tqrHandler.startQueryResult(bindingNames); Iterator<Value> solIter = GraphUtil.getObjectIterator(graph, resultSetNode, SOLUTION); while (solIter.hasNext()) { Value solutionNode = solIter.next(); if (solutionNode instanceof Resource) { reportSolution((Resource)solutionNode, bindingNames); } else { throw new RDFHandlerException( "Value for " + SOLUTION + " is not a resource: " + solutionNode); } } tqrHandler.endQueryResult(); } catch (GraphUtilException e) { throw new RDFHandlerException(e.getMessage(), e); } catch (TupleQueryResultHandlerException e) { throw new RDFHandlerException(e.getMessage(), e); } }
@Override public void endQueryResult() throws TupleQueryResultHandlerException { if (!tupleVariablesFound) { throw new IllegalStateException( "Could not end query result as startQueryResult was not called first."); } try { writer.flush(); } catch (IOException e) { throw new TupleQueryResultHandlerException(e); } }
@Override public void endRDF() throws RDFHandlerException { try { Resource resultSetNode = GraphUtil.getUniqueSubject(graph, RDF.TYPE, RESULTSET); List<String> bindingNames = getBindingNames(resultSetNode); tqrHandler.startQueryResult(bindingNames); Iterator<Value> solIter = GraphUtil.getObjectIterator(graph, resultSetNode, SOLUTION); while (solIter.hasNext()) { Value solutionNode = solIter.next(); if (solutionNode instanceof Resource) { reportSolution((Resource)solutionNode, bindingNames); } else { throw new RDFHandlerException( "Value for " + SOLUTION + " is not a resource: " + solutionNode); } } tqrHandler.endQueryResult(); } catch (GraphUtilException e) { throw new RDFHandlerException(e.getMessage(), e); } catch (TupleQueryResultHandlerException e) { throw new RDFHandlerException(e.getMessage(), e); } }
@Override public void endQueryResult() throws TupleQueryResultHandlerException { if (!tupleVariablesFound) { throw new IllegalStateException( "Could not end query result as startQueryResult was not called first."); } try { writer.flush(); } catch (IOException e) { throw new TupleQueryResultHandlerException(e); } }
@Override public void endRDF() throws RDFHandlerException { try { Resource resultSetNode = GraphUtil.getUniqueSubject(graph, RDF.TYPE, RESULTSET); List<String> bindingNames = getBindingNames(resultSetNode); tqrHandler.startQueryResult(bindingNames); Iterator<Value> solIter = GraphUtil.getObjectIterator(graph, resultSetNode, SOLUTION); while (solIter.hasNext()) { Value solutionNode = solIter.next(); if (solutionNode instanceof Resource) { reportSolution((Resource)solutionNode, bindingNames); } else { throw new RDFHandlerException( "Value for " + SOLUTION + " is not a resource: " + solutionNode); } } tqrHandler.endQueryResult(); } catch (GraphUtilException e) { throw new RDFHandlerException(e.getMessage(), e); } catch (TupleQueryResultHandlerException e) { throw new RDFHandlerException(e.getMessage(), e); } }
@Override public void endQueryResult() throws TupleQueryResultHandlerException { if (bindingNames == null) { throw new IllegalStateException( "Could not end query result as startQueryResult was not called first."); } try { writer.flush(); } catch (IOException e) { throw new TupleQueryResultHandlerException(e); } }
@Override public void endQueryResult() throws TupleQueryResultHandlerException { resultSetNode = null; try { rdfHandler.endRDF(); } catch (RDFHandlerException e) { throw new TupleQueryResultHandlerException(e); } }
@Override public void endQueryResult() throws TupleQueryResultHandlerException { resultSetNode = null; try { rdfHandler.endRDF(); } catch (RDFHandlerException e) { throw new TupleQueryResultHandlerException(e); } }
@Override public void endQueryResult() throws TupleQueryResultHandlerException { resultSetNode = null; try { rdfHandler.endRDF(); } catch (RDFHandlerException e) { throw new TupleQueryResultHandlerException(e); } }
@Override public void startQueryResult(List<String> bindingNames) throws TupleQueryResultHandlerException { this.bindingNames = bindingNames; try { for (int i = 0; i < bindingNames.size(); i++) { writer.write(bindingNames.get(i)); if (i < bindingNames.size() - 1) { writer.write(","); } } writer.write("\r\n"); } catch (IOException e) { throw new TupleQueryResultHandlerException(e); } }
@Override public void startQueryResult(List<String> bindingNames) throws TupleQueryResultHandlerException { this.bindingNames = bindingNames; try { for (int i = 0; i < bindingNames.size(); i++) { writer.write(bindingNames.get(i)); if (i < bindingNames.size() - 1) { writer.write(","); } } writer.write("\r\n"); } catch (IOException e) { throw new TupleQueryResultHandlerException(e); } }
@Override public void parseQueryResult(InputStream in) throws IOException, QueryResultParseException, TupleQueryResultHandlerException { try { parseQueryResultInternal(in, false, true); } catch (QueryResultHandlerException e) { if (e instanceof TupleQueryResultHandlerException) { throw (TupleQueryResultHandlerException)e; } else { throw new TupleQueryResultHandlerException(e); } } }