Class UppercaseFirstCollator

  extended by net.sf.saxon.expr.sort.UppercaseFirstCollator
All Implemented Interfaces:
Serializable, StringCollator

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.

Michael H. Kay
See Also:
Serialized Form

Constructor Summary
UppercaseFirstCollator(StringCollator base)
          Create an UppercaseFirstCollator
Method Summary
 boolean comparesEqual(String s1, String s2)
          Compare two strings for equality.
 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.
 Object getCollationKey(String s)
          Get a collation key for two Strings.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public UppercaseFirstCollator(StringCollator base)
Create an UppercaseFirstCollator

base - the base collator used to compare strings irrespective of case
Method Detail


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.

Specified by:
compareStrings in interface StringCollator
a - the first string
b - the second string
<0 if a0 if a>b
ClassCastException - if the objects do not implement the CharSequence interface


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

Specified by:
comparesEqual in interface StringCollator
s1 - the first string
s2 - the second string
true if and only if the strings are considered equal,


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.

Specified by:
getCollationKey in interface StringCollator
s - the string whose collation key is required
the collation key

Copyright (c) 2004-2010 Saxonica Limited. All rights reserved.