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

Variable Index

 o ASCENDING
Ascending sort order.
 o DEFAULT_COMPARATOR
Default comparator (StringComparator).
 o DEFAULT_ORDER
Default sort order (ASCENDING).
 o DESCENDING
Descending sort order.

Constructor Index

 o Sorter()

Method Index

 o getComparator()
Gets the current comparator for this sorter.
 o getSortOrder()
Returns the current sort order.
 o setComparator(Comparator)
Sets the comparator for this sorter.
 o setSortOrder(int)
Sets the sort order.
 o sort(Object[])
Sorts incoming array of objects and returns the sorted indexes of the original array.
 o toString()
Returns a text representation of this Sorter instance.

Variables

 o ASCENDING
 public static final int ASCENDING
Ascending sort order.

 o DESCENDING
 public static final int DESCENDING
Descending sort order.

 o DEFAULT_ORDER
 public static final int DEFAULT_ORDER
Default sort order (ASCENDING).

 o DEFAULT_COMPARATOR
 public static final Comparator DEFAULT_COMPARATOR
Default comparator (StringComparator).

Constructors

 o Sorter
 public Sorter()

Methods

 o 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
 o setSortOrder
 public void setSortOrder(int order)
Sets the sort order.

Parameters:
order - The new sort order.
See Also:
sort, getSortOrder
 o getSortOrder
 public int getSortOrder()
Returns the current sort order.

See Also:
sort, setSortOrder
 o 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
 o getComparator
 public Comparator getComparator()
Gets the current comparator for this sorter.

Returns:
Returns the current comparator.
See Also:
setComparator
 o 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