01: package org.ontoware.rdfreactor.runtime;
02:
03: import org.ontoware.aifbcommons.collection.ClosableIterator;
04: import org.ontoware.rdf2go.model.Model;
05: import org.ontoware.rdf2go.model.QueryRow;
06: import org.ontoware.rdf2go.model.node.Node;
07:
08: /**
09: * An iterator over nodes, based on an interator over QueryRows, such as
10: * returned by RDF2GO.sparqlSelect(..)
11: *
12: * @author voelkel
13: */
14: public class ExtractingIterator implements ClosableIterator<Node> {
15:
16: private ClosableIterator<QueryRow> it;
17:
18: private Model model;
19:
20: private String extractVariable;
21:
22: public ExtractingIterator(Model model,
23: ClosableIterator<QueryRow> it, String extractVariable) {
24: this .model = model;
25: this .it = it;
26: this .extractVariable = extractVariable;
27: }
28:
29: public boolean hasNext() {
30: return it.hasNext();
31: }
32:
33: public Node next() {
34: return it.next().getValue(extractVariable);
35: }
36:
37: public void remove() {
38: it.remove();
39: }
40:
41: public void close() {
42: it.close();
43: }
44:
45: public Model getModel() {
46: return this.model;
47: }
48:
49: }
|