01: package org.ontoware.rdf2go.impl.jena24;
02:
03: import org.ontoware.aifbcommons.collection.ClosableIterator;
04: import org.ontoware.rdf2go.model.Statement;
05:
06: import com.hp.hpl.jena.graph.Triple;
07:
08: /**
09: * Define an Iterator over Statements, building the Statements from Jena
10: * Triples.
11: */
12:
13: public class TripleIterator implements ClosableIterator<Statement> {
14:
15: private com.hp.hpl.jena.util.iterator.ClosableIterator it;
16:
17: private long modelModificationCountAtCreationTime;
18:
19: private ModelImplJena24 modelImplJena;
20:
21: public TripleIterator(
22: com.hp.hpl.jena.util.iterator.ClosableIterator it,
23: long modelModificationCountAtCreationTime,
24: ModelImplJena24 jenaModel) {
25: this .it = it;
26: this .modelModificationCountAtCreationTime = modelModificationCountAtCreationTime;
27: this .modelImplJena = jenaModel;
28: }
29:
30: public boolean hasNext() {
31: assert modelImplJena.getModificationCount() == modelModificationCountAtCreationTime : "concurrent modification for iterator ("
32: + modelModificationCountAtCreationTime
33: + " but model is "
34: + modelImplJena.getModificationCount() + ")";
35: return it.hasNext();
36: }
37:
38: public Statement next() {
39: assert modelImplJena.getModificationCount() == modelModificationCountAtCreationTime;
40: Triple t = (Triple) it.next();
41: return new StatementJena24Impl(this .modelImplJena, t
42: .getSubject(), t.getPredicate(), t.getObject());
43: }
44:
45: public void remove() {
46: // it.remove();
47: assert modelImplJena.getModificationCount() == modelModificationCountAtCreationTime;
48: it.remove();
49: }
50:
51: public void close() {
52: it.close();
53: }
54:
55: }
|