01: package jimm.datavision.test.mock.source;
02:
03: import jimm.datavision.Selectable;
04: import jimm.datavision.source.DataCursor;
05: import jimm.datavision.source.Query;
06: import java.util.List;
07: import java.util.ArrayList;
08:
09: public class MockAggregateDataCursor extends DataCursor {
10:
11: protected static final Object[][] DATA = {
12: { "A", "B", "D", new Integer(2) },
13: { "A", "B", "D", new Integer(24) },
14: { "A", "B", "D", new Integer(3) },
15: { "A", "C", "D", new Integer(12) },
16: { "A", "C", "D", new Integer(42) } };
17:
18: protected static final String[] SELECTABLES = {
19: "aggregate_test.col1", "aggregate_test.col2",
20: "aggregate_test.col3", "aggregate_test.value" };
21:
22: static int indexOfSelectable(Selectable sel) {
23: String selId = sel.getId().toString();
24: for (int i = 0; i < SELECTABLES.length; ++i)
25: if (selId.equals(SELECTABLES[i]))
26: return i;
27:
28: throw new RuntimeException("can't find selectable \""
29: + sel.getDisplayName() + "\" with id " + selId);
30: }
31:
32: protected int recordIndex;
33:
34: public MockAggregateDataCursor(Query q) {
35: recordIndex = -1;
36: }
37:
38: protected List readRowData() {
39: ++recordIndex;
40: if (recordIndex >= DATA.length)
41: return null;
42:
43: List row = new ArrayList(DATA[recordIndex].length);
44: for (int i = 0; i < DATA[recordIndex].length; ++i)
45: row.add(DATA[recordIndex][i]);
46:
47: return row;
48: }
49:
50: }
|