Package net.sf.saxon.expr.sort
Class CaseFirstCollator
- java.lang.Object
-
- net.sf.saxon.expr.sort.CaseFirstCollator
-
- All Implemented Interfaces:
StringCollator
public class CaseFirstCollator extends java.lang.Object implements StringCollator
A StringCollator that sorts lowercase before uppercase, or vice versa.Case is irrelevant, unless the strings are equal ignoring case, in which case lowercase comes first.
-
-
Constructor Summary
Constructors Constructor Description CaseFirstCollator(StringCollator base, boolean upperFirst, java.lang.String collationURI)
Create a CaseFirstCollator
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
comparesEqual(java.lang.CharSequence s1, java.lang.CharSequence s2)
Compare two strings for equality.int
compareStrings(java.lang.CharSequence a, java.lang.CharSequence b)
Compare two string objects: case is irrelevant, unless the strings are equal ignoring case, in which case lowercase comes first.AtomicMatchKey
getCollationKey(java.lang.CharSequence s)
Get a collation key for two Strings.java.lang.String
getCollationURI()
Get the collation URI.static StringCollator
makeCaseOrderedCollator(java.lang.String uri, StringCollator stringCollator, java.lang.String caseOrder)
-
-
-
Constructor Detail
-
CaseFirstCollator
public CaseFirstCollator(StringCollator base, boolean upperFirst, java.lang.String collationURI)
Create a CaseFirstCollator- Parameters:
base
- the base collator, which determines how characters are sorted irrespective of caseupperFirst
- true if uppercase precedes lowercase, false otherwisecollationURI
- the URI of the collation
-
-
Method Detail
-
makeCaseOrderedCollator
public static StringCollator makeCaseOrderedCollator(java.lang.String uri, StringCollator stringCollator, java.lang.String caseOrder) throws XPathException
- Throws:
XPathException
-
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(java.lang.CharSequence a, java.lang.CharSequence b)
Compare two string objects: case is irrelevant, unless the strings are equal ignoring case, in which case lowercase comes first.- Specified by:
compareStrings
in interfaceStringCollator
- Parameters:
a
- the first stringb
- the second string- Returns:
- <0 if a<b, 0 if a=b, >0 if a>b
- Throws:
java.lang.ClassCastException
- if the objects are of the wrong type for this Comparer
-
comparesEqual
public boolean comparesEqual(java.lang.CharSequence s1, java.lang.CharSequence 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(java.lang.CharSequence s)
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
-- Returns:
- the collation key
-
-