1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package com.ontotext.ordi.iterator;
19
20 import com.ontotext.ordi.exception.ORDIRuntimeException;
21
22 import info.aduna.iteration.CloseableIteration;
23
24 /**
25 * This class wraps the Sesame CloseableIteration type and provides ORDI
26 * friendly iteration interface. The type is used to integrated the Sesame Query
27 * engine functionality in ORDI.
28 *
29 * @author vassil
30 */
31 public class WrappedSesameIteratorImpl<E> implements CloseableIterator<E> {
32
33 private CloseableIteration<E, ? extends Exception> iter;
34
35 public WrappedSesameIteratorImpl(
36 CloseableIteration<E, ? extends Exception> iter) {
37 if (iter == null) {
38 throw new IllegalArgumentException();
39 }
40 this.iter = iter;
41 }
42
43 public void close() {
44 try {
45 iter.close();
46 } catch (Exception e) {
47 throw new ORDIRuntimeException(e);
48 }
49 }
50
51 public boolean hasNext() {
52 try {
53 return iter.hasNext();
54 } catch (Exception e) {
55 throw new ORDIRuntimeException(e);
56 }
57 }
58
59 public E next() {
60 try {
61 return iter.next();
62 } catch (Exception e) {
63 throw new ORDIRuntimeException(e);
64 }
65 }
66
67 public void remove() {
68 try {
69 iter.remove();
70 } catch (Exception e) {
71 throw new ORDIRuntimeException(e);
72 }
73 }
74
75 }