Class 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 Detail

      • getNumberer

        public static ICUNumbererPE getNumberer​(java.util.Locale locale,
                                                java.lang.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​(java.util.Locale locale,
                              java.lang.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 java.util.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 java.lang.String[] getLocales()
        Return all the locales available for collation
        Returns:
        The set of locales as 'code';'display name' pairs
      • getPreferences

        public static java.lang.String[] getPreferences()
      • availableSpelloutNumberings

        public static java.lang.String[] availableSpelloutNumberings​(java.lang.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 java.lang.String[] availableOrdinalNumberings​(java.lang.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 java.lang.String realLocale​(java.lang.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 java.lang.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 java.lang.String ordinalSuffix​(java.lang.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 java.lang.String toWords​(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:
        number - the number to be formatted
        Returns:
        the number formatted as English words
      • postProcess

        public java.lang.String postProcess​(java.lang.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 java.lang.String postProcessOrdinal​(java.lang.String result,
                                                   java.lang.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 java.lang.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 java.lang.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