01: /**
02: * Copyright 2007 Jens Dietrich Licensed under the Apache License, Version 2.0 (the "License");
03: * you may not use this file except in compliance with the License.
04: * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
05: * Unless required by applicable law or agreed to in writing, software distributed under the
06: * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
07: * either express or implied. See the License for the specific language governing permissions
08: * and limitations under the License.
09: */package nz.org.take.rt;
10:
11: import java.util.List;
12:
13: /**
14: * Result set. Wraps a resource iterator. Has an additional reference to the derivation log.
15: * @author <a href="http://www-ist.massey.ac.nz/JBDietrich/">Jens Dietrich</a>
16: */
17: public class ResultSet<T> implements ResourceIterator<T> {
18:
19: private DerivationController derivationController = null;
20: private ResourceIterator<T> delegate = null;
21:
22: public ResultSet(ResourceIterator<T> delegate,
23: DerivationController derivationController) {
24: super ();
25: this .derivationController = derivationController;
26: this .delegate = delegate;
27: }
28:
29: /**
30: * Close the iterator.
31: */
32: public void close() {
33: this .delegate.close();
34: }
35:
36: public List<DerivationLogEntry> getDerivationLog() {
37: return derivationController.getLog();
38: }
39:
40: public DerivationController getDerivationController() {
41: return derivationController;
42: }
43:
44: public boolean hasNext() {
45: return this .delegate.hasNext();
46: }
47:
48: public T next() {
49: return this .delegate.next();
50: }
51:
52: public void remove() {
53: this .delegate.remove();
54: }
55:
56: /**
57: * Cancel the derivation.
58: */
59: public void cancel() {
60: this .derivationController.cancel();
61: }
62:
63: /**
64: * Whether the derivation has been cancelled.
65: * @return the cancelled status
66: */
67: public boolean isCancelled() {
68: return this.derivationController.isCancelled();
69: }
70:
71: }
|