net.sf.saxon.sort
Class NumericComparer
java.lang.Object
net.sf.saxon.sort.NumericComparer
- All Implemented Interfaces:
- Comparator, Serializable
- public class NumericComparer
- extends Object
- implements Comparator, Serializable
A Comparer used for comparing sort keys when data-type="number". The items to be
compared are converted to numbers, and the numbers are then compared directly
- Author:
- Michael H. Kay (michael.h.kay@ntlworld.com)
- See Also:
- Serialized Form
Method Summary |
int |
compare(Object a,
Object b)
Compare two Items by converting them to numbers and comparing the numeric values. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NumericComparer
public NumericComparer()
compare
public int compare(Object a,
Object b)
- Compare two Items by converting them to numbers and comparing the numeric values. If either
value cannot be converted to a number, it is treated as NaN, and compares less that the other
(two NaN values compare equal).
- Specified by:
compare
in interface Comparator
- Parameters:
a
- the first Item to be compared.b
- the second Item to be compared.
- Returns:
- <0 if a0 if a>b
- Throws:
ClassCastException
- if the objects are not Items