## net.sf.saxon.sort
Class AlphanumericCollator

    java.lang.Object
      net.sf.saxon.sort.AlphanumericCollator

All Implemented Interfaces:
  java.io.Serializable, StringCollator

    public class AlphanumericCollator

extends java.lang.Object
implements StringCollator, java.io.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
`AlphanumericCollator(StringCollator base)` Create an alphanumeric collation

Method Summary
`int` `compareStrings(java.lang.String s1, java.lang.String s2)` Compare two objects.
`java.lang.Object` `getCollationKey(java.lang.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

### AlphanumericCollator

    public AlphanumericCollator(StringCollator base)

  Create an alphanumeric collation

  Parameters:
    `base` - the collation used to compare the alphabetic parts of the string

Method Detail

### compareStrings

    public int compareStrings(java.lang.String s1,
                              java.lang.String s2)

  Compare two objects.

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

### getCollationKey

    public java.lang.Object getCollationKey(java.lang.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`
  Parameters:
    `s` - the string whose collation key is required
  Returns:
    the collation key

Copyright (c) Saxonica Limited. All rights reserved.