01: package org.ontoware.rdfreactor.runtime;
02:
03: import org.ontoware.aifbcommons.collection.ClosableIterator;
04: import org.ontoware.rdf2go.exception.ModelRuntimeException;
05:
06: public class RDFObjectIterator<T> implements ClosableIterator<T> {
07:
08: private ExtractingIterator it;
09: private Class<?> returnType;
10:
11: public RDFObjectIterator(ExtractingIterator it, Class<?> returnType) {
12: this .it = it;
13: this .returnType = returnType;
14: }
15:
16: public boolean hasNext() {
17: return it.hasNext();
18: }
19:
20: @SuppressWarnings("unchecked")
21: public T next() {
22: try {
23: return (T) RDFReactorRuntime.node2javatype(it.getModel(),
24: it.next(), returnType);
25: } catch (ModelRuntimeException e) {
26: throw new RuntimeException(e);
27: }
28: }
29:
30: public void remove() {
31: it.remove();
32: }
33:
34: public void close() {
35: it.close();
36: }
37:
38: }
|