com.mindtree.techworks.insight.model
Class ModelDataSorter

java.lang.Object
  extended by com.mindtree.techworks.insight.model.ModelDataSorter
All Implemented Interfaces:
java.util.Comparator

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

The ModelDataSorter class implements sorting of data held by the TableModel that it refers to. Provides methods to invoke sorting by specifying the column index and the data list. Maintains map of sorted columns and their sorting order such that consecutive calls to sort on a column flips the sorting order.

Version:
1.0, 04/11/03
Author:
Regunath B
See Also:
LoggingEvent

Field Summary
static int ASCENDING
           
static int DESCENDING
           
static int NOTSORTED
           
 
Constructor Summary
ModelDataSorter()
           
 
Method Summary
 int compare(java.lang.Object arg0, java.lang.Object arg1)
          Comparator interface method implementation
 int getSortOrder(int columnIndex)
          Returns the sort order for the column specified by the columnIndex
 void resetSortParams()
          Resets the parameters that define the sorting of this ModelDataSorter
 void sortData(int columnIndex, java.util.List data)
          Sorts the specified column data in the specified list.
 
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
 

Field Detail

ASCENDING

public static final int ASCENDING
See Also:
Constant Field Values

DESCENDING

public static final int DESCENDING
See Also:
Constant Field Values

NOTSORTED

public static final int NOTSORTED
See Also:
Constant Field Values
Constructor Detail

ModelDataSorter

public ModelDataSorter()
Method Detail

sortData

public void sortData(int columnIndex,
                     java.util.List data)
Sorts the specified column data in the specified list. Toggles the sort order if the column had been sorted previously. Does nothing if this sorter is already sorting data

Parameters:
columnIndex - index of the column whose data needs to be sorted
data - List containing data to be sorted

getSortOrder

public int getSortOrder(int columnIndex)
Returns the sort order for the column specified by the columnIndex

Parameters:
columnIndex - the index of the column whose sort order is needed
Returns:
the valid sort order as defined by this class

compare

public int compare(java.lang.Object arg0,
                   java.lang.Object arg1)
Comparator interface method implementation

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

resetSortParams

public void resetSortParams()
Resets the parameters that define the sorting of this ModelDataSorter



Copyright © 2003-2008 MindTree Consulting Ltd.. All Rights Reserved.