net.sf.saxon.sort
Class AlphanumericComparer

java.lang.Object
  extended by net.sf.saxon.sort.AlphanumericComparer
All Implemented Interfaces:
Serializable, StringCollator

public class AlphanumericComparer
extends Object
implements StringCollator, Serializable

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().

See Also:
Serialized Form

Constructor Summary
AlphanumericComparer(StringCollator base)
           
 
Method Summary
 int compareStrings(String s1, String s2)
          Compare two objects.
 Object getCollationKey(String s, Platform platform)
          Get a collation key for two Strings.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AlphanumericComparer

public AlphanumericComparer(StringCollator base)
Method Detail

compareStrings

public int compareStrings(String s1,
                          String s2)
Compare two objects.

Specified by:
compareStrings in interface StringCollator
Parameters:
s1 - the first string
s2 - the second string
Returns:
<0 if a0 if a>b

getCollationKey

public Object getCollationKey(String s,
                              Platform platform)
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


Copyright (C) Michael H. Kay. All rights reserved.