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
public class ICUNumbererPE extends AbstractNumberer
A numberer using the ICU features, used principally for formatting numbers as words and day/month namesNote 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, TITLE_CASE, UPPER_CASE, westernDigits
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.String[]
availableOrdinalNumberings(java.lang.String loc)
Return the available ordinal numbering schemes available for a given localestatic java.lang.String[]
availableSpelloutNumberings(java.lang.String loc)
Return the available spellout numbering schemes available for a given localeprotected void
config(java.util.Locale locale, java.lang.String privateUseExtension, Configuration config)
Configure an ICU numberer.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.java.util.Locale
defaultedLocale()
Returns the locale that was used by default, rather than that requested.static java.lang.String
getICUVersion()
Return the version of the ICU supported in this implementationstatic java.lang.String[]
getLocales()
Return all the locales available for collationstatic ICUNumbererPE
getNumberer(java.util.Locale locale, java.lang.String privateUseExtension, Configuration config)
Returns a suitable configured ICU numberer or a specialist subclass thereof.static java.lang.String[]
getPreferences()
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.java.lang.String
ordinalSuffix(java.lang.String ordinalParam, long number)
Construct the ordinal suffix for a number, for example "st", "nd", "rd".java.lang.String
postProcess(java.lang.String result)
Post-process a spelled-out number.java.lang.String
postProcessOrdinal(java.lang.String result, java.lang.String ordinalParam)
Post-process an ordinal spelled-out number.static java.lang.String
realLocale(java.lang.String loc)
Return the real language to be used for a given localejava.lang.String
toOrdinalWords(java.lang.String ordinalParam, long number, int wordCase)
Show an ordinal number as English words in a requested case (for example, Twentyfirst)java.lang.String
toWords(long number)
Show the number as words in title case.java.lang.String
toWords(long number, int wordCase)
Format a number as English words with specified case options-
Methods 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 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 useprivateUseExtension
- the language code extension used to denote required numberingconfig
- 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 useprivateUseExtension
- the language code extension used to denote required numberingconfig
- 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 interfaceNumberer
- Overrides:
defaultedLocale
in classAbstractNumberer
- 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 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
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 classAbstractNumberer
- Parameters:
number
- the number to be formatted- Returns:
- the number formatted as English words
-
toWords
public java.lang.String toWords(long number, int wordCase)
Description copied from class:AbstractNumberer
Format a number as English words with specified case options- Overrides:
toWords
in classAbstractNumberer
- Parameters:
number
- the number to be formattedwordCase
- the required case for exampleAbstractNumberer.UPPER_CASE
,AbstractNumberer.LOWER_CASE
,AbstractNumberer.TITLE_CASE
- Returns:
- the formatted number
-
toOrdinalWords
public java.lang.String toOrdinalWords(java.lang.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 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
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 ICUordinalParam
- 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 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
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 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
-
-