public abstract class AbstractNumberer extends java.lang.Object implements Numberer
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
cyrillicLower |
protected static java.lang.String |
cyrillicUpper |
protected static java.lang.String |
greekLower |
protected static java.lang.String |
greekUpper |
protected static java.lang.String |
hebrew |
protected static java.lang.String |
hiraganaA |
protected static java.lang.String |
hiraganaI |
protected static java.lang.String |
katakanaA |
protected static java.lang.String |
katakanaI |
protected static java.lang.String |
latinLower |
protected static java.lang.String |
latinUpper |
static int |
LOWER_CASE |
static int |
TITLE_CASE |
static int |
UPPER_CASE |
protected static int[] |
westernDigits |
Constructor and Description |
---|
AbstractNumberer() |
Modifier and Type | Method and Description |
---|---|
protected void |
alphaDefault(long number,
char formchar,
FastStringBuffer sb)
Default processing with an alphabetic format token: use the contiguous
range of Unicode letters starting with that token.
|
static FastStringBuffer |
convertDigitSystem(long number,
int[] digits,
int requiredLength)
Convert a number to use a given set of digits, to a required length.
|
abstract java.lang.String |
dayName(int day,
int minWidth,
int maxWidth)
Get a day name or abbreviation
|
java.util.Locale |
defaultedLocale()
Whether this numberer has had its locale defaulted, i.e.
|
java.lang.String |
format(long number,
UnicodeString picture,
int groupSize,
java.lang.String groupSeparator,
java.lang.String letterValue,
java.lang.String ordinal)
Format a number into a string.
|
java.lang.String |
format(long number,
UnicodeString picture,
NumericGroupFormatter numGroupFormatter,
java.lang.String letterValue,
java.lang.String ordinal)
Format a number into a string
|
java.lang.String |
getCalendarName(java.lang.String code)
Get the name of a calendar
|
java.lang.String |
getCountry()
Get the country used by this numberer.
|
java.lang.String |
getEraName(int year)
Get the name for an era (e.g.
|
java.lang.String |
getLanguage()
Get the language used by this numberer
|
java.lang.String |
getOrdinalSuffixForDateTime(java.lang.String component)
Get an ordinal suffix for a particular component of a date/time.
|
java.lang.String |
halfDayName(int minutes,
int minWidth,
int maxWidth)
Get an am/pm indicator.
|
abstract java.lang.String |
monthName(int month,
int minWidth,
int maxWidth)
Get a month name or abbreviation
|
protected java.lang.String |
ordinalSuffix(java.lang.String ordinalParam,
long number)
Construct the ordinal suffix for a number, for example "st", "nd", "rd".
|
void |
setCountry(java.lang.String country)
Set the country used by this numberer (currently used only for names of timezones)
|
void |
setLanguage(java.lang.String language)
Set the language used by this numberer.
|
protected java.lang.String |
toAlpha(long number,
int min,
int max)
Format the number as an alphabetic label using the alphabet consisting
of consecutive Unicode characters from min to max
|
protected java.lang.String |
toAlphaSequence(long number,
java.lang.String alphabet)
Convert the number into an alphabetic label using a given alphabet.
|
java.lang.String |
toJapanese(long number)
Format the number in Japanese.
|
abstract java.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)
|
static java.lang.String |
toRoman(long n)
Generate a Roman numeral (in lower case)
|
abstract 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
|
public static final int UPPER_CASE
public static final int LOWER_CASE
public static final int TITLE_CASE
protected static final int[] westernDigits
protected static final java.lang.String latinUpper
protected static final java.lang.String latinLower
protected static final java.lang.String greekUpper
protected static final java.lang.String greekLower
protected static final java.lang.String cyrillicUpper
protected static final java.lang.String cyrillicLower
protected static final java.lang.String hebrew
protected static final java.lang.String hiraganaA
protected static final java.lang.String katakanaA
protected static final java.lang.String hiraganaI
protected static final java.lang.String katakanaI
public java.util.Locale defaultedLocale()
defaultedLocale
in interface Numberer
public void setCountry(java.lang.String country)
setCountry
in interface Numberer
country
- The ISO two-letter country code.public void setLanguage(java.lang.String language)
language
- the requested language. Note that "en-x-hyphen" is recognized as a request to hyphenate
numbers in the range 21-99.public java.lang.String getLanguage()
public java.lang.String getCountry()
getCountry
in interface Numberer
public final java.lang.String format(long number, UnicodeString picture, int groupSize, java.lang.String groupSeparator, java.lang.String letterValue, java.lang.String ordinal)
Numberer.format(long, UnicodeString, NumericGroupFormatter, String, String)
rather than this method.format
in interface Numberer
number
- The number to be formattedpicture
- 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 digitsletterValue
- The letter-value specified to xsl:number: "alphabetic" or
"traditional". Can also be an empty string or null.ordinal
- The value of the ordinal attribute specified to xsl:number
The value "yes" indicates that ordinal numbers should be used; "" or null indicates
that cardinal numberspublic java.lang.String format(long number, UnicodeString picture, NumericGroupFormatter numGroupFormatter, java.lang.String letterValue, java.lang.String ordinal)
format
in interface Numberer
number
- The number to be formattedpicture
- The format token. This is a single component of the format attribute
of xsl:number, e.g. "1", "01", "i", or "a"numGroupFormatter
- object contains separators to appear between groups of digitsletterValue
- The letter-value specified to xsl:number: "alphabetic" or
"traditional". Can also be an empty string or null.ordinal
- The value of the ordinal attribute specified to xsl:number
The value "yes" indicates that ordinal numbers should be used; "" or null indicates
cardinal numbers. A value such as "-er" indicates ordinal with a particular gender.protected java.lang.String ordinalSuffix(java.lang.String ordinalParam, long number)
ordinalParam
- the value of the ordinal attribute (used in non-English
language implementations)number
- the number being formattedprotected void alphaDefault(long number, char formchar, FastStringBuffer sb)
number
- the number to be formattedformchar
- the format character, for example 'A' for the numbering sequence A,B,Csb
- buffer to hold the result of the formattingprotected java.lang.String toAlpha(long number, int min, int max)
number
- the number to be formattedmin
- the start of the Unicode codepoint rangemax
- the end of the Unicode codepoint rangeprotected java.lang.String toAlphaSequence(long number, java.lang.String alphabet)
number
- the number to be formattedalphabet
- a string containing the characters to be used, for example "abc...xyz"public static FastStringBuffer convertDigitSystem(long number, int[] digits, int requiredLength)
number
- the number to be formatteddigits
- the codepoints to be used for the digitsrequiredLength
- the length of the picture that is significant: for example "3" if the
picture is "001"public static java.lang.String toRoman(long n)
n
- the number to be formattedpublic java.lang.String toJapanese(long number)
number
- the number to be formatted: formatted in Western decimal style unless in the range 1 to 9999public abstract java.lang.String toWords(long number)
number
- the number to be formattedpublic java.lang.String toWords(long number, int wordCase)
number
- the number to be formattedwordCase
- the required case for example UPPER_CASE
,
LOWER_CASE
, TITLE_CASE
public abstract java.lang.String toOrdinalWords(java.lang.String ordinalParam, long number, int wordCase)
ordinalParam
- the value of the "ordinal" attribute as supplied by the usernumber
- the number to be formattedwordCase
- the required case for example UPPER_CASE
,
LOWER_CASE
, TITLE_CASE
public abstract java.lang.String monthName(int month, int minWidth, int maxWidth)
public abstract java.lang.String dayName(int day, int minWidth, int maxWidth)
public java.lang.String halfDayName(int minutes, int minWidth, int maxWidth)
halfDayName
in interface Numberer
minutes
- the minutes within the dayminWidth
- minimum width of outputmaxWidth
- maximum width of outputpublic java.lang.String getOrdinalSuffixForDateTime(java.lang.String component)
getOrdinalSuffixForDateTime
in interface Numberer
component
- the component specifier from a format-dateTime picture, for
example "M" for the month or "D" for the day.public java.lang.String getEraName(int year)
getEraName
in interface Numberer
year
- the proleptic gregorian year, using "0" for the year before 1ADpublic java.lang.String getCalendarName(java.lang.String code)
getCalendarName
in interface Numberer
code
- The code representing the calendar as in the XSLT 2.0 spec, e.g. AD for the Gregorian calendarCopyright (c) 2004-2020 Saxonica Limited. All rights reserved.