Package net.sf.saxon.expr.sort
Class AlphanumericCollator
- java.lang.Object
-
- net.sf.saxon.expr.sort.AlphanumericCollator
-
- All Implemented Interfaces:
StringCollator
public class AlphanumericCollator extends java.lang.Object implements StringCollator
A Comparer that treats strings as an alternating sequence of alpha parts and numeric parts. The alpha parts are compared using a base collation supplied as a parameter; the numeric parts are compared numerically. "Numeric" here means a sequence of consecutive ASCII digits 0-9.Note: this StringCollator produces an ordering that is not compatible with equals().
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PREFIX
-
Constructor Summary
Constructors Constructor Description AlphanumericCollator(StringCollator base)
Create an alphanumeric collation
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
comparesEqual(UnicodeString s1, UnicodeString s2)
Compare two strings for equality.int
compareStrings(UnicodeString cs1, UnicodeString cs2)
Compare two objects.AtomicMatchKey
getCollationKey(UnicodeString cs)
Get a collation key for a String.java.lang.String
getCollationURI()
Get the collation URI.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.lib.StringCollator
isEqualToEmpty
-
-
-
-
Field Detail
-
PREFIX
public static final java.lang.String PREFIX
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AlphanumericCollator
public AlphanumericCollator(StringCollator base)
Create an alphanumeric collation- Parameters:
base
- the collation used to compare the alphabetic parts of the string
-
-
Method Detail
-
getCollationURI
public java.lang.String getCollationURI()
Get the collation URI. It must be possible to use this collation URI to reconstitute the collation- Specified by:
getCollationURI
in interfaceStringCollator
- Returns:
- a collation URI that can be used to reconstruct the collation when an XSLT package is reloaded.
-
compareStrings
public int compareStrings(UnicodeString cs1, UnicodeString cs2)
Compare two objects.- Specified by:
compareStrings
in interfaceStringCollator
- Parameters:
cs1
- the first stringcs2
- the second string- Returns:
- <0 if a<b, 0 if a=b, >0 if a>b
-
comparesEqual
public boolean comparesEqual(UnicodeString s1, UnicodeString s2)
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,
-
getCollationKey
public AtomicMatchKey getCollationKey(UnicodeString cs)
Get a collation key for a String. The essential property of collation keys is that if (and only if) two strings are equal under the collation, then comparing the collation keys using the equals() method must return true.- Specified by:
getCollationKey
in interfaceStringCollator
- Parameters:
cs
- the string whose collation key is required- Returns:
- the collation key
-
-