|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.zkoss.zul.FieldComparator
public class FieldComparator
Based on the the given field names to compare the field value of the object
that is passed in compare(java.lang.Object, java.lang.Object)
method.
The field names accept compound "a.b.c" expression. It also accept multiple field names that you can give expression in the form of e.g. "name, age, salary" and this comparator will compare in that sequence.
Constructor Summary | |
---|---|
FieldComparator(java.lang.String orderBy,
boolean ascending)
Compares with the fields per the given "ORDER BY" clause. |
|
FieldComparator(java.lang.String orderBy,
boolean ascending,
boolean nullAsMax)
Compares with the fields per the given "ORDER BY" clause. |
Method Summary | |
---|---|
int |
compare(java.lang.Object o1,
java.lang.Object o2)
|
java.lang.String |
getOrderBy()
Returns the order-by clause. |
java.lang.String |
getRawOrderBy()
Returns the original order-by claused passed to the constructor. |
boolean |
isAscending()
Returns whether the sorting is ascending. |
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 FieldComparator(java.lang.String orderBy, boolean ascending)
Note: It assumes null as minimum value.
If not, use FieldComparator(String, boolean, boolean)
instead.
orderBy
- the "ORDER BY" clause to be compared upon for the given object in compare(java.lang.Object, java.lang.Object)
.ascending
- whether to sort as ascending (or descending).public FieldComparator(java.lang.String orderBy, boolean ascending, boolean nullAsMax)
orderBy
- the "ORDER BY" clause to be compared upon for the given object in compare(java.lang.Object, java.lang.Object)
.ascending
- whether to sort as ascending (or descending).nullAsMax
- whether to consider null as the maximum value.
If false, null is considered as the minimum value.Method Detail |
---|
public int compare(java.lang.Object o1, java.lang.Object o2)
compare
in interface java.util.Comparator
public java.lang.String getOrderBy()
name=category ASC
.
For the original format, please use getRawOrderBy()
.
public java.lang.String getRawOrderBy()
category
,
or a concatenation of field names, such as category.name
.
Notice that, with the field's name, you could retrieve the value
by use of Fields.getByCompound(java.lang.Object, java.lang.String)
.
public boolean isAscending()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |