Class Numberer_en

java.lang.Object
net.sf.saxon.expr.number.AbstractNumberer
net.sf.saxon.expr.number.Numberer_en
All Implemented Interfaces:
Numberer
Direct Known Subclasses:
Numberer_he

public class Numberer_en extends AbstractNumberer
Numberer class for the English language.
  • Constructor Details

    • Numberer_en

      public Numberer_en()
  • Method Details

    • setTensUnitsSeparatorCardinal

      public void setTensUnitsSeparatorCardinal(String separator)
      Set the separator to be used between tens and units for cardinal numbers. This allows customization of the output, for example "thirty six", "thirty-six", or "thirtysix". Default is a single space.

      Currently the only way of calling this is from a subclass, which can be nominated by setting a LocalizerFactory on the Configuration

      Parameters:
      separator - the separator to be used between tens and units when cardinal numbers are written as words.
    • setTensUnitsSeparatorOrdinal

      public void setTensUnitsSeparatorOrdinal(String separator)
      Set the separator to be used between tens and units for ordinal numbers. This allows customization of the output, for example "thirty sixth", "thirty-sixth", or "thirtysixth". Default is a hyphen.

      Currently the only way of calling this is from a subclass, which can be nominated by setting a LocalizerFactory on the Configuration

      Parameters:
      separator - the separator to be used between tens and units when ordinal numbers are written as words.
    • setLanguage

      public void setLanguage(String language)
      Set the language used by this numberer. Useful because it can potentially handle variants of English (and subclasses can handle other languages)
      Overrides:
      setLanguage in class AbstractNumberer
      Parameters:
      language - the requested language. Note that "en-x-hyphen" is recognized as a request to hyphenate numbers in the range 21-99.
    • ordinalSuffix

      protected String ordinalSuffix(String ordinalParam, long number)
      Construct the ordinal suffix for a number, for example "st", "nd", "rd"
      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)
      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 -
      number - the number to be formatted
      Returns:
      the number formatted as English words
    • toOrdinalWords

      public String toOrdinalWords(String ordinalParam, long number, int wordCase)
      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
    • monthName

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

      public String dayName(int day, int minWidth, int maxWidth)
      Get a day name or abbreviation
      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 or abbreviation as a string (for example, "Monday" or "Mon")