Class UcaCollatorUsingJava

java.lang.Object
net.sf.saxon.expr.sort.UcaCollatorUsingJava
All Implemented Interfaces:
StringCollator, SubstringMatcher

public class UcaCollatorUsingJava extends Object implements SubstringMatcher
This class implements (an approximation to) the UCA Collation Algorithm relying solely on the built-in Java support (that is, without using the ICU library). This provides a fallback implementation for Saxon-HE, and it is used only when the collation URI does not include the option fallback=no.
  • Constructor Details Link icon

    • UcaCollatorUsingJava Link icon

      public UcaCollatorUsingJava(String uri, Configuration config) throws XPathException
      Create a collation from a given collation URI
      Parameters:
      uri - the collation URI, in the format defined in the W3C Functions and Operators specification
      config - the Saxon Configuration, used for diagnostics
      Throws:
      XPathException - if the collation URI does not conform to the W3C rules, or if it requires features that Saxon-HE does not support
  • Method Details Link icon

    • getRuleBasedCollator Link icon

      public RuleBasedCollator getRuleBasedCollator()
      Get the underlying Java Collator object
      Returns:
      the underlying Java Collator
    • getJavaCollationKey Link icon

      public CollationKey getJavaCollationKey(String source)
      Factory method to create a CollationKey that can be used as a proxy for string comparisons under this collation
      Parameters:
      source - the string whose CollationKey is required
      Returns:
      a CollationKey with the property that two collation keys are equal (according to its Object.equals(Object) method if their corresponding strings are considered to be equal under this collation
    • hashCode Link icon

      public int hashCode()
      Get a hash code used to compare two collations. (Probably not used.)
      Overrides:
      hashCode in class Object
      Returns:
      a suitable hash code
    • getProperties Link icon

      public Properties getProperties()
      Get the properties of the collation
      Returns:
      the properties of the collation
    • setStrength Link icon

      public void setStrength(int newStrength)
      Set the strength of the collation (primary, secondary, tertiary, etc)
      Parameters:
      newStrength - the strength
    • getStrength Link icon

      public int getStrength()
      Get the strength of the collation (primary, secondary, tertiary, etc)
      Returns:
      the strength
    • comparesEqual Link icon

      public boolean comparesEqual(UnicodeString s1, UnicodeString s2)
      Ask whether two strings are considered equal under this collation
      Specified by:
      comparesEqual in interface StringCollator
      Parameters:
      s1 - the first string
      s2 - the second string
      Returns:
      true if the strings are considered equal
    • getCollationURI Link icon

      public String getCollationURI()
      Get the collation URI corresponding to this collation
      Specified by:
      getCollationURI in interface StringCollator
      Returns:
      the collation URI
    • compareStrings Link icon

      public int compareStrings(UnicodeString o1, UnicodeString o2)
      Compare two strings for equality or ordering under the rules of this collation
      Specified by:
      compareStrings in interface StringCollator
      Parameters:
      o1 - the first string
      o2 - the second string
      Returns:
      -1, 0, or +1 according to the relative ordering of the strings
    • getCollationKey Link icon

      public AtomicMatchKey getCollationKey(UnicodeString s)
      Get a collation key that can be used as a proxy for strings being compared
      Specified by:
      getCollationKey in interface StringCollator
      Parameters:
      s - the string whose collation key is required
      Returns:
      a collation key
    • contains Link icon

      public boolean contains(UnicodeString s1, UnicodeString s2)
      Test whether one string contains another, according to the rules of the XPath contains() function
      Specified by:
      contains in interface SubstringMatcher
      Parameters:
      s1 - the containing string
      s2 - the contained string
      Returns:
      true iff s1 contains s2
    • endsWith Link icon

      public boolean endsWith(UnicodeString s1, UnicodeString s2)
      Test whether one string ends with another, according to the rules of the XPath ends-with() function
      Specified by:
      endsWith in interface SubstringMatcher
      Parameters:
      s1 - the containing string
      s2 - the contained string
      Returns:
      true iff s1 ends with s2
    • startsWith Link icon

      public boolean startsWith(UnicodeString s1, UnicodeString s2)
      Test whether one string starts with another, according to the rules of the XPath starts-with() function
      Specified by:
      startsWith in interface SubstringMatcher
      Parameters:
      s1 - the containing string
      s2 - the contained string
      Returns:
      true iff s1 starts with s2
    • substringAfter Link icon

      public UnicodeString substringAfter(UnicodeString s1, UnicodeString s2)
      Return the part of a string after a given substring, according to the rules of the XPath substring-after() function
      Specified by:
      substringAfter in interface SubstringMatcher
      Parameters:
      s1 - the containing string
      s2 - the contained string
      Returns:
      the part of s1 that follows the first occurrence of s2
    • substringBefore Link icon

      public UnicodeString substringBefore(UnicodeString s1, UnicodeString s2)
      Return the part of a string before a given substring, according to the rules of the XPath substring-before() function
      Specified by:
      substringBefore in interface SubstringMatcher
      Parameters:
      s1 - the containing string
      s2 - the contained string
      Returns:
      the part of s1 that precedes the first occurrence of s2