01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 2008.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.sail.rdbms.evaluation;
07:
08: import info.aduna.iteration.CloseableIteration;
09:
10: import org.openrdf.model.Resource;
11: import org.openrdf.model.URI;
12: import org.openrdf.model.Value;
13: import org.openrdf.query.QueryEvaluationException;
14: import org.openrdf.query.algebra.evaluation.TripleSource;
15: import org.openrdf.sail.SailException;
16: import org.openrdf.sail.rdbms.RdbmsTripleRepository;
17: import org.openrdf.sail.rdbms.RdbmsValueFactory;
18: import org.openrdf.sail.rdbms.model.RdbmsResource;
19: import org.openrdf.sail.rdbms.model.RdbmsURI;
20: import org.openrdf.sail.rdbms.model.RdbmsValue;
21:
22: /**
23: * Proxies request to a {@link RdbmsTripleRepository}.
24: *
25: * @author James Leigh
26: *
27: */
28: public class RdbmsTripleSource implements TripleSource {
29: private RdbmsTripleRepository triples;
30:
31: public RdbmsTripleSource(RdbmsTripleRepository triples) {
32: super ();
33: this .triples = triples;
34: }
35:
36: public RdbmsValueFactory getValueFactory() {
37: return triples.getValueFactory();
38: }
39:
40: public CloseableIteration getStatements(Resource subj, URI pred,
41: Value obj, Resource... contexts)
42: throws QueryEvaluationException {
43: try {
44: RdbmsValueFactory vf = triples.getValueFactory();
45: RdbmsResource s = vf.asRdbmsResource(subj);
46: RdbmsURI p = vf.asRdbmsURI(pred);
47: RdbmsValue o = vf.asRdbmsValue(obj);
48: RdbmsResource[] c = vf.asRdbmsResource(contexts);
49: return triples.find(s, p, o, c);
50: } catch (SailException e) {
51: throw new QueryEvaluationException(e);
52: }
53: }
54:
55: }
|