View | Details | Raw Unified | Return to bug 9114
Collapse All | Expand All

(-)RowRecordsAggregate.java (-9 / +54 lines)
Line 62 Link Here
62
import java.util.HashMap;
62
import java.util.TreeMap;
63
--
Line 65 Link Here
65
import java.util.Comparator;
Line 69 Link Here
70
 * @author Tal Moshaiov (talm@vistaportal.com)
Line 76 Link Here
76
    HashMap records  = null;
78
    TreeMap records  = null;
77
--
Line 80 Link Here
80
Line 83 Link Here
83
        records = new HashMap();
84
        records = new TreeMap(new RowRecordsComparator());
84
--
Line 219 Link Here
219
}
220
    
220
--
221
    /**
222
     * compares between two row records according to their row number
223
     */
224
    private class RowRecordsComparator implements Comparator
225
    {
226
        /**
227
         * Object equality, implemented as object identity
228
         * @param o Object we're being compared to
229
         * @return true if identical, else false
230
         */
231
        public boolean equals(Object obj)
232
        {
233
            return this == obj;
234
        }
235
        
236
        /**
237
         * compare method. Checks if any of the parameters is null or not 
238
         * instances of RowRecord. 
239
         * One row is less than another if its row number is smaller than
240
         * the other's. 
241
         *
242
         * @param row1 first object to compare, better be a RowRecord
243
         * @param row2 second object to compare, better be a RowRecord
244
         *
245
         * @return negative value if row1 < row2,
246
         *         zero           if row1 == row2,
247
         *         positive value if row1 >  row2.
248
         */      
249
        public  int compare(Object row1, Object row2) {
250
          //if any of the records is null, return not equal
251
          if (row1 == null || row2 == null)
252
            return -1;
253
          //if any of the objects isn't a RowRecrod, return not equal
254
          if (!(row2 instanceof RowRecord && row2 instanceof RowRecord))
255
            return -1;
256
          //get row numbers of both row records
257
          int row1Number = ((RowRecord)row1).getRowNumber();
258
          int row2Number = ((RowRecord)row2).getRowNumber();
259
          //compare row numbers and return result
260
          if (row1Number == row2Number)
261
            return 0;
262
          else if (row1Number < row2Number)
263
            return -1;
264
          else
265
            return 1;
266
        }    
267
    }//end private class RowRecordsComparator  
268
}

Return to bug 9114