|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object texsoft.java.object.XsObjectComparator
Implements a comparator that compares XsObjectWithReflection
objects.
For the comparator to work the caller MUST set an array of properties that define the properties used to order the object and their sequence for comparison. For example if one need to order by properties name, age the array will be { "name", "age" }.
If case insensitive sorting is needed for String property, the the NOCASE constant has to be appended to the property name (ex. { "name" + NOCASE, "age" }).
A property can be ordered descending by appending the constant DESCENDING to the property name (ex. { "name", "age" + DESCENDING }).
There is also a DESCENDING_NOCASE constant to perform a descending insensitive case sorting.
Field Summary | |
static java.lang.String |
ASCENDING
Append it to property name to have ascending sorting on the property. |
static java.lang.String |
ASCENDING_NOCASE
Append it to property name to have ascending ignorecase sorting on the property. |
static java.lang.String |
DESCENDING
Append it to property name to have descending sorting on the property. |
static java.lang.String |
DESCENDING_NOCASE
Append it to property name to have descending ignorecase sorting on the property. |
static java.lang.String |
NOCASE
Append it to property name to have ascending ignorecase sorting on the property. |
Constructor Summary | |
XsObjectComparator()
Creates a new XsObjectComparator . |
|
XsObjectComparator(java.lang.String[] order)
Create a new XsObjectComparator with the given properties' comparison order. |
Method Summary | |
int |
compare(java.lang.Object a,
java.lang.Object b)
Compare two objects. |
java.lang.String[] |
getOrder()
Returns the properties used for the comparison. |
void |
setOrder(java.lang.String[] order)
Sets the properties involved into the comparison. |
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 |
Field Detail |
public static final java.lang.String ASCENDING
public static final java.lang.String ASCENDING_NOCASE
public static final java.lang.String NOCASE
public static final java.lang.String DESCENDING
public static final java.lang.String DESCENDING_NOCASE
Constructor Detail |
public XsObjectComparator()
XsObjectComparator
.
public XsObjectComparator(java.lang.String[] order)
XsObjectComparator
with the given properties' comparison order.
order
- array of String with the names of the properties used to compare the
object; the comparison type constants can be appended to property names to
select comparison optionsMethod Detail |
public java.lang.String[] getOrder()
public void setOrder(java.lang.String[] order)
order
- array of String with the names of the properties used to compare the
object; the comparison type constants can be appended to property names to
select comparison optionspublic int compare(java.lang.Object a, java.lang.Object b)
This implementations require that both objects derive from
XsObjectWithReflection
and belong to the same class.
compare
in interface java.util.Comparator
a
- first object to compareb
- second object to compare
java.lang.ClassCastException
- thrown if the two object being compared do not belong to the same class or if
they do not extend XsObjectWithReflection
; this exception is thrown
also if during objects comparison a reflection error occurs.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |