|
@@ -27,13 +27,11 @@ |
27 |
27 |
|
* <p/> |
28 |
28 |
|
* This class should be removed once this bug is fixed. |
29 |
29 |
|
*/ |
30 |
|
- |
public final class TableModelHelper |
31 |
|
- |
{ |
|
30 |
+ |
public final class TableModelHelper { |
32 |
31 |
|
/** |
33 |
32 |
|
* Information about the sort order of a specific column in a table. |
34 |
33 |
|
*/ |
35 |
|
- |
public static class ColumnSortInfo implements Serializable |
36 |
|
- |
{ |
|
34 |
+ |
public static class ColumnSortInfo implements Serializable { |
37 |
35 |
|
/** |
38 |
36 |
|
* True if the sort order is ascending. |
39 |
37 |
|
*/ |
|
@@ -47,8 +45,7 @@ |
47 |
45 |
|
/** |
48 |
46 |
|
* Default constructor used for RPC. |
49 |
47 |
|
*/ |
50 |
|
- |
public ColumnSortInfo() |
51 |
|
- |
{ |
|
48 |
+ |
public ColumnSortInfo() { |
52 |
49 |
|
this( 0, true ); |
53 |
50 |
|
} |
54 |
51 |
|
|
|
@@ -58,17 +55,14 @@ |
58 |
55 |
|
* @param column the column index |
59 |
56 |
|
* @param ascending true if sorted ascending |
60 |
57 |
|
*/ |
61 |
|
- |
public ColumnSortInfo( int column, boolean ascending ) |
62 |
|
- |
{ |
|
58 |
+ |
public ColumnSortInfo( int column, boolean ascending ) { |
63 |
59 |
|
this.column = column; |
64 |
60 |
|
this.ascending = ascending; |
65 |
61 |
|
} |
66 |
62 |
|
|
67 |
63 |
|
@Override |
68 |
|
- |
public boolean equals( Object obj ) |
69 |
|
- |
{ |
70 |
|
- |
if ( obj instanceof ColumnSortInfo ) |
71 |
|
- |
{ |
|
64 |
+ |
public boolean equals( Object obj ) { |
|
65 |
+ |
if ( obj instanceof ColumnSortInfo ) { |
72 |
66 |
|
return equals( (ColumnSortInfo) obj ); |
73 |
67 |
|
} |
74 |
68 |
|
return false; |
|
@@ -82,10 +76,8 @@ |
82 |
76 |
|
* |
83 |
77 |
|
* @return true if objects are the same |
84 |
78 |
|
*/ |
85 |
|
- |
public boolean equals( ColumnSortInfo csi ) |
86 |
|
- |
{ |
87 |
|
- |
if ( csi == null ) |
88 |
|
- |
{ |
|
79 |
+ |
public boolean equals( ColumnSortInfo csi ) { |
|
80 |
+ |
if ( csi == null ) { |
89 |
81 |
|
return false; |
90 |
82 |
|
} |
91 |
83 |
|
return getColumn() == csi.getColumn() && isAscending() == csi.isAscending(); |
|
@@ -94,22 +86,19 @@ |
94 |
86 |
|
/** |
95 |
87 |
|
* @return the column index |
96 |
88 |
|
*/ |
97 |
|
- |
public int getColumn() |
98 |
|
- |
{ |
|
89 |
+ |
public int getColumn() { |
99 |
90 |
|
return column; |
100 |
91 |
|
} |
101 |
92 |
|
|
102 |
93 |
|
@Override |
103 |
|
- |
public int hashCode() |
104 |
|
- |
{ |
|
94 |
+ |
public int hashCode() { |
105 |
95 |
|
return super.hashCode(); |
106 |
96 |
|
} |
107 |
97 |
|
|
108 |
98 |
|
/** |
109 |
99 |
|
* @return true if ascending, false if descending |
110 |
100 |
|
*/ |
111 |
|
- |
public boolean isAscending() |
112 |
|
- |
{ |
|
101 |
+ |
public boolean isAscending() { |
113 |
102 |
|
return ascending; |
114 |
103 |
|
} |
115 |
104 |
|
|
|
@@ -118,8 +107,7 @@ |
118 |
107 |
|
* |
119 |
108 |
|
* @param ascending true if ascending, false if descending |
120 |
109 |
|
*/ |
121 |
|
- |
public void setAscending( boolean ascending ) |
122 |
|
- |
{ |
|
110 |
+ |
public void setAscending( boolean ascending ) { |
123 |
111 |
|
this.ascending = ascending; |
124 |
112 |
|
} |
125 |
113 |
|
|
|
@@ -128,8 +116,7 @@ |
128 |
116 |
|
* |
129 |
117 |
|
* @param column the column index |
130 |
118 |
|
*/ |
131 |
|
- |
public void setColumn( int column ) |
132 |
|
- |
{ |
|
119 |
+ |
public void setColumn( int column ) { |
133 |
120 |
|
this.column = column; |
134 |
121 |
|
} |
135 |
122 |
|
} |
|
@@ -140,8 +127,7 @@ |
140 |
127 |
|
* is the first tie-breaker, and so on. |
141 |
128 |
|
*/ |
142 |
129 |
|
public static class ColumnSortList implements Serializable, |
143 |
|
- |
Iterable<ColumnSortInfo> |
144 |
|
- |
{ |
|
130 |
+ |
Iterable<ColumnSortInfo> { |
145 |
131 |
|
/** |
146 |
132 |
|
* A List used to manage the insertion/removal of {@link ColumnSortInfo}. |
147 |
133 |
|
*/ |
|
@@ -157,8 +143,7 @@ |
157 |
143 |
|
* |
158 |
144 |
|
* @param sortInfo the {@link ColumnSortInfo} to add |
159 |
145 |
|
*/ |
160 |
|
- |
public void add( ColumnSortInfo sortInfo ) |
161 |
|
- |
{ |
|
146 |
+ |
public void add( ColumnSortInfo sortInfo ) { |
162 |
147 |
|
add( 0, sortInfo ); |
163 |
148 |
|
} |
164 |
149 |
|
|
|
@@ -169,19 +154,15 @@ |
169 |
154 |
|
* |
170 |
155 |
|
* @param sortInfo the {@link ColumnSortInfo} to add |
171 |
156 |
|
*/ |
172 |
|
- |
public void add( int index, ColumnSortInfo sortInfo ) |
173 |
|
- |
{ |
|
157 |
+ |
public void add( int index, ColumnSortInfo sortInfo ) { |
174 |
158 |
|
// Remove sort info for duplicate columns |
175 |
159 |
|
int column = sortInfo.getColumn(); |
176 |
|
- |
for ( int i = 0; i < infos.size(); i++ ) |
177 |
|
- |
{ |
|
160 |
+ |
for ( int i = 0; i < infos.size(); i++ ) { |
178 |
161 |
|
ColumnSortInfo curInfo = infos.get( i ); |
179 |
|
- |
if ( curInfo.getColumn() == column ) |
180 |
|
- |
{ |
|
162 |
+ |
if ( curInfo.getColumn() == column ) { |
181 |
163 |
|
infos.remove( i ); |
182 |
164 |
|
i--; |
183 |
|
- |
if ( column < index ) |
184 |
|
- |
{ |
|
165 |
+ |
if ( column < index ) { |
185 |
166 |
|
index--; |
186 |
167 |
|
} |
187 |
168 |
|
} |
|
@@ -194,16 +175,13 @@ |
194 |
175 |
|
/** |
195 |
176 |
|
* Removes all of the elements from this list. |
196 |
177 |
|
*/ |
197 |
|
- |
public void clear() |
198 |
|
- |
{ |
|
178 |
+ |
public void clear() { |
199 |
179 |
|
infos.clear(); |
200 |
180 |
|
} |
201 |
181 |
|
|
202 |
182 |
|
@Override |
203 |
|
- |
public boolean equals( Object obj ) |
204 |
|
- |
{ |
205 |
|
- |
if ( obj instanceof ColumnSortList ) |
206 |
|
- |
{ |
|
183 |
+ |
public boolean equals( Object obj ) { |
|
184 |
+ |
if ( obj instanceof ColumnSortList ) { |
207 |
185 |
|
return equals( (ColumnSortList) obj ); |
208 |
186 |
|
} |
209 |
187 |
|
return false; |
|
@@ -216,26 +194,21 @@ |
216 |
194 |
|
* |
217 |
195 |
|
* @return true if objects are equal |
218 |
196 |
|
*/ |
219 |
|
- |
public boolean equals( ColumnSortList csl ) |
220 |
|
- |
{ |
|
197 |
+ |
public boolean equals( ColumnSortList csl ) { |
221 |
198 |
|
// Object is null |
222 |
|
- |
if ( csl == null ) |
223 |
|
- |
{ |
|
199 |
+ |
if ( csl == null ) { |
224 |
200 |
|
return false; |
225 |
201 |
|
} |
226 |
202 |
|
|
227 |
203 |
|
// Check the size of the lists |
228 |
204 |
|
int size = size(); |
229 |
|
- |
if ( size != csl.size() ) |
230 |
|
- |
{ |
|
205 |
+ |
if ( size != csl.size() ) { |
231 |
206 |
|
return false; |
232 |
207 |
|
} |
233 |
208 |
|
|
234 |
209 |
|
// Compare the entries |
235 |
|
- |
for ( int i = 0; i < size; i++ ) |
236 |
|
- |
{ |
237 |
|
- |
if ( !infos.get( i ).equals( csl.infos.get( i ) ) ) |
238 |
|
- |
{ |
|
210 |
+ |
for ( int i = 0; i < size; i++ ) { |
|
211 |
+ |
if ( !infos.get( i ).equals( csl.infos.get( i ) ) ) { |
239 |
212 |
|
return false; |
240 |
213 |
|
} |
241 |
214 |
|
} |
|
@@ -249,11 +222,9 @@ |
249 |
222 |
|
* |
250 |
223 |
|
* @return the primary column or -1 if not sorted |
251 |
224 |
|
*/ |
252 |
|
- |
public int getPrimaryColumn() |
253 |
|
- |
{ |
|
225 |
+ |
public int getPrimaryColumn() { |
254 |
226 |
|
ColumnSortInfo primaryInfo = getPrimaryColumnSortInfo(); |
255 |
|
- |
if ( primaryInfo == null ) |
256 |
|
- |
{ |
|
227 |
+ |
if ( primaryInfo == null ) { |
257 |
228 |
|
return -1; |
258 |
229 |
|
} |
259 |
230 |
|
return primaryInfo.getColumn(); |
|
@@ -264,18 +235,15 @@ |
264 |
235 |
|
* |
265 |
236 |
|
* @return the primary column sort info |
266 |
237 |
|
*/ |
267 |
|
- |
public ColumnSortInfo getPrimaryColumnSortInfo() |
268 |
|
- |
{ |
269 |
|
- |
if ( infos.size() > 0 ) |
270 |
|
- |
{ |
|
238 |
+ |
public ColumnSortInfo getPrimaryColumnSortInfo() { |
|
239 |
+ |
if ( infos.size() > 0 ) { |
271 |
240 |
|
return infos.get( 0 ); |
272 |
241 |
|
} |
273 |
242 |
|
return null; |
274 |
243 |
|
} |
275 |
244 |
|
|
276 |
245 |
|
@Override |
277 |
|
- |
public int hashCode() |
278 |
|
- |
{ |
|
246 |
+ |
public int hashCode() { |
279 |
247 |
|
return super.hashCode(); |
280 |
248 |
|
} |
281 |
249 |
|
|
|
@@ -284,18 +252,15 @@ |
284 |
252 |
|
* |
285 |
253 |
|
* @return true if ascending, false if descending |
286 |
254 |
|
*/ |
287 |
|
- |
public boolean isPrimaryAscending() |
288 |
|
- |
{ |
|
255 |
+ |
public boolean isPrimaryAscending() { |
289 |
256 |
|
ColumnSortInfo primaryInfo = getPrimaryColumnSortInfo(); |
290 |
|
- |
if ( primaryInfo == null ) |
291 |
|
- |
{ |
|
257 |
+ |
if ( primaryInfo == null ) { |
292 |
258 |
|
return true; |
293 |
259 |
|
} |
294 |
260 |
|
return primaryInfo.isAscending(); |
295 |
261 |
|
} |
296 |
262 |
|
|
297 |
|
- |
public Iterator<ColumnSortInfo> iterator() |
298 |
|
- |
{ |
|
263 |
+ |
public Iterator<ColumnSortInfo> iterator() { |
299 |
264 |
|
return new ImmutableIterator<ColumnSortInfo>( infos.iterator() ); |
300 |
265 |
|
} |
301 |
266 |
|
|
|
@@ -304,27 +269,23 @@ |
304 |
269 |
|
* |
305 |
270 |
|
* @param sortInfo the {@link ColumnSortInfo} to remove |
306 |
271 |
|
*/ |
307 |
|
- |
public boolean remove( Object sortInfo ) |
308 |
|
- |
{ |
|
272 |
+ |
public boolean remove( Object sortInfo ) { |
309 |
273 |
|
return infos.remove( sortInfo ); |
310 |
274 |
|
} |
311 |
275 |
|
|
312 |
276 |
|
/** |
313 |
277 |
|
* @return the number of {@link ColumnSortInfo} in the list |
314 |
278 |
|
*/ |
315 |
|
- |
public int size() |
316 |
|
- |
{ |
|
279 |
+ |
public int size() { |
317 |
280 |
|
return infos.size(); |
318 |
281 |
|
} |
319 |
282 |
|
|
320 |
283 |
|
/** |
321 |
284 |
|
* @return a duplicate of this list |
322 |
285 |
|
*/ |
323 |
|
- |
ColumnSortList copy() |
324 |
|
- |
{ |
|
286 |
+ |
ColumnSortList copy() { |
325 |
287 |
|
ColumnSortList copy = new ColumnSortList(); |
326 |
|
- |
for ( ColumnSortInfo info : this ) |
327 |
|
- |
{ |
|
288 |
+ |
for ( ColumnSortInfo info : this ) { |
328 |
289 |
|
copy.infos.add( new ColumnSortInfo( info.getColumn(), info.isAscending() ) ); |
329 |
290 |
|
} |
330 |
291 |
|
return copy; |
|
@@ -334,8 +295,7 @@ |
334 |
295 |
|
/** |
335 |
296 |
|
* A {@link TableModelHelper} request. |
336 |
297 |
|
*/ |
337 |
|
- |
public static class Request implements Serializable |
338 |
|
- |
{ |
|
298 |
+ |
public static class Request implements Serializable { |
339 |
299 |
|
private static final long serialVersionUID = 1L; |
340 |
300 |
|
|
341 |
301 |
|
/** |
|
@@ -356,8 +316,7 @@ |
356 |
316 |
|
/** |
357 |
317 |
|
* Default constructor used for RPC. |
358 |
318 |
|
*/ |
359 |
|
- |
public Request() |
360 |
|
- |
{ |
|
319 |
+ |
public Request() { |
361 |
320 |
|
this( 0, 0, null ); |
362 |
321 |
|
} |
363 |
322 |
|
|
|
@@ -367,8 +326,7 @@ |
367 |
326 |
|
* @param startRow the first row to request |
368 |
327 |
|
* @param numRows the number of rows to request |
369 |
328 |
|
*/ |
370 |
|
- |
public Request( int startRow, int numRows ) |
371 |
|
- |
{ |
|
329 |
+ |
public Request( int startRow, int numRows ) { |
372 |
330 |
|
this( startRow, numRows, null ); |
373 |
331 |
|
} |
374 |
332 |
|
|
|
@@ -380,8 +338,7 @@ |
380 |
338 |
|
* @param numRows the number of rows to request |
381 |
339 |
|
* @param columnSortList a list of {@link ColumnSortInfo} |
382 |
340 |
|
*/ |
383 |
|
- |
public Request( int startRow, int numRows, ColumnSortList columnSortList ) |
384 |
|
- |
{ |
|
341 |
+ |
public Request( int startRow, int numRows, ColumnSortList columnSortList ) { |
385 |
342 |
|
this.startRow = startRow; |
386 |
343 |
|
this.numRows = numRows; |
387 |
344 |
|
this.columnSortList = columnSortList; |
|
@@ -390,24 +347,21 @@ |
390 |
347 |
|
/** |
391 |
348 |
|
* @return the list of {@link ColumnSortInfo} |
392 |
349 |
|
*/ |
393 |
|
- |
public ColumnSortList getColumnSortList() |
394 |
|
- |
{ |
|
350 |
+ |
public ColumnSortList getColumnSortList() { |
395 |
351 |
|
return columnSortList; |
396 |
352 |
|
} |
397 |
353 |
|
|
398 |
354 |
|
/** |
399 |
355 |
|
* @return the number of requested rows |
400 |
356 |
|
*/ |
401 |
|
- |
public int getNumRows() |
402 |
|
- |
{ |
|
357 |
+ |
public int getNumRows() { |
403 |
358 |
|
return numRows; |
404 |
359 |
|
} |
405 |
360 |
|
|
406 |
361 |
|
/** |
407 |
362 |
|
* @return the first requested row |
408 |
363 |
|
*/ |
409 |
|
- |
public int getStartRow() |
410 |
|
- |
{ |
|
364 |
+ |
public int getStartRow() { |
411 |
365 |
|
return startRow; |
412 |
366 |
|
} |
413 |
367 |
|
} |
|
@@ -417,8 +371,7 @@ |
417 |
371 |
|
* |
418 |
372 |
|
* @param <RowType> the data type of the row values |
419 |
373 |
|
*/ |
420 |
|
- |
public abstract static class Response<RowType> |
421 |
|
- |
{ |
|
374 |
+ |
public abstract static class Response<RowType> { |
422 |
375 |
|
/** |
423 |
376 |
|
* Get the objects associated with the retrieved rows. |
424 |
377 |
|
* |
|
@@ -433,8 +386,7 @@ |
433 |
386 |
|
* |
434 |
387 |
|
* @param <RowType> the serializable data type of the row values |
435 |
388 |
|
*/ |
436 |
|
- |
public static class SerializableResponse<RowType extends Serializable> extends Response<RowType> implements Serializable |
437 |
|
- |
{ |
|
389 |
+ |
public static class SerializableResponse<RowType extends Serializable> extends Response<RowType> implements Serializable { |
438 |
390 |
|
/** |
439 |
391 |
|
* The {@link Collection} of row values. |
440 |
392 |
|
*/ |
|
@@ -443,22 +395,19 @@ |
443 |
395 |
|
/** |
444 |
396 |
|
* Default constructor used for RPC. |
445 |
397 |
|
*/ |
446 |
|
- |
public SerializableResponse() |
447 |
|
- |
{ |
|
398 |
+ |
public SerializableResponse() { |
448 |
399 |
|
this( null ); |
449 |
400 |
|
} |
450 |
401 |
|
|
451 |
402 |
|
/** |
452 |
403 |
|
* Create a new {@link SerializableResponse}. |
453 |
404 |
|
*/ |
454 |
|
- |
public SerializableResponse( Collection<RowType> rowValues ) |
455 |
|
- |
{ |
|
405 |
+ |
public SerializableResponse( Collection<RowType> rowValues ) { |
456 |
406 |
|
this.rowValues = rowValues; |
457 |
407 |
|
} |
458 |
408 |
|
|
459 |
409 |
|
@Override |
460 |
|
- |
public Iterator<RowType> getRowValues() |
461 |
|
- |
{ |
|
410 |
+ |
public Iterator<RowType> getRowValues() { |
462 |
411 |
|
return rowValues.iterator(); |
463 |
412 |
|
} |
464 |
413 |
|
} |
|
@@ -466,27 +415,22 @@ |
466 |
415 |
|
/** |
467 |
416 |
|
* Wrap an {@link Iterator} in an immutable iterator. |
468 |
417 |
|
*/ |
469 |
|
- |
private static class ImmutableIterator<E> implements Iterator<E> |
470 |
|
- |
{ |
|
418 |
+ |
private static class ImmutableIterator<E> implements Iterator<E> { |
471 |
419 |
|
private Iterator<E> iterator; |
472 |
420 |
|
|
473 |
|
- |
public ImmutableIterator( Iterator<E> iterator ) |
474 |
|
- |
{ |
|
421 |
+ |
public ImmutableIterator( Iterator<E> iterator ) { |
475 |
422 |
|
this.iterator = iterator; |
476 |
423 |
|
} |
477 |
424 |
|
|
478 |
|
- |
public boolean hasNext() |
479 |
|
- |
{ |
|
425 |
+ |
public boolean hasNext() { |
480 |
426 |
|
return iterator.hasNext(); |
481 |
427 |
|
} |
482 |
428 |
|
|
483 |
|
- |
public E next() |
484 |
|
- |
{ |
|
429 |
+ |
public E next() { |
485 |
430 |
|
return iterator.next(); |
486 |
431 |
|
} |
487 |
432 |
|
|
488 |
|
- |
public void remove() |
489 |
|
- |
{ |
|
433 |
+ |
public void remove() { |
490 |
434 |
|
throw (new UnsupportedOperationException()); |
491 |
435 |
|
} |
492 |
436 |
|
} |