Class TreeitemComparator
- java.lang.Object
-
- org.zkoss.zul.TreeitemComparator
-
- All Implemented Interfaces:
java.io.Serializable
,java.util.Comparator
public class TreeitemComparator extends java.lang.Object implements java.util.Comparator, java.io.Serializable
A comparator used to compareTreeitem
, if not live data, or the data themselves, if live data.- Since:
- 5.0.6
- Author:
- jimmy
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TreeitemComparator()
Compares withTreeitem.getValue()
.TreeitemComparator(int index)
Compares with the column of the specified index.TreeitemComparator(int index, boolean ascending, boolean ignoreCase)
Compares with the column of the specified index.TreeitemComparator(int index, boolean ascending, boolean ignoreCase, boolean byValue)
Compares with the column of the specified index.TreeitemComparator(int index, boolean ascending, boolean ignoreCase, boolean byValue, boolean nullAsMax)
Compares with the column of the specified index.TreeitemComparator(Treecol treecol, boolean ascending, boolean ignoreCase)
Compares with the column which the tree header is at.TreeitemComparator(Treecol treecol, boolean ascending, boolean ignoreCase, boolean byValue)
Compares with the column which the tree header is at.TreeitemComparator(Treecol treecol, boolean ascending, boolean ignoreCase, boolean byValue, boolean nullAsMax)
Compares with the column which the tree header is at.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
byValue()
Returns whether to compare the returned value ofTreeitem.getValue()
int
compare(java.lang.Object o1, java.lang.Object o2)
boolean
equals(java.lang.Object o)
Treecol
getTreecol()
Returns the Treecol that this comparator is associated with, or null if not available.int
hashCode()
boolean
isAscending()
Returns whether the order is ascending.boolean
shallIgnoreCase()
Returns whether to ignore case.java.lang.String
toString()
-
-
-
Constructor Detail
-
TreeitemComparator
public TreeitemComparator()
Compares withTreeitem.getValue()
.It assumes the value returned by
Treeitem.getValue()
implements Comparable.Note: It assumes the ascending order and case-insensitive. If not, use
TreeitemComparator(int, boolean, boolean)
instead.
-
TreeitemComparator
public TreeitemComparator(int index)
Compares with the column of the specified index.0 for the first column, 1 for the second and so on
Note: -1 for
Treeitem.getValue()
and it assumes the value implements Comparable.Note: It assumes the ascending order, case-insensitive and comparing the returned values of
LabelElement.getLabel()
. If not, useTreeitemComparator(int, boolean, boolean, boolean)
instead.A null value is considered as the minimum value.
- Parameters:
index
- which column to compare. If -1,Treeitem.getValue()
is used.
-
TreeitemComparator
public TreeitemComparator(int index, boolean ascending, boolean ignoreCase)
Compares with the column of the specified index.0 for the first column, 1 for the second and so on
Note: -1 for
Treeitem.getValue()
and it assumes the value implements Comparable.Note: it compares the returned value of
LabelElement.getLabel()
. If you want to compareTreeitem.getValue()
., useTreeitemComparator(int, boolean, boolean, boolean)
instead.A null value is considered as the minimum value.
- Parameters:
index
- which column to compare. If -1,Treeitem.getValue()
is used.ascending
- whether to sort as ascending (or descending).ignoreCase
- whether to sort case-insensitive
-
TreeitemComparator
public TreeitemComparator(int index, boolean ascending, boolean ignoreCase, boolean byValue)
Compares with the column of the specified index.0 for the first column, 1 for the second and so on
Note: -1 for
Treeitem.getValue()
and it assumes the value implements Comparable.A null value is considered as the minimum value.
- Parameters:
index
- which column to compare. If -1,Treeitem.getValue()
is used.ascending
- whether to sort as ascending (or descending).ignoreCase
- whether to sort case-insensitivebyValue
- whether to compareTreeitem.getValue()
. If false, it comparesLabelElement.getLabel()
. If true, it assumes the value returned byTreeitem.getValue()
implements Comparable. It is ignored if the index is -1.
-
TreeitemComparator
public TreeitemComparator(int index, boolean ascending, boolean ignoreCase, boolean byValue, boolean nullAsMax)
Compares with the column of the specified index.0 for the first column, 1 for the second and so on
Note: -1 for
Treeitem.getValue()
and it assumes the value implements Comparable.- Parameters:
index
- which column to compare. If -1,Treeitem.getValue()
is used.ascending
- whether to sort as ascending (or descending).ignoreCase
- whether to sort case-insensitivebyValue
- whether to compareTreeitem.getValue()
. If false, it comparesLabelElement.getLabel()
. If true, it assumes the value returned byTreeitem.getValue()
implements Comparable. It is ignored if the index is -1.nullAsMax
- whether to consider null as the maximum value. If false, null is considered as the minimum value.
-
TreeitemComparator
public TreeitemComparator(Treecol treecol, boolean ascending, boolean ignoreCase)
Compares with the column which the tree header is at.Note: it compares the returned value of
LabelElement.getLabel()
. If you want to compareTreeitem.getValue()
., useTreeitemComparator(Treecol, boolean, boolean, boolean)
instead.A null value is considered as the minimum value.
- Parameters:
ascending
- whether to sort as ascending (or descending).ignoreCase
- whether to sort case-insensitive
-
TreeitemComparator
public TreeitemComparator(Treecol treecol, boolean ascending, boolean ignoreCase, boolean byValue)
Compares with the column which the tree header is at.A null value is considered as the minimum value.
- Parameters:
ascending
- whether to sort as ascending (or descending).ignoreCase
- whether to sort case-insensitivebyValue
- whether to compareTreeitem.getValue()
. If false, it comparesLabelElement.getLabel()
.
-
TreeitemComparator
public TreeitemComparator(Treecol treecol, boolean ascending, boolean ignoreCase, boolean byValue, boolean nullAsMax)
Compares with the column which the tree header is at.- Parameters:
ascending
- whether to sort as ascending (or descending).ignoreCase
- whether to sort case-insensitivebyValue
- whether to compareTreeitem.getValue()
. If false, it comparesLabelElement.getLabel()
.nullAsMax
- whether to consider null as the maximum value. If false, null is considered as the minimum value.
-
-
Method Detail
-
getTreecol
public Treecol getTreecol()
Returns the Treecol that this comparator is associated with, or null if not available.
-
isAscending
public boolean isAscending()
Returns whether the order is ascending.
-
shallIgnoreCase
public boolean shallIgnoreCase()
Returns whether to ignore case.
-
byValue
public boolean byValue()
Returns whether to compare the returned value ofTreeitem.getValue()
-
compare
public int compare(java.lang.Object o1, java.lang.Object o2)
- Specified by:
compare
in interfacejava.util.Comparator
-
equals
public boolean equals(java.lang.Object o)
- Specified by:
equals
in interfacejava.util.Comparator
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-