net.sf.saxon.number

Class Numberer_en

public class Numberer_en extends Object implements Numberer, 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

Field Summary
protected static StringcyrillicLower
protected static StringcyrillicUpper
protected static StringgreekLower
protected static StringgreekUpper
protected static Stringhebrew
protected static StringhiraganaA
protected static StringhiraganaI
protected static StringkanjiDigits
protected static StringkatakanaA
protected static StringkatakanaI
protected static StringlatinLower
protected static StringlatinUpper
static intLOWER_CASE
static HashMaptimezones
static intTITLE_CASE
static intUPPER_CASE
protected static StringwesternDigits
Method Summary
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.
StringdayName(int day, int minWidth, int maxWidth)
Get a day name or abbreviation
Stringformat(long number, String picture, int groupSize, String groupSeparator, String letterValue, String ordinal)
Format a number into a string
StringgetEraName(int year)
Get the name for an era (e.g.
StringgetOrdinalSuffixForDateTime(String component)
Get an ordinal suffix for a particular component of a date/time.
StringgetTimezoneName(int tz)
Get the name of a timezone
StringhalfDayName(int minutes, int minWidth, int maxWidth)
Get an am/pm indicator
StringmonthName(int month, int minWidth, int maxWidth)
Get a month name or abbreviation
protected StringordinalSuffix(String ordinalParam, long number)
Construct the ordinal suffix for a number, for example "st", "nd", "rd"
voidsetCountry(String country)
Set the country used by this numberer (currenly used only for names of timezones)
protected 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 max
protected StringtoAlphaSequence(long number, String alphabet)
Convert the number into an alphabetic label using a given alphabet.
StringtoOrdinalWords(String ordinalParam, long number, int wordCase)
Show an ordinal number as English words in a requested case (for example, Twentyfirst)
static StringtoRoman(long n)
Generate a Roman numeral (in lower case)
StringtoWords(long number)
Show the number as words in title case.
StringtoWords(long number, int wordCase)
static voidtz(double offset, String name, String country)

Field Detail

cyrillicLower

protected static final String cyrillicLower

cyrillicUpper

protected static final String cyrillicUpper

greekLower

protected static final String greekLower

greekUpper

protected static final String greekUpper

hebrew

protected static final String hebrew

hiraganaA

protected static final String hiraganaA

hiraganaI

protected static final String hiraganaI

kanjiDigits

protected static final String kanjiDigits

katakanaA

protected static final String katakanaA

katakanaI

protected static final String katakanaI

latinLower

protected static final String latinLower

latinUpper

protected static final String latinUpper

LOWER_CASE

public static final int LOWER_CASE

timezones

static HashMap timezones

TITLE_CASE

public static final int TITLE_CASE

UPPER_CASE

public static final int UPPER_CASE

westernDigits

protected static final String westernDigits

Method Detail

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.

dayName

public String dayName(int day, int minWidth, int maxWidth)
Get a day name or abbreviation

Parameters: day The day of the week (1=Monday, 7=Sunday) minWidth The minimum number of characters maxWidth The maximum number of characters

format

public String format(long number, String picture, int groupSize, String groupSeparator, String letterValue, String ordinal)
Format a number into a string

Parameters: number The number to be formatted picture 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 digits letterValue 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.

getEraName

public String getEraName(int year)
Get the name for an era (e.g. "BC" or "AD")

Parameters: year the proleptic gregorian year, using "0" for the year before 1AD

getOrdinalSuffixForDateTime

public String getOrdinalSuffixForDateTime(String component)
Get an ordinal suffix for a particular component of a date/time.

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".

getTimezoneName

public String getTimezoneName(int tz)
Get the name of a timezone

Parameters: tz the offset of the timezone from GMT in minutes

halfDayName

public String halfDayName(int minutes, int minWidth, int maxWidth)
Get an am/pm indicator

Parameters: minutes the minutes within the day minWidth minimum width of output maxWidth maximum width of output

Returns: the AM or PM indicator

monthName

public String monthName(int month, int minWidth, int maxWidth)
Get a month name or abbreviation

Parameters: month The month number (1=January, 12=December) minWidth The minimum number of characters maxWidth The maximum number of characters

ordinalSuffix

protected String ordinalSuffix(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

setCountry

public void setCountry(String country)
Set the country used by this numberer (currenly used only for names of timezones)

toAlpha

protected 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 String toAlphaSequence(long number, 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, ....

toOrdinalWords

public String toOrdinalWords(String ordinalParam, long number, int wordCase)
Show an ordinal number as English words in a requested case (for example, Twentyfirst)

toRoman

public static String toRoman(long n)
Generate a Roman numeral (in lower case)

toWords

public 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 String toWords(long number, int wordCase)

tz

static void tz(double offset, String name, String country)