public class IlpTableAttributeComparator extends IlpAttributeComparator
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.
IlpAttributeComparator
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
compare, getDirectionAndOrder, getSortedAttributesCount
addChangeListener, fireStateChanged, removeChangeListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
public IlpTableAttributeComparator(IlpTableView tableView, IlpAttribute attribute)
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.tableView
- The table view containing the attributes this comparator
will have to sort.attribute
- The first attribute used to sort the table.IllegalArgumentException
- if the given table view or the given
attribute equals null
.public IlpTableAttributeComparator(IlpTableView tableView, IlpAttribute attribute, boolean ascendingOrder, boolean useDisplayValue)
IlpTableView
.
An attribute must be given since the comparator must contain at least one
attribute.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.IllegalArgumentException
- if the given table view or the given
attribute equals null
.public IlpTableAttributeComparator(ilog.cpl.table.internal.IlpTableViewSupportContext suppContext, IlpAttribute attribute, boolean ascendingOrder, boolean useDisplayValue)
This constructor is used internally and is shared between both swing and web versions. It's not documented.
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.IllegalArgumentException
- if the given table view or the given
attribute equals null
.public void setDirectionAndOrder(IlpAttribute attribute, int order, boolean ascendingOrder)
setDirectionAndOrder
in class IlpAttributeComparator
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.IllegalArgumentException
- if the given attribute equals
null
.public void setDirectionAndOrder(IlpAttribute attribute, int order, boolean ascendingOrder, boolean useDisplayValue)
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.IllegalArgumentException
- if the given attribute equals
null
.public boolean isUsingDisplayValue(IlpAttribute attribute)
true
if the given attribute is sorted using display
values.attribute
- The attribute to sort.public void removeSortedAttribute(IlpAttribute attribute)
removeSortedAttribute
in class IlpAttributeComparator
attribute
- The attribute to remove.UnsupportedOperationException
- if the attribute to remove is
the last one.protected int compareObjectsByAttribute(Object row1, Object row2, IlpAttribute attribute)
IlpAttributeValueHolder
instances.compareObjectsByAttribute
in class IlpAttributeComparator
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.isUsingDisplayValue(IlpAttribute)
,
setDirectionAndOrder(IlpAttribute, int, boolean)
© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.