Methods Summary |
---|
public int | compare(java.lang.Object x, java.lang.Object y)Compares its two arguments for order. Sorts according to the following design.
Note that if the ascending property is false, the values for +1 or -1 will be
reversed.
-
Giving null for the first argument will always give a -1 reply.
-
Giving null for the second argument will always give a +1 reply.
-
Giving null for the both arguments will always give a 0 reply.
-
Objects whose sortProperty contains null will give a -1 reply relative to objects
with a non-null sortProperty.
-
If both objects' sort property are not null, The values of the sort properties
will be compared.
if (ascending) {
return compareHelper(x, y);
} else {
return (0 - compareHelper(x, y));
}
|
private int | compareHelper(java.lang.Object x, java.lang.Object y)Perform the raw compare.
try {
if ((x != null) && (y == null)) {
return -1;
} else if ((x == null) && (y != null)) {
return -1;
} else if ((x == null) && (y == null)) {
return 0;
}
Object xVal = this.sortProperty.getReadMethod()
.invoke(x, null);
Object yVal = this.sortProperty.getReadMethod()
.invoke(y, null);
if ((xVal != null) && (yVal == null)) {
return -1;
} else if ((xVal == null) && (yVal != null)) {
return -1;
} else if ((xVal == null) && (yVal == null)) {
return 0;
}
return ((Comparable)xVal).compareTo(yVal);
} catch (final InvocationTargetException ex) {
throw new RuntimeException(ex);
} catch (final IllegalAccessException ex) {
throw new RuntimeException(ex);
}
|
public java.lang.Class | getDataType()Getter for property tgtClass.
return this.dataType;
|
public java.beans.PropertyDescriptor | getSortProperty()Getter for property sortProperty.
return this.sortProperty;
|
public boolean | isAscending()Getter for property ascending.
return this.ascending;
|
public void | setAscending(boolean ascending)Setter for property ascending.
this.ascending = ascending;
|
public void | setDataType(java.lang.Class dataType)Setter for property tgtClass.
this.dataType = dataType;
|
public void | setSortProperty(java.beans.PropertyDescriptor sortProperty)Setter for property sortProperty.
this.sortProperty = sortProperty;
|