All Packages Class Hierarchy This Package Previous Next Index
Class COM.taligent.util.Sorter
java.lang.Object
|
+----COM.taligent.util.Sorter
- public abstract class Sorter
- extends Object
- implements Serializable
This class must be extended to provide functionality of various
sorting algorithms. The only method that needs to be overridden
is sort(Object[]). The decendent must take the array of objects
sent in and sort them according to the comparator set for this
Sorter. Upon return, the original array is sorted and sort()
returns a sorted list of indexes of the original array. For an
example, see the source for COM.taligent.util.SelectionSorter.
- See Also:
- Comparator, SelectionSorter
-
ASCENDING
- Ascending sort order.
-
DEFAULT_COMPARATOR
- Default comparator (StringComparator).
-
DEFAULT_ORDER
- Default sort order (ASCENDING).
-
DESCENDING
- Descending sort order.
-
Sorter()
-
-
getComparator()
- Gets the current comparator for this sorter.
-
getSortOrder()
- Returns the current sort order.
-
setComparator(Comparator)
- Sets the comparator for this sorter.
-
setSortOrder(int)
- Sets the sort order.
-
sort(Object[])
- Sorts incoming array of objects and returns the sorted indexes
of the original array.
-
toString()
- Returns a text representation of this Sorter instance.
ASCENDING
public static final int ASCENDING
- Ascending sort order.
DESCENDING
public static final int DESCENDING
- Descending sort order.
DEFAULT_ORDER
public static final int DEFAULT_ORDER
- Default sort order (ASCENDING).
DEFAULT_COMPARATOR
public static final Comparator DEFAULT_COMPARATOR
- Default comparator (StringComparator).
Sorter
public Sorter()
sort
public abstract int[] sort(Object array[])
- Sorts incoming array of objects and returns the sorted indexes
of the original array. The order of the sort is determined by
the value returned by getOrder().
The descendent of this class MUST override this method.
- Parameters:
- array - The array of strings to be sorted.
- Returns:
- Returns an array of sorted indexes of the original array.
- See Also:
- setSortOrder, getSortOrder, setComparator, getComparator
setSortOrder
public void setSortOrder(int order)
- Sets the sort order.
- Parameters:
- order - The new sort order.
- See Also:
- sort, getSortOrder
getSortOrder
public int getSortOrder()
- Returns the current sort order.
- See Also:
- sort, setSortOrder
setComparator
public Sorter setComparator(Comparator comparator)
- Sets the comparator for this sorter.
- Parameters:
- comparator - The new comparator.
- Returns:
- Returns this so that multiple method calls can be
chained together.
- See Also:
- getComparator
getComparator
public Comparator getComparator()
- Gets the current comparator for this sorter.
- Returns:
- Returns the current comparator.
- See Also:
- setComparator
toString
public String toString()
- Returns a text representation of this Sorter instance.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index