net.sf.saxon.sort

Class NamedCollation

public class NamedCollation extends Object implements StringCollator

A StringCollator is used for comparing strings (Java String objects). The URI is retained along with the collation so that the collation can be reconstructed on demand, typically at run-time by compiled code which has access to the URI but not the collation object itself.
Constructor Summary
NamedCollation(String uri, Comparator collation)
Create a NamedCollation
Method Summary
booleancomparesEqual(String s1, String s2)
Compare two strings for equality.
intcompareStrings(String o1, String o2)
Compares its two arguments for order.
ComparatorgetCollation()
Get the underlying comparator
ObjectgetCollationKey(String s)
Get a collation key for two Strings.
StringgetUri()
Get the URI identifying the collation
voidsetCollation(Comparator collation)
Set the underlying comparator
voidsetUri(String uri)
Set the URI identifying the collation

Constructor Detail

NamedCollation

public NamedCollation(String uri, Comparator collation)
Create a NamedCollation

Parameters: uri the name of the collation collation the Comparator that does the actual string comparison

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 o1, String o2)
Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Parameters: o1 the first object to be compared. o2 the second object to be compared.

Returns: a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Throws: ClassCastException if the arguments' types prevent them from being compared by this Comparator.

getCollation

public Comparator getCollation()
Get the underlying comparator

Returns: the underlying comparator

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.

getUri

public String getUri()
Get the URI identifying the collation

setCollation

public void setCollation(Comparator collation)
Set the underlying comparator

Parameters: collation the underlying comparator

setUri

public void setUri(String uri)
Set the URI identifying the collation

Parameters: uri the collation URI