001: package net.sf.saxon.number;
002:
003: /**
004: * Interface Numberer supports number formatting. There is a separate
005: * implementation for each language, e.g. Numberer_en for English.
006: * This supports the xsl:number element
007: * @author Michael H. Kay
008: */
009:
010: public interface Numberer {
011:
012: /**
013: * Set the country used by this numberer (currenly used only for names of timezones)
014: */
015:
016: public void setCountry(String country);
017:
018: /**
019: * Format a number into a string
020: * @param number The number to be formatted
021: * @param picture The format token. This is a single component of the format attribute
022: * of xsl:number, e.g. "1", "01", "i", or "a"
023: * @param groupSize number of digits per group (0 implies no grouping)
024: * @param groupSeparator string to appear between groups of digits
025: * @param letterValue The letter-value specified to xsl:number: "alphabetic" or
026: * "traditional". Can also be an empty string or null.
027: * @param ordinal The value of the ordinal attribute specified to xsl:number
028: * The value "yes" indicates that ordinal numbers should be used; "" or null indicates
029: * that cardinal numbers
030: * @return the formatted number. Note that no errors are reported; if the request
031: * is invalid, the number is formatted as if the string() function were used.
032: */
033:
034: public String format(long number, String picture, int groupSize,
035: String groupSeparator, String letterValue, String ordinal);
036:
037: /**
038: * Get a month name or abbreviation
039: * @param month The month number (1=January, 12=December)
040: * @param minWidth The minimum number of characters
041: * @param maxWidth The maximum number of characters
042: */
043:
044: public String monthName(int month, int minWidth, int maxWidth);
045:
046: /**
047: * Get a day name or abbreviation
048: * @param day The month number (1=Monday, 7=Sunday)
049: * @param minWidth The minimum number of characters
050: * @param maxWidth The maximum number of characters
051: */
052:
053: public String dayName(int day, int minWidth, int maxWidth);
054:
055: /**
056: * Get an am/pm indicator
057: * @param minutes the minutes within the day
058: * @param minWidth minimum width of output
059: * @param maxWidth maximum width of output
060: * @return the AM or PM indicator
061: */
062:
063: public String halfDayName(int minutes, int minWidth, int maxWidth);
064:
065: /**
066: * Get an ordinal suffix for a particular component of a date/time.
067: * @param component the component specifier from a format-dateTime picture, for
068: * example "M" for the month or "D" for the day.
069: * @return a string that is acceptable in the ordinal attribute of xsl:number
070: * to achieve the required ordinal representation. For example, "-e" for the day component
071: * in German, to have the day represented as "dritte August".
072: */
073:
074: public String getOrdinalSuffixForDateTime(String component);
075:
076: /**
077: * Get the name for an era (e.g. "BC" or "AD")
078: * @param year: the proleptic gregorian year, using "0" for the year before 1AD
079: */
080:
081: public String getEraName(int year);
082:
083: /**
084: * Get the name of a timezone
085: * @param tz: the offset of the timezone from GMT in minutes
086: */
087:
088: public String getTimezoneName(int tz);
089: }
090:
091: //
092: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
093: // you may not use this file except in compliance with the License. You may obtain a copy of the
094: // License at http://www.mozilla.org/MPL/
095: //
096: // Software distributed under the License is distributed on an "AS IS" basis,
097: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
098: // See the License for the specific language governing rights and limitations under the License.
099: //
100: // The Original Code is: all this file.
101: //
102: // The Initial Developer of the Original Code is Michael H. Kay.
103: //
104: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
105: //
106: // Contributor(s): none.
107: //
|