ilog.cpl.table
Class IlpTableAttributeComparator

java.lang.Object
  extended by ilog.cpl.util.IlpAbstractComparator
      extended by ilog.cpl.util.IlpAttributeComparator
          extended by ilog.cpl.table.IlpTableAttributeComparator
All Implemented Interfaces:
IlpMutableComparator, Comparator

public class IlpTableAttributeComparator
extends IlpAttributeComparator

This class is used to sort columns of an IlpTableView. Attributes can be sorted by comparing either their raw value or the value displayed in the table.

This comparator must have an attribute to base the comparison on, otherwise it could not provide an order and would not be a real comparator.

Since:
JTGO 3.0
See Also:
IlpAttributeComparator

Constructor Summary
IlpTableAttributeComparator(IlpTableView tableView, IlpAttribute attribute)
          Creates an attribute comparator for a particular IlpTableView.
IlpTableAttributeComparator(IlpTableView tableView, IlpAttribute attribute, boolean ascendingOrder, boolean useDisplayValue)
          Creates an attribute comparator for a particular IlpTableView.
IlpTableAttributeComparator(ilog.cpl.table.internal.IlpTableViewSupportContext suppContext, IlpAttribute attribute, boolean ascendingOrder, boolean useDisplayValue)
          Creates an attribute comparator.
 
Method Summary
protected  int compareObjectsByAttribute(Object row1, Object row2, IlpAttribute attribute)
          Compares the given objects according to the value of the attribute.
 boolean isUsingDisplayValue(IlpAttribute attribute)
          Returns true if the given attribute is sorted using display values.
 void removeSortedAttribute(IlpAttribute attribute)
          Removes an attribute from the sorted attributes in the list.
 void setDirectionAndOrder(IlpAttribute attribute, int order, boolean ascendingOrder)
          Sets the sorting direction and sorting order of the specified attribute.
 void setDirectionAndOrder(IlpAttribute attribute, int order, boolean ascendingOrder, boolean useDisplayValue)
          Sets the sorting direction and sorting order of the specified attribute.
 
Methods inherited from class ilog.cpl.util.IlpAttributeComparator
compare, getDirectionAndOrder, getSortedAttributesCount
 
Methods inherited from class ilog.cpl.util.IlpAbstractComparator
addChangeListener, fireStateChanged, removeChangeListener
 
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

IlpTableAttributeComparator

public IlpTableAttributeComparator(IlpTableView tableView,
                                   IlpAttribute attribute)
Creates an attribute comparator for a particular IlpTableView. An attribute must be given since the comparator must contain at least one attribute. This attribute will be sorted in ascending order and using raw values.

Parameters:
tableView - The table view containing the attributes this comparator will have to sort.
attribute - The first attribute used to sort the table.
Throws:
IllegalArgumentException - if the given table view or the given attribute equals null.

IlpTableAttributeComparator

public IlpTableAttributeComparator(IlpTableView tableView,
                                   IlpAttribute attribute,
                                   boolean ascendingOrder,
                                   boolean useDisplayValue)
Creates an attribute comparator for a particular IlpTableView. An attribute must be given since the comparator must contain at least one attribute.

Parameters:
tableView - The table view containing the attributes this comparator will have to sort.
attribute - The first attribute used to sort the table.
ascendingOrder - Specifies whether the attribute will be sorted in ascending (true) or descending order.
useDisplayValue - Specifies whether the attribute will be sorted using display values (true) or raw values.
Throws:
IllegalArgumentException - if the given table view or the given attribute equals null.

IlpTableAttributeComparator

public IlpTableAttributeComparator(ilog.cpl.table.internal.IlpTableViewSupportContext suppContext,
                                   IlpAttribute attribute,
                                   boolean ascendingOrder,
                                   boolean useDisplayValue)
Creates an attribute comparator. An attribute must be given since the comparator must contain at least one attribute.

This constructor is used internally and is shared between both swing and web versions. It's not documented.

Parameters:
suppContext - The table view support containing the attributes this comparator will have to sort.
attribute - The first attribute used to sort the table.
ascendingOrder - Specifies whether the attribute will be sorted in ascending (true) or descending order.
useDisplayValue - Specifies whether the attribute will be sorted using display values (true) or raw values.
Throws:
IllegalArgumentException - if the given table view or the given attribute equals null.
Method Detail

setDirectionAndOrder

public void setDirectionAndOrder(IlpAttribute attribute,
                                 int order,
                                 boolean ascendingOrder)
Sets the sorting direction and sorting order of the specified attribute. The attribute is sorted using raw values.

Overrides:
setDirectionAndOrder in class IlpAttributeComparator
Parameters:
attribute - The attribute to sort.
order - The sorting order of the attribute. If order is less than or equal to 0, the attribute is put in the first position. If order is greater than the current number of attributes used for the sort, the column is put in the last position. If the attribute is already sorted, its index or sorting direction is changed.
ascendingOrder - Specifies whether the attribute will be sorted in ascending (true) or descending order.
Throws:
IllegalArgumentException - if the given attribute equals null.

setDirectionAndOrder

public void setDirectionAndOrder(IlpAttribute attribute,
                                 int order,
                                 boolean ascendingOrder,
                                 boolean useDisplayValue)
Sets the sorting direction and sorting order of the specified attribute. The attribute is sorted using raw values.

Parameters:
attribute - The attribute to sort.
order - The sorting order of the attribute. If order is less than or equal to 0, the attribute is put in the first position. If order is greater than the current number of attributes used for the sort, the column is put in the last position. If the attribute is already sorted, its index or sorting direction is changed.
ascendingOrder - Specifies whether the attribute will be sorted in ascending (true) or descending order.
useDisplayValue - Specifies whether the attribute will be sorted using display values (true) or raw values.
Throws:
IllegalArgumentException - if the given attribute equals null.

isUsingDisplayValue

public boolean isUsingDisplayValue(IlpAttribute attribute)
Returns true if the given attribute is sorted using display values.

Parameters:
attribute - The attribute to sort.

removeSortedAttribute

public void removeSortedAttribute(IlpAttribute attribute)
Removes an attribute from the sorted attributes in the list.

Overrides:
removeSortedAttribute in class IlpAttributeComparator
Parameters:
attribute - The attribute to remove.
Throws:
UnsupportedOperationException - if the attribute to remove is the last one.

compareObjectsByAttribute

protected int compareObjectsByAttribute(Object row1,
                                        Object row2,
                                        IlpAttribute attribute)
Compares the given objects according to the value of the attribute. This method assumes the given objects are IlpAttributeValueHolder instances.

Overrides:
compareObjectsByAttribute in class IlpAttributeComparator
Returns:
A value 0 if both objects are equivalent. A value less than 0 if the first object is meant to be before the second object. A value greater than 0 if the first object is meant to be after the second object.
See Also:
isUsingDisplayValue(IlpAttribute), setDirectionAndOrder(IlpAttribute, int, boolean)


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.   . All Rights Reserved.