1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package com.ontotext.ordi.mapper.processor;
19
20 import org.openrdf.model.Resource;
21 import org.openrdf.model.URI;
22 import org.openrdf.model.Value;
23
24 import com.ontotext.ordi.mapper.model.RDFResultSet;
25
26 public class AggregateRDFResultSet implements RDFResultSet {
27
28 private RDFResultManager manager;
29 private RDFResultSet current;
30
31 public AggregateRDFResultSet(RDFResultManager manager) {
32 if (manager == null) {
33 throw new IllegalArgumentException();
34 }
35 this.manager = manager;
36 }
37
38 public void run() {
39 }
40
41 public void close() {
42 do {
43 if (current != null) {
44 current.close();
45 }
46 current = manager.getNextCompleted();
47 } while (manager.getNextCompleted() != null);
48 }
49
50 public URI getNamedGraph() {
51 if (current == null) {
52 throw new IllegalStateException(invalidState);
53 }
54 return current.getNamedGraph();
55 }
56
57 public Value getObject() {
58 if (current == null) {
59 throw new IllegalStateException(invalidState);
60 }
61 return current.getObject();
62 }
63
64 public URI getPredicate() {
65 if (current == null) {
66 throw new IllegalStateException(invalidState);
67 }
68 return current.getPredicate();
69 }
70
71 public Resource getSubject() {
72 if (current == null) {
73 throw new IllegalStateException(invalidState);
74 }
75 return current.getSubject();
76 }
77
78 public URI[] getTriplesets() {
79 if (current == null) {
80 throw new IllegalStateException(invalidState);
81 }
82 return current.getTriplesets();
83 }
84
85 public boolean next() {
86 if (current == null) {
87 current = manager.getNextCompleted();
88 }
89 while (current != null) {
90 boolean hasNext = current.next();
91 if (hasNext) {
92 return true;
93 }
94 current.close();
95 current = manager.getNextCompleted();
96 return next();
97 }
98 return false;
99 }
100
101 private final String invalidState = "Invalid operation first call next() method!";
102 }