01: package org.ontoware.rdfreactor.runtime;
02:
03: import java.util.List;
04: import java.util.Map;
05:
06: import org.ontoware.aifbcommons.collection.ClosableIterator;
07: import org.ontoware.rdf2go.exception.ModelRuntimeException;
08: import org.ontoware.rdf2go.model.Model;
09: import org.ontoware.rdf2go.model.QueryResultTable;
10:
11: public class OOQueryResultTableImpl implements OOQueryResultTable {
12:
13: private Model m;
14:
15: private Map<String, Class<?>> returnTypes;
16:
17: private QueryResultTable resultTable;
18:
19: public OOQueryResultTableImpl(Model m,
20: Map<String, Class<?>> returnTypes, String sparqlSelectQuery)
21: throws ModelRuntimeException {
22:
23: this .resultTable = m.sparqlSelect(sparqlSelectQuery);
24:
25: if (!sparqlSelectQuery.contains("SELECT")) {
26: throw new ModelRuntimeException(
27: "The given query is not a SELECT query");
28: }
29: // else
30: this .m = m;
31: this .returnTypes = returnTypes;
32: }
33:
34: public List<String> getVariables() {
35: return this .resultTable.getVariables();
36: }
37:
38: public ClosableIterator<OOQueryRow> iterator() {
39: return new SparqlIterator(this , this .resultTable.iterator());
40: }
41:
42: public Model getModel() {
43: return this .m;
44: }
45:
46: public Class<?> getReturnType(String varname) {
47: return returnTypes.get(varname);
48: }
49:
50: }
|