com.ge.research.acuity.utils
Class SelectionListSortComparator

java.lang.Object
  extended bycom.ge.research.acuity.utils.SelectionListSortComparator
All Implemented Interfaces:
java.util.Comparator

public class SelectionListSortComparator
extends java.lang.Object
implements java.util.Comparator

Comparator for SelectionPO choices that allows for selection value/label pairs to be sorted by either value or label. Choices must be in an Object[] of size >=2

Version:
$Revision: 1.1 $ $Date: 2006/08/11 00:17:35 $
Author:
garbiras
Created on:
Nov 8, 2005

Constructor Summary
SelectionListSortComparator(int index, boolean sortDescending)
          Creates a new SelectionListSortComparator with prioritized sort columns, and current sort column index and sort orientation flag
 
Method Summary
 int compare(java.lang.Object o1List, java.lang.Object o2List)
          Compares two selection list choices.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

SelectionListSortComparator

public SelectionListSortComparator(int index,
                                   boolean sortDescending)
Creates a new SelectionListSortComparator with prioritized sort columns, and current sort column index and sort orientation flag

Parameters:
index - the array index to perform the sorting on 0 to sort on values, 1 to sort on labels
sortDescending - A flag indicating to sort in DESCending fashion if true, ASCending fashion if false
Method Detail

compare

public int compare(java.lang.Object o1List,
                   java.lang.Object o2List)
Compares two selection list choices. The comparator checks to make sure that each argument is a java.lang.Object[] containing the value/label data for the selection choice. The item at the current useIndex position within both arrays are extracted and compared. Depending on the type of data extracted and the value of the sortDescending flag, the values are compared and the method returns a -1 if o1List should come after o2List, 0 if o1List and o2List are equal, and 1 if o1List should come before o2List

Specified by:
compare in interface java.util.Comparator
See Also:
Comparator.compare(java.lang.Object, java.lang.Object)