Interface Numberer

All Known Implementing Classes:
AbstractNumberer, ICUNumberer_de, ICUNumbererEnUnhyphenated, ICUNumbererPE, Numberer_da, Numberer_de, Numberer_en, Numberer_fr, Numberer_frBE, Numberer_he, Numberer_it, Numberer_nl, Numberer_nlBE, Numberer_sv, Numberer_tr

public interface Numberer
Interface Numberer supports number formatting. There is a separate implementation for each language, e.g. Numberer_en for English. This supports the xsl:number element
  • Method Details

    • setCountry

      void setCountry(String country)
      Set the country used by this numberer (currently used only for names of timezones).

      Note: this method is called by the system when allocating a numberer for a specific language and country. Since numberers are normally shared across threads, it should not be changed after the initial creation of the Numberer.

      Parameters:
      country - The ISO two-letter country code.
    • getCountry

      String getCountry()
      Get the country used by this numberer
      Returns:
      The ISO code of the country
    • defaultedLocale

      Locale defaultedLocale()
      Whether this numberer has had its locale defaulted, i.e. it's not using the language requested This can be used for situations, such as in fn:format-date(), where indication of use of defaults is required. Override for subclasses where this can happen
      Returns:
      the locale used, null if it wasn't defaulted
    • format

      String format(long number, UnicodeString picture, int groupSize, String groupSeparator, String letterValue, String cardinal, String ordinal)
      Format a number into a string
      Parameters:
      number - The number to be formatted
      picture - The format token. This is a single component of the format attribute of xsl:number, e.g. "1", "01", "i", or "a"
      groupSize - number of digits per group (0 implies no grouping)
      groupSeparator - string to appear between groups of digits
      letterValue - The letter-value specified to xsl:number: "alphabetic" or "traditional". Can also be an empty string or null.
      cardinal - When called from xsl:number, the value is set to an empty string. When called from format-integer, the value is the value within parentheses after "c", for example "c(%spellout-masculine)" supplies the value "%spellout-masculine".
      ordinal - When called from xsl:number, the value of the ordinal attribute ("true" and "1" are normalized to "yes"). When called from format-integer, the value is the value within parentheses after "o", for example "o(%spellout-masculine)" supplies the value "%spellout-masculine".
      Returns:
      the formatted number. Note that no errors are reported; if the request is invalid, the number is formatted as if the string() function were used.
      Since:
      12.0 - the "cardinal" argument was added in 12.0
    • format

      String format(long number, UnicodeString picture, NumericGroupFormatter numGrpFormatter, String letterValue, String cardinal, String ordinal)
      Format a number into a string
      Parameters:
      number - The number to be formatted
      picture - The format token. This is a single component of the format attribute of xsl:number, e.g. "1", "01", "i", or "a"
      numGrpFormatter - an object that handles insertion of grouping separators into the formatted number
      letterValue - The letter-value specified to xsl:number: "alphabetic" or "traditional". The value "Xnn" or "xnn" signifies use of a radix other than 10, in the range 2 to 36. Can also be an empty string or null.
      cardinal - When called from xsl:number, the value is set to an empty string. When called from format-integer, the value is the value within parentheses after "c", for example "c(%spellout-masculine)" supplies the value "%spellout-masculine".
      ordinal - When called from xsl:number, the value of the ordinal attribute ("true" and "1" are normalized to "yes"). When called from format-integer, the value is the value within parentheses after "o", for example "o(%spellout-masculine)" supplies the value "%spellout-masculine".
      Returns:
      the formatted number. Note that no errors are reported; if the request is invalid, the number is formatted as if the string() function were used.
      Since:
      12.0 - the "cardinal" argument was added in 12.0
    • monthName

      String monthName(int month, int minWidth, int maxWidth)
      Get a month name or abbreviation
      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 or abbreviation as a string (for example, "September" or "Sep")
    • dayName

      String dayName(int day, int minWidth, int maxWidth)
      Get a day name or abbreviation
      Parameters:
      day - The month number (1=Monday, 7=Sunday)
      minWidth - The minimum number of characters
      maxWidth - The maximum number of characters
      Returns:
      the day name or abbreviation as a string (for example, "Monday" or "Mon")
    • halfDayName

      String halfDayName(int minutes, int minWidth, int maxWidth)
      Get an am/pm indicator
      Parameters:
      minutes - the minutes within the day
      minWidth - minimum width of output
      maxWidth - maximum width of output
      Returns:
      the AM or PM indicator
    • getOrdinalSuffixForDateTime

      String getOrdinalSuffixForDateTime(String component)
      Get an ordinal suffix for a particular component of a date/time.
      Parameters:
      component - the component specifier from a format-dateTime picture, for example "M" for the month or "D" for the day.
      Returns:
      a string that is acceptable in the ordinal attribute of xsl:number to achieve the required ordinal representation. For example, "-e" for the day component in German, to have the day represented as "dritte August".
    • getEraName

      String getEraName(int year)
      Get the name for an era (e.g. "BC" or "AD")
      Parameters:
      year - the proleptic gregorian year, using "0" for the year before 1AD
      Returns:
      the name of the era, for example "AD"
    • getCalendarName

      String getCalendarName(String code)
      Get the name of a calendar
      Parameters:
      code - The code representing the calendar as in the XSLT 2.0 spec, e.g. AD for the Gregorian calendar
      Returns:
      the name of the calendar, for example "AD"