Package net.sf.saxon.expr.sort
Class SimpleCollation
java.lang.Object
net.sf.saxon.expr.sort.SimpleCollation
- All Implemented Interfaces:
Serializable
,StringCollator
A simple collation that just wraps a suppled Comparator
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
comparesEqual
(String s1, String s2) Compare two strings for equality.int
compareStrings
(String o1, String o2) Compares its two arguments for order.Get the underlying comparatorGet a collation key for two Strings.void
setCollation
(Comparator collation) Set the underlying comparator
-
Constructor Details
-
SimpleCollation
Create a SimpleCollation- Parameters:
collation
- the Comparator that does the actual string comparison
-
-
Method Details
-
compareStrings
Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.- Specified by:
compareStrings
in interfaceStringCollator
- Parameters:
o1
- the first object to be compared.o2
- the second object to be compared.- Returns:
- a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
- Throws:
ClassCastException
- if the arguments' types prevent them from being compared by this Comparator.
-
comparesEqual
Compare two strings for equality. This may be more efficient than using compareStrings and testing whether the result is zero, but it must give the same result- Specified by:
comparesEqual
in interfaceStringCollator
- Parameters:
s1
- the first strings2
- the second string- Returns:
- true if and only if the strings are considered equal,
-
getCollation
Get the underlying comparator- Returns:
- the underlying comparator
-
setCollation
Set the underlying comparator- Parameters:
collation
- the underlying comparator
-
getCollationKey
Get a collation key for two Strings. The essential property of collation keys is that if two values are equal under the collation, then the collation keys are compare correctly under the equals() method.- Specified by:
getCollationKey
in interfaceStringCollator
- Parameters:
s
- the string whose collation key is required- Returns:
- the collation key
-