org.openrdf.query.TupleQueryResultHandlerException Java Examples
The following examples show how to use
org.openrdf.query.TupleQueryResultHandlerException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SPARQLInferenceTest.java From neo4j-sparql-extension with GNU General Public License v3.0 | 6 votes |
private QueryResult runQuery() throws IOException, QueryEvaluationException, QueryResultParseException, TupleQueryResultHandlerException, QueryResultHandlerException { TestResultHandler noninf = new TestResultHandler(); TestResultHandler actual = new TestResultHandler(); TestResultHandler expect = new TestResultHandler(); parser.setQueryResultHandler(expect); parser.parseQueryResult(getResource(expected)); nonInfQuery.evaluate(noninf); query.evaluate(actual); Multiset<BindingSet> noninfset = noninf.getSolutions(); Multiset<BindingSet> expectset = expect.getSolutions(); Multiset<BindingSet> actualset = actual.getSolutions(); return new QueryResult(expectset, actualset, noninfset); }
Example #2
Source File: BigdataSPARQLResultsJSONWriterForConstruct.java From database with GNU General Public License v2.0 | 5 votes |
@Override public void endRDF() throws RDFHandlerException { try { writer.endQueryResult(); // writer.endDocument(); // } catch (IOException e) { // throw new RDFHandlerException(e); } catch (TupleQueryResultHandlerException e) { throw new RDFHandlerException(e); } }
Example #3
Source File: SelectQueryExecutionStrategy.java From ldp4j with Apache License 2.0 | 5 votes |
@Override public void handleSolution(BindingSet bindingSet) throws TupleQueryResultHandlerException { Map<String,Node> result=new HashMap<String,Node>(); for(String varName:query.getVariables()) { Node node = parser.parseValue(bindingSet.getValue(varName)); if(!query.isCompatibleValue(varName, node)) { throw new TupleQueryResultHandlerException("Incompatible value for binding '"+varName+"'"); } result.put(varName, node); } if(!query.getVariables().equals(result.keySet())) { throw new TupleQueryResultHandlerException(EXPECTED_BINDINGS_MISSING); } handler.handleSolution(Collections.unmodifiableMap(result)); }
Example #4
Source File: SelectQueryExecutionStrategy.java From ldp4j with Apache License 2.0 | 5 votes |
@Override public void startQueryResult(List<String> bindingNames) throws TupleQueryResultHandlerException { if(!bindingNames.containsAll(query.getVariables())) { throw new TupleQueryResultHandlerException(EXPECTED_BINDINGS_MISSING); } handler.startResult(); }
Example #5
Source File: SPARQLInferenceTest.java From neo4j-sparql-extension with GNU General Public License v3.0 | 5 votes |
@Test public void subset() throws QueryEvaluationException, TupleQueryResultHandlerException, IOException, QueryResultParseException, QueryResultHandlerException { QueryResult q = this.runQuery(); assertTrue( q.getNonInferred() + " should be a subset of " + q.getActual(), Multisets.containsOccurrences( q.getActual(), q.getNonInferred() )); }
Example #6
Source File: SPARQLJSONWriterBase.java From database with GNU General Public License v2.0 | 5 votes |
protected void writeValue(Value value) throws IOException, QueryResultHandlerException { jg.writeStartObject(); if (value instanceof URI) { jg.writeStringField("type", "uri"); jg.writeStringField("value", ((URI)value).toString()); } else if (value instanceof BNode) { jg.writeStringField("type", "bnode"); jg.writeStringField("value", ((BNode)value).getID()); } else if (value instanceof Literal) { Literal lit = (Literal)value; // TODO: Implement support for // BasicWriterSettings.RDF_LANGSTRING_TO_LANG_LITERAL here if (lit.getLanguage() != null) { jg.writeObjectField("xml:lang", lit.getLanguage()); } // TODO: Implement support for // BasicWriterSettings.XSD_STRING_TO_PLAIN_LITERAL here if (lit.getDatatype() != null) { jg.writeObjectField("datatype", lit.getDatatype().stringValue()); } jg.writeObjectField("type", "literal"); jg.writeObjectField("value", lit.getLabel()); } else { throw new TupleQueryResultHandlerException("Unknown Value object type: " + value.getClass()); } jg.writeEndObject(); }
Example #7
Source File: BigdataSPARQLResultsJSONWriterForConstruct.java From database with GNU General Public License v2.0 | 5 votes |
@Override public void handleStatement(Statement st) throws RDFHandlerException { final MapBindingSet bs = new MapBindingSet(); bs.addBinding("subject", st.getSubject()); bs.addBinding("predicate", st.getPredicate()); bs.addBinding("object", st.getObject()); if (st.getContext() != null) bs.addBinding("context", st.getContext()); try { writer.handleSolution(bs); } catch (TupleQueryResultHandlerException e) { throw new RDFHandlerException(e); } }
Example #8
Source File: BigdataSPARQLResultsJSONParserForConstruct.java From database with GNU General Public License v2.0 | 5 votes |
@Override public void handleSolution(BindingSet bs) throws TupleQueryResultHandlerException { if (!bs.hasBinding("subject")) { throw new TupleQueryResultHandlerException("no subject: " + bs); } if (!bs.hasBinding("predicate")) { throw new TupleQueryResultHandlerException("no predicate: " + bs); } if (!bs.hasBinding("object")) { throw new TupleQueryResultHandlerException("no object: " + bs); } final Resource s = (Resource) bs.getValue("subject"); final URI p = (URI) bs.getValue("predicate"); final Value o = (Value) bs.getValue("object"); final Resource c = bs.hasBinding("context") ? (Resource) bs.getValue("context") : null; final Statement stmt = valueFactory.createStatement(s, p, o, c); try { getRDFHandler().handleStatement(stmt); } catch (RDFHandlerException e) { throw new TupleQueryResultHandlerException(e); } }
Example #9
Source File: BigdataSPARQLResultsJSONParserForConstruct.java From database with GNU General Public License v2.0 | 5 votes |
@Override public void endQueryResult() throws TupleQueryResultHandlerException { try { getRDFHandler().endRDF(); } catch (RDFHandlerException e) { throw new TupleQueryResultHandlerException(e); } }
Example #10
Source File: BigdataSPARQLResultsJSONParserForConstruct.java From database with GNU General Public License v2.0 | 5 votes |
@Override public void startQueryResult(List<String> bindingNames) throws TupleQueryResultHandlerException { try { getRDFHandler().startRDF(); } catch (RDFHandlerException e) { throw new TupleQueryResultHandlerException(e); } }
Example #11
Source File: BigdataRemoteTupleQuery.java From database with GNU General Public License v2.0 | 5 votes |
public void evaluate(TupleQueryResultHandler handler) throws QueryEvaluationException, TupleQueryResultHandlerException { TupleQueryResult tqr = evaluate(); try { handler.startQueryResult(tqr.getBindingNames()); while (tqr.hasNext()) { handler.handleSolution(tqr.next()); } handler.endQueryResult(); } finally { tqr.close(); } }
Example #12
Source File: BackgroundTupleResult.java From database with GNU General Public License v2.0 | 5 votes |
@Override public void handleSolution(final BindingSet bindingSet) throws TupleQueryResultHandlerException { if (closed) throw new TupleQueryResultHandlerException("Result closed"); try { queue.put(bindingSet); } catch (InterruptedException e) { throw new TupleQueryResultHandlerException(e); } }
Example #13
Source File: BackgroundTupleResult.java From database with GNU General Public License v2.0 | 4 votes |
@Override public void endQueryResult() throws TupleQueryResultHandlerException { // no-op }
Example #14
Source File: BackgroundTupleResult.java From database with GNU General Public License v2.0 | 4 votes |
@Override public void startQueryResult(final List<String> bindingNames) throws TupleQueryResultHandlerException { this.bindingNames = bindingNames; bindingNamesReady.countDown(); }
Example #15
Source File: TestResultHandler.java From neo4j-sparql-extension with GNU General Public License v3.0 | 4 votes |
@Override public void startQueryResult(List<String> bindingNames) throws TupleQueryResultHandlerException { this.bindingNames = bindingNames; }
Example #16
Source File: TestResultHandler.java From neo4j-sparql-extension with GNU General Public License v3.0 | 4 votes |
@Override public void endQueryResult() throws TupleQueryResultHandlerException { }
Example #17
Source File: TestResultHandler.java From neo4j-sparql-extension with GNU General Public License v3.0 | 4 votes |
@Override public void handleSolution(BindingSet set) throws TupleQueryResultHandlerException { this.solutions.add(set); }
Example #18
Source File: QueryEvaluation.java From CostFed with GNU Affero General Public License v3.0 | 4 votes |
@Override public void handleSolution(BindingSet arg0) throws TupleQueryResultHandlerException { resultCount++; }
Example #19
Source File: QueryEvaluation.java From CostFed with GNU Affero General Public License v3.0 | 2 votes |
@Override public void endQueryResult() throws TupleQueryResultHandlerException { }
Example #20
Source File: QueryEvaluation.java From CostFed with GNU Affero General Public License v3.0 | 2 votes |
@Override public void startQueryResult(List<String> arg0) throws TupleQueryResultHandlerException { }