1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package tools.gsf.facade.sql;
18
19 import COM.FutureTense.Interfaces.IList;
20
21 import java.util.Iterator;
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 public class IListIterable implements Iterable<Row> {
37 private final IList list;
38
39 private final int numRows;
40
41 public IListIterable(final IList list) {
42 super();
43 this.list = list;
44 if (list != null) {
45 numRows = list.numRows();
46 } else {
47 numRows = 0;
48 }
49 }
50
51 public Iterator<Row> iterator() {
52 if (list == null || !list.hasData()) {
53 return new Iterator<Row>() {
54
55 public boolean hasNext() {
56 return false;
57 }
58
59 public Row next() {
60 return null;
61 }
62
63 public void remove() {
64 throw new RuntimeException("Can not remove");
65 }
66
67 };
68 }
69 return new Iterator<Row>() {
70 private int rowNum = 0;
71
72 public boolean hasNext() {
73 return rowNum < numRows;
74 }
75
76 public Row next() {
77 rowNum++;
78 list.moveTo(rowNum);
79 return new SingleRow(list);
80 }
81
82 public void remove() {
83 throw new RuntimeException("Can not remove");
84 }
85 };
86 }
87
88 public int size() {
89 return numRows;
90 }
91
92 public void flush() {
93 if (list != null) {
94 list.flush();
95 }
96 }
97
98 public String getColumnName(final int i) {
99 if (list != null) {
100 return list.getColumnName(i);
101 }
102 return "";
103 }
104
105 public String getIndirectColumnName(final int index) {
106 if (list != null) {
107 return list.getIndirectColumnName(index);
108 }
109 return "";
110 }
111
112 public int numColumns() {
113 if (list != null) {
114 return list.numColumns();
115 }
116 return 0;
117 }
118
119 public int numIndirectColumns() {
120 if (list != null) {
121 return list.numIndirectColumns();
122 }
123 return 0;
124 }
125
126 }