1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.apache.commons.scaffold.util; |
18 | |
|
19 | |
|
20 | |
import java.util.ArrayList; |
21 | |
import java.util.Collection; |
22 | |
import java.util.Iterator; |
23 | |
import java.util.List; |
24 | |
import java.util.Map; |
25 | |
|
26 | |
import org.apache.commons.beanutils.BeanUtils; |
27 | |
|
28 | |
import org.apache.commons.scaffold.lang.ChainedException; |
29 | |
import org.apache.commons.scaffold.lang.Tokens; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
public class ResultListBase implements ResultList { |
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | 0 | protected List result = (List) new ArrayList(); |
46 | |
|
47 | |
|
48 | |
public List getResult() { |
49 | 0 | return this.result; |
50 | |
} |
51 | |
|
52 | |
|
53 | |
public void setResult(List result) { |
54 | 0 | this.result = result; |
55 | 0 | } |
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | 0 | protected Scroller scroller = null; |
63 | |
|
64 | |
|
65 | |
public void setScroller(Scroller scroller){ |
66 | 0 | this.scroller = scroller; |
67 | 0 | } |
68 | |
|
69 | |
|
70 | |
public Scroller getScroller() { |
71 | 0 | return this.scroller; |
72 | |
} |
73 | |
|
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | 0 | private int counter = 0; |
79 | |
|
80 | |
|
81 | |
public int getCounter() { |
82 | 0 | return counter++; |
83 | |
} |
84 | |
|
85 | |
|
86 | |
public void setCounter(int counter) { |
87 | 0 | this.counter = counter; |
88 | 0 | } |
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | 0 | private Integer code = null; |
95 | |
|
96 | |
|
97 | |
public Integer getCode() { |
98 | 0 | return (this.code); |
99 | |
} |
100 | |
|
101 | |
|
102 | |
public void setCode(Integer code) { |
103 | 0 | this.code = code; |
104 | 0 | } |
105 | |
|
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | |
|
111 | 0 | private String legend = null; |
112 | |
|
113 | |
|
114 | |
public String getLegend() { |
115 | 0 | return (this.legend); |
116 | |
} |
117 | |
|
118 | |
|
119 | |
public void setLegend(String legend) { |
120 | 0 | this.legend = legend; |
121 | 0 | } |
122 | |
|
123 | |
|
124 | |
public void setLegend(String name, String value) { |
125 | |
|
126 | 0 | if ((null==value) || ("".equals(value))) { |
127 | |
|
128 | 0 | setLegend(name + Tokens.PARAM_EQUALS + Tokens.PARAM_ANY); |
129 | |
|
130 | |
} |
131 | |
else { |
132 | |
|
133 | 0 | setLegend(name + Tokens.PARAM_EQUALS + value); |
134 | |
|
135 | |
} |
136 | 0 | } |
137 | |
|
138 | |
|
139 | |
|
140 | |
|
141 | |
|
142 | 0 | protected Map displayName = null; |
143 | |
|
144 | |
|
145 | |
public Map getDisplayName() { |
146 | 0 | return this.displayName; |
147 | |
} |
148 | |
|
149 | |
|
150 | |
public void setDisplayName(Map displayName) { |
151 | 0 | this.displayName = displayName; |
152 | 0 | } |
153 | |
|
154 | |
|
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | |
|
161 | |
|
162 | |
public Object[] toArray() { |
163 | 0 | return getResult().toArray(); |
164 | |
} |
165 | |
|
166 | |
|
167 | |
public Object[] toArray(Object a[]) { |
168 | 0 | return getResult().toArray(a); |
169 | |
} |
170 | |
|
171 | |
|
172 | |
|
173 | |
|
174 | |
|
175 | |
public boolean isEmpty() { |
176 | 0 | return getResult().isEmpty(); |
177 | |
} |
178 | |
|
179 | |
|
180 | |
public int size() { |
181 | 0 | return getResult().size(); |
182 | |
} |
183 | |
|
184 | |
|
185 | |
public boolean contains(Object element) { |
186 | 0 | return getResult().contains(element); |
187 | |
} |
188 | |
|
189 | |
|
190 | |
public boolean add(Object o) { |
191 | 0 | return getResult().add(o); |
192 | |
} |
193 | |
|
194 | |
|
195 | |
public Iterator iterator() { |
196 | 0 | return getResult().iterator(); |
197 | |
} |
198 | |
|
199 | |
|
200 | |
|
201 | |
|
202 | |
|
203 | |
public Object get(int index) { |
204 | 0 | return getResult().get(index); |
205 | |
} |
206 | |
|
207 | |
|
208 | |
|
209 | |
|
210 | |
|
211 | |
public boolean addAll(Collection c) { |
212 | 0 | return getResult().addAll(c); |
213 | |
} |
214 | |
|
215 | |
|
216 | |
public void clear() { |
217 | 0 | getResult().clear(); |
218 | 0 | } |
219 | |
|
220 | |
|
221 | |
public boolean containsAll(Collection c) { |
222 | 0 | return getResult().containsAll(c); |
223 | |
} |
224 | |
|
225 | |
|
226 | |
public boolean remove(Object o) { |
227 | 0 | return getResult().remove(o); |
228 | |
} |
229 | |
|
230 | |
|
231 | |
public boolean removeAll(Collection c) { |
232 | 0 | return getResult().removeAll(c); |
233 | |
} |
234 | |
|
235 | |
|
236 | |
public boolean retainAll(Collection c) { |
237 | 0 | return getResult().retainAll(c); |
238 | |
} |
239 | |
|
240 | |
|
241 | |
|
242 | |
|
243 | |
|
244 | |
|
245 | |
public Object getElement(int index) { |
246 | 0 | return getResult().get(index); |
247 | |
} |
248 | |
|
249 | |
|
250 | |
public Iterator getIterator() { |
251 | 0 | return iterator(); |
252 | |
} |
253 | |
|
254 | |
|
255 | |
public int getSize() { |
256 | 0 | return size(); |
257 | |
} |
258 | |
|
259 | |
|
260 | |
public boolean populate(Object o, int index) throws Exception { |
261 | 0 | Object bean = null; |
262 | 0 | if (size()>index) |
263 | 0 | bean = get(index); |
264 | 0 | if (bean==null) return false; |
265 | |
try { |
266 | 0 | BeanUtils.copyProperties(o,bean); |
267 | 0 | } catch (Throwable t) { |
268 | 0 | throw new ChainedException(t); |
269 | 0 | } |
270 | 0 | return true; |
271 | |
} |
272 | |
|
273 | |
|
274 | |
|
275 | |
|
276 | |
|
277 | |
|
278 | |
|
279 | |
|
280 | |
public ResultListBase() { |
281 | 0 | super(); |
282 | 0 | } |
283 | |
|
284 | |
|
285 | |
|
286 | |
|
287 | |
|
288 | |
public ResultListBase(Object o) { |
289 | 0 | super(); |
290 | 0 | add(o); |
291 | 0 | } |
292 | |
|
293 | |
|
294 | |
|
295 | |
|
296 | |
|
297 | |
public ResultListBase(Collection c) { |
298 | 0 | super(); |
299 | 0 | addAll(c); |
300 | 0 | } |
301 | |
|
302 | |
} |