JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.util.swing
Class DefaultRowComparator

java.lang.Object
  |
  +--com.klg.jclass.util.swing.DefaultRowComparator
All Implemented Interfaces:
JCRowComparator, Serializable

public class DefaultRowComparator
extends Object
implements JCRowComparator, Serializable

This class is to be used with JCRowSortModel. It sorts rows by the list of columns specified. By default it only sorts on the first column

See Also:
Serialized Form

Field Summary
static int FORWARD
          Valid value for SortOrder
protected  int[] keyColumns
           
protected  int order
           
static int REVERSE
          Valid value for SortOrder
 
Constructor Summary
DefaultRowComparator(int order)
          Creates a JCRowComparator that sorts columns by the natural order of the values in the first column.
DefaultRowComparator(int order, int[] keyColumns)
          Creates a JCRowComparator that sorts columns according with the list of columns specified.
 
Method Summary
 int compare(com.klg.jclass.util.swing.JCComparableRow row1, com.klg.jclass.util.swing.JCComparableRow row2)
          Compares its two arguments for order.
 int[] getKeyColumns()
          Gets a list of columns by which to sort.
 int getSortOrder()
          Gets a sorting order.
 void setKeyColumns(int[] keyColumns)
          Sets a list of columns by which to sort.
 void setSortOrder(int order)
          Sets a sorting order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FORWARD

public static final int FORWARD
Valid value for SortOrder

See Also:
Constant Field Values

REVERSE

public static final int REVERSE
Valid value for SortOrder

See Also:
Constant Field Values

order

protected int order

keyColumns

protected int[] keyColumns
Constructor Detail

DefaultRowComparator

public DefaultRowComparator(int order)
Creates a JCRowComparator that sorts columns by the natural order of the values in the first column.

Parameters:
order - The sort order (FORWARD or REVERSE)

DefaultRowComparator

public DefaultRowComparator(int order,
                            int[] keyColumns)
Creates a JCRowComparator that sorts columns according with the list of columns specified.

Parameters:
order - The sort order (FORWARD or REVERSE)
keyColumns - A list of columns by which to sort
Method Detail

setKeyColumns

public void setKeyColumns(int[] keyColumns)
Sets a list of columns by which to sort.

Specified by:
setKeyColumns in interface JCRowComparator
Parameters:
keyColumns - The new list of columns by which to sort

getKeyColumns

public int[] getKeyColumns()
Gets a list of columns by which to sort.

Specified by:
getKeyColumns in interface JCRowComparator
Returns:
The list of columns by which to sort

setSortOrder

public void setSortOrder(int order)
Sets a sorting order.

Specified by:
setSortOrder in interface JCRowComparator
Parameters:
order - The new sort order (FORWARD or REVERSE)

getSortOrder

public int getSortOrder()
Gets a sorting order.

Specified by:
getSortOrder in interface JCRowComparator
Returns:
The current sort order (FORWARD or REVERSE)

compare

public int compare(com.klg.jclass.util.swing.JCComparableRow row1,
                   com.klg.jclass.util.swing.JCComparableRow row2)
Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second respectively.

Specified by:
compare in interface JCRowComparator
Parameters:
row1 - The row of the first argument in the compare
row2 - The row of the second argument in the compare
Returns:
A negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second respectively.

Copyright © 2004 Quest Software Inc..
All rights reserved.