Package com.saxonica.config.pe
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
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.
-
Field Summary
Fields inherited from class net.sf.saxon.expr.number.AbstractNumberer
cyrillicLower, cyrillicUpper, greekLower, greekUpper, hebrew, hiraganaA, hiraganaI, katakanaA, katakanaI, latinLower, latinUpper, LOWER_CASE, lowerCaseAlphabet, TITLE_CASE, UPPER_CASE, upperCaseAlphabet, westernDigits
-
Method Summary
Modifier and TypeMethodDescriptionstatic String[]
Return the available ordinal numbering schemes available for a given localestatic String[]
Return the available spellout numbering schemes available for a given localeprotected void
config
(Locale locale, String privateUseExtension, Configuration config) Configure an ICU numberer.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.Returns the locale that was used by default, rather than that requested.static String
Return the version of the ICU supported in this implementationstatic String[]
Return all the locales available for collationstatic ICUNumbererPE
getNumberer
(Locale locale, String privateUseExtension, Configuration config) Returns a suitable configured ICU numberer or a specialist subclass thereof.static 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.ordinalSuffix
(String ordinalParam, long number) Construct the ordinal suffix for a number, for example "st", "nd", "rd".postProcess
(String result) Post-process a spelled-out number.postProcessOrdinal
(String result, String ordinalParam) Post-process an ordinal spelled-out number.static String
realLocale
(String loc) Return the real language to be used for a given localetoOrdinalWords
(String ordinalParam, long number, int wordCase) Show an ordinal number as English words in a requested case (for example, Twentyfirst)Show the number as words in title case.Format a number as English words with specified case optionsMethods inherited from class net.sf.saxon.expr.number.AbstractNumberer
alphaDefault, convertDigitSystem, format, format, getCalendarName, getCountry, getEraName, getLanguage, getOrdinalSuffixForDateTime, halfDayName, setCountry, setLanguage, toAlpha, toAlphaSequence, toJapanese, toRoman, zero
-
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 useprivateUseExtension
- the language code extension used to denote required numberingconfig
- the system Configuration- Returns:
- a suitable Numberer.
-
config
Configure an ICU numberer. This includes possibly substituting a default locale if that requested isn't supported.- Parameters:
locale
- the locale to useprivateUseExtension
- the language code extension used to denote required numberingconfig
- the system Configuration
-
defaultedLocale
Returns the locale that was used by default, rather than that requested.- Specified by:
defaultedLocale
in interfaceNumberer
- Overrides:
defaultedLocale
in classAbstractNumberer
- Returns:
- the locale actually used, null if no default was required.
-
getLocales
Return all the locales available for collation- Returns:
- The set of locales as 'code';'display name' pairs
-
getPreferences
-
availableSpelloutNumberings
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
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
Return the real language to be used for a given locale- Parameters:
loc
- the locale code- Returns:
- the language code actually used
-
getICUVersion
Return the version of the ICU supported in this implementation- Returns:
- the version code as a 'major.minor.milli.micro' string
-
ordinalSuffix
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 classAbstractNumberer
- 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
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 classAbstractNumberer
- Parameters:
cardinal
- the value of the "cardinal" attribute as supplied by the usernumber
- the number to be formatted- Returns:
- the number formatted as English words
-
toWords
Description copied from class:AbstractNumberer
Format a number as English words with specified case options- Overrides:
toWords
in classAbstractNumberer
- Parameters:
cardinal
- the value of the "cardinal" attribute as supplied by the usernumber
- the number to be formattedwordCase
- the required case for exampleAbstractNumberer.UPPER_CASE
,AbstractNumberer.LOWER_CASE
,AbstractNumberer.TITLE_CASE
- Returns:
- the formatted number
-
toOrdinalWords
Description copied from class:AbstractNumberer
Show an ordinal number as English words in a requested case (for example, Twentyfirst)- Specified by:
toOrdinalWords
in classAbstractNumberer
- Parameters:
ordinalParam
- the value of the "ordinal" attribute as supplied by the usernumber
- the number to be formattedwordCase
- the required case for exampleAbstractNumberer.UPPER_CASE
,AbstractNumberer.LOWER_CASE
,AbstractNumberer.TITLE_CASE
- Returns:
- the formatted number
-
postProcess
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
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 ICUordinalParam
- The ordinal parameter, if any- Returns:
- processed string
-
monthName
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 interfaceNumberer
- Specified by:
monthName
in classAbstractNumberer
- Parameters:
month
- The month number (1=January, 12=December)minWidth
- The minimum number of charactersmaxWidth
- The maximum number of characters- Returns:
- The month name in TITLE case
-
dayName
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 interfaceNumberer
- Specified by:
dayName
in classAbstractNumberer
- Parameters:
day
- The day of the week (1=Monday, 7=Sunday)minWidth
- The minimum number of charactersmaxWidth
- The maximum number of characters- Returns:
- The day name in TITLE case
-