Class ICUNumbererPE

java.lang.Object
net.sf.saxon.expr.number.AbstractNumberer
com.saxonica.config.pe.ICUNumbererPE
All Implemented Interfaces:
Numberer
Direct Known Subclasses:
ICUNumberer_de, ICUNumbererEnUnhyphenated

public class ICUNumbererPE extends AbstractNumberer
A numberer using the ICU features, used principally for formatting numbers as words and day/month names

Note that in the case that the ICU libraries have not been loaded, then this class is not instantiated. However, the public static functions, e.g. getLocales() could in theory be accessed via an XSLT stylesheet (such as the documentation generators for example) and these invoke ICU features The guard function com.saxonica.config.ICUNumbererPE.hasICU() can be used to check.

  • Method Details

    • getNumberer

      public static ICUNumbererPE getNumberer(Locale locale, String privateUseExtension, Configuration config)
      Returns a suitable configured ICU numberer or a specialist subclass thereof.
      Parameters:
      locale - the locale to use
      privateUseExtension - the language code extension used to denote required numbering
      config - the system Configuration
      Returns:
      a suitable Numberer.
    • config

      protected void config(Locale locale, String privateUseExtension, Configuration config)
      Configure an ICU numberer. This includes possibly substituting a default locale if that requested isn't supported.
      Parameters:
      locale - the locale to use
      privateUseExtension - the language code extension used to denote required numbering
      config - the system Configuration
    • defaultedLocale

      public Locale defaultedLocale()
      Returns the locale that was used by default, rather than that requested.
      Specified by:
      defaultedLocale in interface Numberer
      Overrides:
      defaultedLocale in class AbstractNumberer
      Returns:
      the locale actually used, null if no default was required.
    • getLocales

      public static String[] getLocales()
      Return all the locales available for collation
      Returns:
      The set of locales as 'code';'display name' pairs
    • getPreferences

      public static String[] getPreferences()
    • availableSpelloutNumberings

      public static String[] availableSpelloutNumberings(String loc)
      Return the available spellout numbering schemes available for a given locale
      Parameters:
      loc - the locale code
      Returns:
      the numbering scheme names, e.g. '%spellout-verbose'
    • availableOrdinalNumberings

      public static String[] availableOrdinalNumberings(String loc)
      Return the available ordinal numbering schemes available for a given locale
      Parameters:
      loc - the locale code
      Returns:
      the numbering scheme names, e.g. '%digits-ordinal'
    • realLocale

      public static String realLocale(String loc)
      Return the real language to be used for a given locale
      Parameters:
      loc - the locale code
      Returns:
      the language code actually used
    • getICUVersion

      public static String getICUVersion()
      Return the version of the ICU supported in this implementation
      Returns:
      the version code as a 'major.minor.milli.micro' string
    • ordinalSuffix

      public String ordinalSuffix(String ordinalParam, long number)
      Description copied from class: AbstractNumberer
      Construct the ordinal suffix for a number, for example "st", "nd", "rd". The default (language-neutral) implementation returns a zero-length string
      Overrides:
      ordinalSuffix in class AbstractNumberer
      Parameters:
      ordinalParam - the value of the ordinal attribute (used in non-English language implementations)
      number - the number being formatted
      Returns:
      the ordinal suffix to be appended to the formatted number
    • toWords

      public String toWords(String cardinal, long number)
      Description copied from class: AbstractNumberer
      Show the number as words in title case. (We choose title case because the result can then be converted algorithmically to lower case or upper case).
      Specified by:
      toWords in class AbstractNumberer
      Parameters:
      cardinal - the value of the "cardinal" attribute as supplied by the user
      number - the number to be formatted
      Returns:
      the number formatted as English words
    • toWords

      public String toWords(String cardinal, long number, int wordCase)
      Description copied from class: AbstractNumberer
      Format a number as English words with specified case options
      Overrides:
      toWords in class AbstractNumberer
      Parameters:
      cardinal - the value of the "cardinal" attribute as supplied by the user
      number - the number to be formatted
      wordCase - the required case for example AbstractNumberer.UPPER_CASE, AbstractNumberer.LOWER_CASE, AbstractNumberer.TITLE_CASE
      Returns:
      the formatted number
    • toOrdinalWords

      public String toOrdinalWords(String ordinalParam, long number, int wordCase)
      Description copied from class: AbstractNumberer
      Show an ordinal number as English words in a requested case (for example, Twentyfirst)
      Specified by:
      toOrdinalWords in class AbstractNumberer
      Parameters:
      ordinalParam - the value of the "ordinal" attribute as supplied by the user
      number - the number to be formatted
      wordCase - the required case for example AbstractNumberer.UPPER_CASE, AbstractNumberer.LOWER_CASE, AbstractNumberer.TITLE_CASE
      Returns:
      the formatted number
    • postProcess

      public String postProcess(String result)
      Post-process a spelled-out number. Overriding this can add additional effects such as replacing '-' with a space.
      Parameters:
      result - The spelled-out number generated by ICU
      Returns:
      processed string
    • postProcessOrdinal

      public String postProcessOrdinal(String result, String ordinalParam)
      Post-process an ordinal spelled-out number. Overriding this can add additional effects, such as gender/case variable suffices in German
      Parameters:
      result - The spelled-out ordinal generated by ICU
      ordinalParam - The ordinal parameter, if any
      Returns:
      processed string
    • monthName

      public String monthName(int month, int minWidth, int maxWidth)
      Return an appropriate month name, using ICU data The approach is to try each of the forms available in descending order of 'size' until we have the first that fits the width constraints.
      Specified by:
      monthName in interface Numberer
      Specified by:
      monthName in class AbstractNumberer
      Parameters:
      month - The month number (1=January, 12=December)
      minWidth - The minimum number of characters
      maxWidth - The maximum number of characters
      Returns:
      The month name in TITLE case
    • dayName

      public String dayName(int day, int minWidth, int maxWidth)
      Return an appropriate day name, using ICU data The approach is to try each of the forms available in descending order of 'size' until we have the first that fits the width constraints.
      Specified by:
      dayName in interface Numberer
      Specified by:
      dayName in class AbstractNumberer
      Parameters:
      day - The day of the week (1=Monday, 7=Sunday)
      minWidth - The minimum number of characters
      maxWidth - The maximum number of characters
      Returns:
      The day name in TITLE case