1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package jTrolog.terms;
23
24 import jTrolog.terms.Term;
25 import jTrolog.engine.BindingsTable;
26
27 import java.util.Iterator;
28
29
30
31
32 @SuppressWarnings({ "rawtypes" })
33 public interface Wrapper {
34
35 int getContext();
36
37 Term getBasis();
38
39 static class WrappedIterator implements Iterator {
40
41 private Iterator underlyingIt;
42 private int ctx;
43
44 WrappedIterator(Iterator orig, int ctx) {
45 underlyingIt = orig;
46 this.ctx = ctx;
47 }
48
49 public boolean hasNext() {
50 return underlyingIt.hasNext();
51 }
52
53 public Object next() {
54 return BindingsTable.wrapWithID((Term) underlyingIt.next(), ctx);
55 }
56
57 public void remove() {
58 throw new UnsupportedOperationException("dont remove on Prolog lists");
59 }
60 }
61 }