|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.taursys.model.VOComparator
VOComparator
is a Comparator
for sorting value
objects in a VOListValueHolder
. This can sort by one or more
properties of the value object. Ascending or descending can be specified
for each property (default is ascending).
To sort by a single property, use the setPropertyName
method.
To sort by more than one property use the setPropertyNames
method and pass it a String[]
array of property names.
To change the order for a single property, use the
setAscendingOrder
method (true
=Ascending
false
=descending). To change the order for multiple properties,
use the setAscendingOrders
method and pass it a
boolean[]
array. The order of the ascending order indicators
should match the array of property names.
This VOComparator
is then attached to the
VOListValueHolder
using the setComparator
method.
IMPORTANT: This VOComparator can only be used with one VOListValueHolder
at a time - it cannot be shared.
Example - sort ascending by a lastName
VOListValueHolder holder = new VOListValueHolder(); VOComparator comparator = new VOComparator(); ... comparator.setPropertyName("lastName"); holder.setComparator(comparator);
Example - sort ascending by a salary(descending), yearsWorked(ascending)
VOListValueHolder holder = new VOListValueHolder(); VOComparator comparator = new VOComparator(); ... comparator.setPropertyNames(new String[] {"salary", "yearsWorked"}); comparator.setAscendingOrders(new boolean[] {false, true}); holder.setComparator(comparator);
Constructor Summary | |
VOComparator()
Constructs a new VOComparator |
Method Summary | |
int |
compare(java.lang.Object o1,
java.lang.Object o2)
Compare the two given value objects based on the propertyName(s)
and ascendingOrder(s) . |
boolean[] |
getAscendingOrders()
Get the ascending order flags for each of the properties. |
java.lang.String |
getPropertyName()
Get the first or only propertyName used for the comparison. |
java.lang.String[] |
getPropertyNames()
Get the propertyNames (in order) used for the comparison. |
VOValueHolder |
getVOValueHolder()
Get the VOValueHolder that this comparator is linked to. |
boolean |
isAscendingOrder()
Get the ascending order flag for the first or only propertyName. |
void |
setAscendingOrder(boolean ascendingOrder)
Set the ascending order flag for the first or only propertyName. |
void |
setAscendingOrders(boolean[] ascendingOrders)
Set the ascending order flags for each of the properties. |
void |
setPropertyName(java.lang.String propertyName)
Set the first or only propertyName used for the comparison. |
void |
setPropertyNames(java.lang.String[] propertyNames)
Set the propertyNames (in order) used for the comparison. |
void |
setVOValueHolder(VOValueHolder holder)
Set the VOValueHolder that this comparator is linked to. |
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 |
public VOComparator()
Method Detail |
public int compare(java.lang.Object o1, java.lang.Object o2)
propertyName(s)
and ascendingOrder(s)
. Return 0 if they are equal, negative
value if o1
should appear before o2
in the list,
or positive if o1
should appear after o2
in the
list. If both o1
and o2
are null, they are
considered equal. If one is null and the other not null, the null value
will appear before the non-null value in the list. The same null rule holds
true for the property values.
compare
in interface java.util.Comparator
o1
- the object to base the comparison ono2
- the object to compare to
public void setVOValueHolder(VOValueHolder holder)
holder
- the VOValueHolder that this comparator is linked to.public VOValueHolder getVOValueHolder()
public void setPropertyName(java.lang.String propertyName)
propertyName
- the first or only propertyName used for the comparison.public java.lang.String getPropertyName()
public void setAscendingOrder(boolean ascendingOrder)
ascendingOrder
- the ascending order flag for the first or only
propertyName.public boolean isAscendingOrder()
public void setPropertyNames(java.lang.String[] propertyNames)
propertyNames
- the propertyNames (in order) used for the comparison.public java.lang.String[] getPropertyNames()
public void setAscendingOrders(boolean[] ascendingOrders)
ascendingOrders
- the ascending order flags for each of the properties.public boolean[] getAscendingOrders()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |