net.sf.saxon.number
Class Numberer_en

java.lang.Object
  extended bynet.sf.saxon.number.Numberer_en
All Implemented Interfaces:
Numberer, Serializable
Direct Known Subclasses:
Numberer_de

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:
Serialized Form

Field Summary
protected static String cyrillicLower
           
protected static String cyrillicUpper
           
protected static String greekLower
           
protected static String greekUpper
           
protected static String hebrew
           
protected static String hiraganaA
           
protected static String hiraganaI
           
protected static String kanjiDigits
           
protected static String katakanaA
           
protected static String katakanaI
           
protected static String latinLower
           
protected static String latinUpper
           
static int LOWER_CASE
           
static int TITLE_CASE
           
static int UPPER_CASE
           
protected static String westernDigits
           
 
Constructor Summary
Numberer_en()
           
 
Method Summary
protected  void alphaDefault(long number, char formchar, StringBuffer sb)
          Default processing with an alphabetic format token: use the contiguous range of Unicode letters starting with that token.
 String dayName(int day, int minWidth, int maxWidth)
          Get a day name or abbreviation
 String format(long number, String picture, int groupSize, String groupSeparator, String letterValue, String ordinal)
          Format a number into a string
 String halfDayName(int minutes, int minWidth, int maxWidth)
          Get an am/pm indicator
 String monthName(int month, int minWidth, int maxWidth)
          Get a month name or abbreviation
protected  String ordinalSuffix(String ordinalParam, long number)
          Construct the ordinal suffix for a number, for example "st", "nd", "rd"
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
protected  String toAlphaSequence(long number, String alphabet)
          Convert the number into an alphabetic label using a given alphabet.
 String toOrdinalWords(String ordinalParam, long number, int wordCase)
          Show an ordinal number as English words in a requested case (for example, Twentyfirst)
static String toRoman(long n)
          Generate a Roman numeral (in lower case)
 String toWords(long number)
          Show the number as words in title case.
 String toWords(long number, int wordCase)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 String westernDigits
See Also:
Constant Field Values

latinUpper

protected static final String latinUpper
See Also:
Constant Field Values

latinLower

protected static final String latinLower
See Also:
Constant Field Values

greekUpper

protected static final String greekUpper
See Also:
Constant Field Values

greekLower

protected static final String greekLower
See Also:
Constant Field Values

cyrillicUpper

protected static final String cyrillicUpper
See Also:
Constant Field Values

cyrillicLower

protected static final String cyrillicLower
See Also:
Constant Field Values

hebrew

protected static final String hebrew
See Also:
Constant Field Values

hiraganaA

protected static final String hiraganaA
See Also:
Constant Field Values

katakanaA

protected static final String katakanaA
See Also:
Constant Field Values

hiraganaI

protected static final String hiraganaI
See Also:
Constant Field Values

katakanaI

protected static final String katakanaI
See Also:
Constant Field Values

kanjiDigits

protected static final String kanjiDigits
See Also:
Constant Field Values
Constructor Detail

Numberer_en

public Numberer_en()
Method Detail

format

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

Specified by:
format in interface Numberer
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.

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

alphaDefault

protected void alphaDefault(long number,
                            char formchar,
                            StringBuffer sb)
Default processing with an alphabetic format token: use the contiguous range of Unicode letters starting with that token.


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


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)

toOrdinalWords

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


monthName

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

Specified by:
monthName in interface Numberer
Parameters:
month - The month number (1=January, 12=December)
minWidth - The minimum number of characters
maxWidth - The maximum number of characters

dayName

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

Specified by:
dayName in interface Numberer
Parameters:
day - The month number (1=Monday, 7=Sunday)
minWidth - The minimum number of characters
maxWidth - The maximum number of characters

halfDayName

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

Specified by:
halfDayName in interface Numberer
Parameters:
minutes - the minutes within the day
minWidth - minimum width of output
maxWidth - maximum width of output
Returns:
the AM or PM indicator