Package net.sf.saxon.number
Class Numberer_en
- java.lang.Object
-
- net.sf.saxon.number.Numberer_en
-
- All Implemented Interfaces:
java.io.Serializable,Numberer
- Direct Known Subclasses:
Numberer_de,Numberer_fr
public class Numberer_en extends java.lang.Object implements Numberer, java.io.Serializable
Class Numberer_en does number formatting for language="en". This supports the xsl:number element. Methods and data are declared as protected, and static is avoided, to allow easy subclassing.- Author:
- Michael H. Kay
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringcyrillicLowerprotected static java.lang.StringcyrillicUpperprotected static java.lang.StringgreekLowerprotected static java.lang.StringgreekUpperprotected static java.lang.Stringhebrewprotected static java.lang.StringhiraganaAprotected static java.lang.StringhiraganaIprotected static int[]kanjiDigitsprotected static java.lang.StringkatakanaAprotected static java.lang.StringkatakanaIprotected static java.lang.StringlatinLowerprotected static java.lang.StringlatinUpperstatic intLOWER_CASE(package private) static java.util.HashMaptimezonesstatic intTITLE_CASEstatic intUPPER_CASEprotected static int[]westernDigits
-
Constructor Summary
Constructors Constructor Description Numberer_en()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidalphaDefault(long number, char formchar, FastStringBuffer sb)Default processing with an alphabetic format token: use the contiguous range of Unicode letters starting with that token.java.lang.StringdayName(int day, int minWidth, int maxWidth)Get a day name or abbreviationjava.lang.Stringformat(long number, java.lang.String picture, int groupSize, java.lang.String groupSeparator, java.lang.String letterValue, java.lang.String ordinal)Format a number into a stringjava.lang.StringgetCalendarName(java.lang.String code)Get the name of a calendarjava.lang.StringgetEraName(int year)Get the name for an era (e.g.java.lang.StringgetOrdinalSuffixForDateTime(java.lang.String component)Get an ordinal suffix for a particular component of a date/time.java.lang.StringgetTimezoneName(int tz)Get the name of a timezonejava.lang.StringhalfDayName(int minutes, int minWidth, int maxWidth)Get an am/pm indicatorjava.lang.StringmonthName(int month, int minWidth, int maxWidth)Get a month name or abbreviationprotected java.lang.StringordinalSuffix(java.lang.String ordinalParam, long number)Construct the ordinal suffix for a number, for example "st", "nd", "rd"voidsetCountry(java.lang.String country)Set the country used by this numberer (currenly used only for names of timezones)protected java.lang.StringtoAlpha(long number, int min, int max)Format the number as an alphabetic label using the alphabet consisting of consecutive Unicode characters from min to maxprotected java.lang.StringtoAlphaSequence(long number, java.lang.String alphabet)Convert the number into an alphabetic label using a given alphabet.java.lang.StringtoOrdinalWords(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.StringtoRoman(long n)Generate a Roman numeral (in lower case)java.lang.StringtoWords(long number)Show the number as words in title case.java.lang.StringtoWords(long number, int wordCase)(package private) static voidtz(double offset, java.lang.String name, java.lang.String country)
-
-
-
Field Detail
-
UPPER_CASE
public static final int UPPER_CASE
- See Also:
- Constant Field Values
-
LOWER_CASE
public static final int LOWER_CASE
- See Also:
- Constant Field Values
-
TITLE_CASE
public static final int TITLE_CASE
- See Also:
- Constant Field Values
-
westernDigits
protected static final int[] westernDigits
-
latinUpper
protected static final java.lang.String latinUpper
- See Also:
- Constant Field Values
-
latinLower
protected static final java.lang.String latinLower
- See Also:
- Constant Field Values
-
greekUpper
protected static final java.lang.String greekUpper
- See Also:
- Constant Field Values
-
greekLower
protected static final java.lang.String greekLower
- See Also:
- Constant Field Values
-
cyrillicUpper
protected static final java.lang.String cyrillicUpper
- See Also:
- Constant Field Values
-
cyrillicLower
protected static final java.lang.String cyrillicLower
- See Also:
- Constant Field Values
-
hebrew
protected static final java.lang.String hebrew
- See Also:
- Constant Field Values
-
hiraganaA
protected static final java.lang.String hiraganaA
- See Also:
- Constant Field Values
-
katakanaA
protected static final java.lang.String katakanaA
- See Also:
- Constant Field Values
-
hiraganaI
protected static final java.lang.String hiraganaI
- See Also:
- Constant Field Values
-
katakanaI
protected static final java.lang.String katakanaI
- See Also:
- Constant Field Values
-
kanjiDigits
protected static final int[] kanjiDigits
-
timezones
static java.util.HashMap timezones
-
-
Method Detail
-
setCountry
public void setCountry(java.lang.String country)
Set the country used by this numberer (currenly used only for names of timezones)- Specified by:
setCountryin interfaceNumberer
-
format
public java.lang.String format(long number, java.lang.String picture, int groupSize, java.lang.String groupSeparator, java.lang.String letterValue, java.lang.String ordinal)Format a number into a string- Specified by:
formatin interfaceNumberer- Parameters:
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 numbers- 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.
-
ordinalSuffix
protected java.lang.String ordinalSuffix(java.lang.String ordinalParam, long number)Construct the ordinal suffix for a number, for example "st", "nd", "rd"- 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
-
alphaDefault
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.
-
toAlpha
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
-
toAlphaSequence
protected java.lang.String toAlphaSequence(long number, java.lang.String alphabet)Convert the number into an alphabetic label using a given alphabet. For example, if the alphabet is "xyz" the sequence is x, y, z, xx, xy, xz, ....
-
toRoman
public static java.lang.String toRoman(long n)
Generate a Roman numeral (in lower case)
-
toWords
public java.lang.String toWords(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).
-
toWords
public java.lang.String toWords(long number, int wordCase)
-
toOrdinalWords
public 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)
-
monthName
public java.lang.String monthName(int month, int minWidth, int maxWidth)Get a month name or abbreviation
-
dayName
public java.lang.String dayName(int day, int minWidth, int maxWidth)Get a day name or abbreviation
-
halfDayName
public java.lang.String halfDayName(int minutes, int minWidth, int maxWidth)Get an am/pm indicator- Specified by:
halfDayNamein interfaceNumberer- Parameters:
minutes- the minutes within the dayminWidth- minimum width of outputmaxWidth- maximum width of output- Returns:
- the AM or PM indicator
-
getOrdinalSuffixForDateTime
public java.lang.String getOrdinalSuffixForDateTime(java.lang.String component)
Get an ordinal suffix for a particular component of a date/time.- Specified by:
getOrdinalSuffixForDateTimein interfaceNumberer- 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
public java.lang.String getEraName(int year)
Get the name for an era (e.g. "BC" or "AD")- Specified by:
getEraNamein interfaceNumberer- Parameters:
year- the proleptic gregorian year, using "0" for the year before 1AD
-
getTimezoneName
public java.lang.String getTimezoneName(int tz)
Get the name of a timezone- Specified by:
getTimezoneNamein interfaceNumberer- Parameters:
tz- the offset of the timezone from GMT in minutes
-
tz
static void tz(double offset, java.lang.String name, java.lang.String country)
-
getCalendarName
public java.lang.String getCalendarName(java.lang.String code)
Get the name of a calendar- Specified by:
getCalendarNamein interfaceNumberer- Parameters:
code- The code representing the calendar as in the XSLT 2.0 spec, e.g. AD for the Gregorian calendar
-
-