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

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

Return to bug 9114