|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| package org.displaytag.model; |
|
13 |
| |
|
14 |
| import java.util.Iterator; |
|
15 |
| import java.util.List; |
|
16 |
| |
|
17 |
| import org.apache.commons.logging.Log; |
|
18 |
| import org.apache.commons.logging.LogFactory; |
|
19 |
| import org.displaytag.decorator.TableDecorator; |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| public class RowIterator |
|
28 |
| { |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| private static Log log = LogFactory.getLog(RowIterator.class); |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| |
|
38 |
| private Iterator iterator; |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| private int rowNumber; |
|
44 |
| |
|
45 |
| |
|
46 |
| |
|
47 |
| |
|
48 |
| private TableDecorator decorator; |
|
49 |
| |
|
50 |
| |
|
51 |
| |
|
52 |
| |
|
53 |
| private String id; |
|
54 |
| |
|
55 |
| |
|
56 |
| |
|
57 |
| |
|
58 |
| private int pageOffset; |
|
59 |
| |
|
60 |
| |
|
61 |
| |
|
62 |
| |
|
63 |
| |
|
64 |
| |
|
65 |
| |
|
66 |
| |
|
67 |
394
| protected RowIterator(List rowList, List columnList, TableDecorator tableDecorator, int offset)
|
|
68 |
| { |
|
69 |
394
| this.iterator = rowList.iterator();
|
|
70 |
394
| this.rowNumber = 0;
|
|
71 |
394
| this.decorator = tableDecorator;
|
|
72 |
394
| this.pageOffset = offset;
|
|
73 |
| } |
|
74 |
| |
|
75 |
| |
|
76 |
| |
|
77 |
| |
|
78 |
| |
|
79 |
394
| public void setId(String tableId)
|
|
80 |
| { |
|
81 |
394
| this.id = tableId;
|
|
82 |
| } |
|
83 |
| |
|
84 |
| |
|
85 |
| |
|
86 |
| |
|
87 |
| |
|
88 |
1408
| public boolean hasNext()
|
|
89 |
| { |
|
90 |
1408
| return this.iterator.hasNext();
|
|
91 |
| } |
|
92 |
| |
|
93 |
94
| public int getPageOffset()
|
|
94 |
| { |
|
95 |
94
| return this.pageOffset;
|
|
96 |
| } |
|
97 |
| |
|
98 |
| |
|
99 |
| |
|
100 |
| |
|
101 |
| |
|
102 |
662
| public Row next()
|
|
103 |
| { |
|
104 |
| |
|
105 |
662
| int currentRowNumber = this.rowNumber++;
|
|
106 |
| |
|
107 |
662
| if (log.isDebugEnabled())
|
|
108 |
| { |
|
109 |
662
| log.debug("[" + this.id + "] rowIterator.next() row number=" + currentRowNumber);
|
|
110 |
| } |
|
111 |
| |
|
112 |
662
| Object object = this.iterator.next();
|
|
113 |
| |
|
114 |
662
| Row row = (Row) object;
|
|
115 |
| |
|
116 |
662
| row.setRowNumber(currentRowNumber);
|
|
117 |
| |
|
118 |
662
| if (this.decorator != null)
|
|
119 |
| { |
|
120 |
50
| this.decorator.initRow(row.getObject(), currentRowNumber, currentRowNumber + getPageOffset());
|
|
121 |
| } |
|
122 |
| |
|
123 |
662
| return row;
|
|
124 |
| |
|
125 |
| } |
|
126 |
| |
|
127 |
| } |