net.sf.saxon.sort

Class UppercaseFirstCollator

public class UppercaseFirstCollator extends Object implements StringCollator, Serializable

A Collator used for comparing strings, with upper case collated before lower case if the strings are otherwise equal. This is implemented as a wrapper around a collator that compares the strings ignoring case.

Author: Michael H. Kay

Constructor Summary
UppercaseFirstCollator(StringCollator base)
Create an UppercaseFirstCollator
Method Summary
booleancomparesEqual(String s1, String s2)
Compare two strings for equality.
intcompareStrings(String a, String b)
Compare two string objects: case is irrelevant, unless the strings are equal ignoring case, in which case uppercase comes first.
ObjectgetCollationKey(String s)
Get a collation key for two Strings.

Constructor Detail

UppercaseFirstCollator

public UppercaseFirstCollator(StringCollator base)
Create an UppercaseFirstCollator

Parameters: base the base collator used to compare strings irrespective of case

Method Detail

comparesEqual

public boolean comparesEqual(String s1, String 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

Parameters: s1 the first string s2 the second string

Returns: true if and only if the strings are considered equal,

compareStrings

public int compareStrings(String a, String b)
Compare two string objects: case is irrelevant, unless the strings are equal ignoring case, in which case uppercase comes first.

Returns: <0 if a0 if a>b

Throws: ClassCastException if the objects do not implement the CharSequence interface

getCollationKey

public Object getCollationKey(String 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.