]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-52_1/demos/src/com/ibm/icu/dev/demo/rbnf/RbnfSampleRuleSets.java
Upgrade ICU4J.
[Dictionary.git] / jars / icu4j-52_1 / demos / src / com / ibm / icu / dev / demo / rbnf / RbnfSampleRuleSets.java
1 /*
2  *******************************************************************************
3  * Copyright (C) 1996-2007, International Business Machines Corporation and    *
4  * others. All Rights Reserved.                                                *
5  *******************************************************************************
6  */
7 package com.ibm.icu.dev.demo.rbnf;
8
9 import java.util.Locale;
10
11 /**
12  * A collection of example rule sets for use with RuleBasedNumberFormat.
13  * These examples are intended to serve both as demonstrations of what can
14  * be done with this framework, and as starting points for designing new
15  * rule sets.
16  *
17  * For those that claim to represent number-spellout rules for languages
18  * other than U.S. English, we make no claims of either accuracy or
19  * completeness.  In fact, we know them to be incomplete, and suspect
20  * most have mistakes in them.  If you see something that you know is wrong,
21  * please tell us!
22  *
23  * @author Richard Gillam
24  */
25 public class RbnfSampleRuleSets {
26     /**
27      * Puts a copyright in the .class file
28      */
29 //    private static final String copyrightNotice
30 //        = "Copyright \u00a91997-1998 IBM Corp.  All rights reserved.";
31
32     //========================================================================
33     // Spellout rules for various languages
34     //
35     // The following RuleBasedNumberFormat descriptions show the rules for
36     // spelling out numeric values in various languages.  As mentioned
37     // before, we cannot vouch for the accuracy or completeness of this
38     // data, although we believe it's pretty close.  Basically, this
39     // represents one day's worth of Web-surfing.  If you can supply the
40     // missing information in any of these rule sets, or if you find errors,
41     // or if you can supply spellout rules for languages that aren't shown
42     // here, we want to hear from you!
43     //========================================================================
44
45     /**
46      * Spellout rules for U.S. English.  This demonstration version of the
47      * U.S. English spellout rules has four variants: 1) %simplified is a
48      * set of rules showing the simple method of spelling out numbers in
49      * English: 289 is formatted as "two hundred eighty-nine".  2) %alt-teens
50      * is the same as %simplified, except that values between 1,000 and 9,999
51      * whose hundreds place isn't zero are formatted in hundreds.  For example,
52      * 1,983 is formatted as "nineteen hundred eighty-three," and 2,183 is
53      * formatted as "twenty-one hundred eighty-three," but 2,083 is still
54      * formatted as "two thousand eighty-three."  3) %ordinal formats the
55      * values as ordinal numbers in English (e.g., 289 is "two hundred eighty-
56      * ninth").  4) %default uses a more complicated algorithm to format
57      * numbers in a more natural way: 289 is formatted as "two hundred AND
58      * eighty-nine" and commas are inserted between the thousands groups for
59      * values above 100,000.
60      */
61     public static final String usEnglish =
62         // This rule set shows the normal simple formatting rules for English
63         "%simplified:\n"
64                // negative number rule.  This rule is used to format negative
65                // numbers.  The result of formatting the number's absolute
66                // value is placed where the >> is.
67         + "    -x: minus >>;\n"
68                // faction rule.  This rule is used for formatting numbers
69                // with fractional parts.  The result of formatting the
70                // number's integral part is substituted for the <<, and
71                // the result of formatting the number's fractional part
72                // (one digit at a time, e.g., 0.123 is "zero point one two
73                // three") replaces the >>.
74         + "    x.x: << point >>;\n"
75                // the rules for the values from 0 to 19 are simply the
76                // words for those numbers
77         + "    zero; one; two; three; four; five; six; seven; eight; nine;\n"
78         + "    ten; eleven; twelve; thirteen; fourteen; fifteen; sixteen;\n"
79         + "        seventeen; eighteen; nineteen;\n"
80                // beginning at 20, we use the >> to mark the position where
81                // the result of formatting the number's ones digit.  Thus,
82                // we only need a new rule at every multiple of 10.  Text in
83                // backets is omitted if the value being formatted is an
84                // even multiple of 10.
85         + "    20: twenty[->>];\n"
86         + "    30: thirty[->>];\n"
87         + "    40: forty[->>];\n"
88         + "    50: fifty[->>];\n"
89         + "    60: sixty[->>];\n"
90         + "    70: seventy[->>];\n"
91         + "    80: eighty[->>];\n"
92         + "    90: ninety[->>];\n"
93                // beginning at 100, we can use << to mark the position where
94                // the result of formatting the multiple of 100 is to be
95                // inserted.  Notice also that the meaning of >> has shifted:
96                // here, it refers to both the ones place and the tens place.
97                // The meanings of the << and >> tokens depend on the base value
98                // of the rule.  A rule's divisor is (usually) the highest
99                // power of 10 that is less than or equal to the rule's base
100                // value.  The value being formatted is divided by the rule's
101                // divisor, and the integral quotient is used to get the text
102                // for <<, while the remainder is used to produce the text
103                // for >>.  Again, text in brackets is omitted if the value
104                // being formatted is an even multiple of the rule's divisor
105                // (in this case, an even multiple of 100)
106         + "    100: << hundred[ >>];\n"
107                // The rules for the higher numbers work the same way as the
108                // rule for 100: Again, the << and >> tokens depend on the
109                // rule's divisor, which for all these rules is also the rule's
110                // base value.  To group by thousand, we simply don't have any
111                // rules between 1,000 and 1,000,000.
112         + "    1000: << thousand[ >>];\n"
113         + "    1,000,000: << million[ >>];\n"
114         + "    1,000,000,000: << billion[ >>];\n"
115         + "    1,000,000,000,000: << trillion[ >>];\n"
116                // overflow rule.  This rule specifies that values of a
117                // quadrillion or more are shown in numerals rather than words.
118                // The == token means to format (with new rules) the value
119                // being formatted by this rule and place the result where
120                // the == is.  The #,##0 inside the == signs is a
121                // DecimalFormat pattern.  It specifies that the value should
122                // be formatted with a DecimalFormat object, and that it
123                // should be formatted with no decimal places, at least one
124                // digit, and a thousands separator.
125         + "    1,000,000,000,000,000: =#,##0=;\n"
126
127         // This rule set formats numbers between 1,000 and 9,999 somewhat
128         // differently: If the hundreds digit is not zero, the first two
129         // digits are treated as a number of hundreds.  For example, 2,197
130         // would come out as "twenty-one hundred ninety-seven."
131         + "%alt-teens:\n"
132                // just use %simplified to format values below 1,000
133         + "    =%simplified=;\n"
134                // values between 1,000 and 9,999 are delegated to %%alt-hundreds
135                // for formatting.  The > after "1000" decreases the exponent
136                // of the rule's radix by one, causing the rule's divisor
137                // to be 100 instead of 1,000.  This causes the first TWO
138                // digits of the number, instead of just the first digit,
139                // to be sent to %%alt-hundreds
140         + "    1000>: <%%alt-hundreds<[ >>];\n"
141                // for values of 10,000 and more, we again just use %simplified
142         + "    10,000: =%simplified=;\n"
143         // This rule set uses some obscure voodoo of the description language
144         // to format the first two digits of a value in the thousands.
145         // The rule at 10 formats the first two digits as a multiple of 1,000
146         // and the rule at 11 formats the first two digits as a multiple of
147         // 100.  This works because of something known as the "rollback rule":
148         // if the rule applicable to the value being formatted has two
149         // substitutions, the value being formatted is an even multiple of
150         // the rule's divisor, and the rule's base value ISN'T an even multiple
151         // if the rule's divisor, then the rule that precedes this one in the
152         // list is used instead.  (The [] notation is implemented internally
153         // using this notation: a rule containing [] is split into two rules,
154         // and the right one is chosen using the rollback rule.) In this case,
155         // it means that if the first two digits are an even multiple of 10,
156         // they're formatted with the 10 rule (containing "thousand"), and if
157         // they're not, they're formatted with the 11 rule (containing
158         // "hundred").  %%empty is a hack to cause the rollback rule to be
159         // invoked: it makes the 11 rule have two substitutions, even though
160         // the second substitution (calling %%empty) doesn't actually do
161         // anything.
162         + "%%alt-hundreds:\n"
163         + "    0: SHOULD NEVER GET HERE!;\n"
164         + "    10: <%simplified< thousand;\n"
165         + "    11: =%simplified= hundred>%%empty>;\n"
166         + "%%empty:\n"
167         + "    0:;"
168
169         // this rule set is the same as %simplified, except that it formats
170         // the value as an ordinal number: 234 is formatted as "two hundred
171         // thirty-fourth".  Notice the calls to ^simplified: we have to
172         // call %simplified to avoid getting "second hundred thirty-fourth."
173         + "%ordinal:\n"
174         + "    zeroth; first; second; third; fourth; fifth; sixth; seventh;\n"
175         + "        eighth; ninth;\n"
176         + "    tenth; eleventh; twelfth; thirteenth; fourteenth;\n"
177         + "        fifteenth; sixteenth; seventeenth; eighteenth;\n"
178         + "        nineteenth;\n"
179         + "    twentieth; twenty->>;\n"
180         + "    30: thirtieth; thirty->>;\n"
181         + "    40: fortieth; forty->>;\n"
182         + "    50: fiftieth; fifty->>;\n"
183         + "    60: sixtieth; sixty->>;\n"
184         + "    70: seventieth; seventy->>;\n"
185         + "    80: eightieth; eighty->>;\n"
186         + "    90: ninetieth; ninety->>;\n"
187         + "    100: <%simplified< hundredth; <%simplified< hundred >>;\n"
188         + "    1000: <%simplified< thousandth; <%simplified< thousand >>;\n"
189         + "    1,000,000: <%simplified< millionth; <%simplified< million >>;\n"
190         + "    1,000,000,000: <%simplified< billionth;\n"
191         + "        <%simplified< billion >>;\n"
192         + "    1,000,000,000,000: <%simplified< trillionth;\n"
193         + "        <%simplified< trillion >>;\n"
194         + "    1,000,000,000,000,000: =#,##0=;"
195
196         // %default is a more elaborate form of %simplified;  It is basically
197         // the same, except that it introduces "and" before the ones digit
198         // when appropriate (basically, between the tens and ones digits) and
199         // separates the thousands groups with commas in values over 100,000.
200         + "%default:\n"
201                // negative-number and fraction rules.  These are the same
202                // as those for %simplified, but ave to be stated here too
203                // because this is an entry point
204         + "    -x: minus >>;\n"
205         + "    x.x: << point >>;\n"
206                // just use %simplified for values below 100
207         + "    =%simplified=;\n"
208                // for values from 100 to 9,999 use %%and to decide whether or
209                // not to interpose the "and"
210         + "    100: << hundred[ >%%and>];\n"
211         + "    1000: << thousand[ >%%and>];\n"
212                // for values of 100,000 and up, use %%commas to interpose the
213                // commas in the right places (and also to interpose the "and")
214         + "    100,000>>: << thousand[>%%commas>];\n"
215         + "    1,000,000: << million[>%%commas>];\n"
216         + "    1,000,000,000: << billion[>%%commas>];\n"
217         + "    1,000,000,000,000: << trillion[>%%commas>];\n"
218         + "    1,000,000,000,000,000: =#,##0=;\n"
219         // if the value passed to this rule set is greater than 100, don't
220         // add the "and"; if it's less than 100, add "and" before the last
221         // digits
222         + "%%and:\n"
223         + "    and =%default=;\n"
224         + "    100: =%default=;\n"
225         // this rule set is used to place the commas
226         + "%%commas:\n"
227                // for values below 100, add "and" (the apostrophe at the
228                // beginning is ignored, but causes the space that follows it
229                // to be significant: this is necessary because the rules
230                // calling %%commas don't put a space before it)
231         + "    ' and =%default=;\n"
232                // put a comma after the thousands (or whatever preceded the
233                // hundreds)
234         + "    100: , =%default=;\n"
235                // put a comma after the millions (or whatever precedes the
236                // thousands)
237         + "    1000: , <%default< thousand, >%default>;\n"
238                // and so on...
239         + "    1,000,000: , =%default=;"
240         // %%lenient-parse isn't really a set of number formatting rules;
241         // it's a set of collation rules.  Lenient-parse mode uses a Collator
242         // object to compare fragments of the text being parsed to the text
243         // in the rules, allowing more leeway in the matching text.  This set
244         // of rules tells the formatter to ignore commas when parsing (it
245         // already ignores spaces, which is why we refer to the space; it also
246         // ignores hyphens, making "twenty one" and "twenty-one" parse
247         // identically)
248         + "%%lenient-parse:\n"
249         + "    & ' ' , ',' ;\n";
250
251     /**
252      * Spellout rules for U.K. English.  U.K. English has one significant
253      * difference from U.S. English: the names for values of 1,000,000,000
254      * and higher.  In American English, each successive "-illion" is 1,000
255      * times greater than the preceding one: 1,000,000,000 is "one billion"
256      * and 1,000,000,000,000 is "one trillion."  In British English, each
257      * successive "-illion" is one million times greater than the one before:
258      * "one billion" is 1,000,000,000,000 (or what Americans would call a
259      * "trillion"), and "one trillion" is 1,000,000,000,000,000,000.
260      * 1,000,000,000 in British English is "one thousand million."  (This
261      * value is sometimes called a "milliard," but this word seems to have
262      * fallen into disuse.)
263      */
264     public static final String ukEnglish =
265         "%simplified:\n"
266         + "    -x: minus >>;\n"
267         + "    x.x: << point >>;\n"
268         + "    zero; one; two; three; four; five; six; seven; eight; nine;\n"
269         + "    ten; eleven; twelve; thirteen; fourteen; fifteen; sixteen;\n"
270         + "        seventeen; eighteen; nineteen;\n"
271         + "    20: twenty[->>];\n"
272         + "    30: thirty[->>];\n"
273         + "    40: forty[->>];\n"
274         + "    50: fifty[->>];\n"
275         + "    60: sixty[->>];\n"
276         + "    70: seventy[->>];\n"
277         + "    80: eighty[->>];\n"
278         + "    90: ninety[->>];\n"
279         + "    100: << hundred[ >>];\n"
280         + "    1000: << thousand[ >>];\n"
281         + "    1,000,000: << million[ >>];\n"
282         + "    1,000,000,000,000: << billion[ >>];\n"
283         + "    1,000,000,000,000,000: =#,##0=;\n"
284         + "%alt-teens:\n"
285         + "    =%simplified=;\n"
286         + "    1000>: <%%alt-hundreds<[ >>];\n"
287         + "    10,000: =%simplified=;\n"
288         + "    1,000,000: << million[ >%simplified>];\n"
289         + "    1,000,000,000,000: << billion[ >%simplified>];\n"
290         + "    1,000,000,000,000,000: =#,##0=;\n"
291         + "%%alt-hundreds:\n"
292         + "    0: SHOULD NEVER GET HERE!;\n"
293         + "    10: <%simplified< thousand;\n"
294         + "    11: =%simplified= hundred>%%empty>;\n"
295         + "%%empty:\n"
296         + "    0:;"
297         + "%ordinal:\n"
298         + "    zeroth; first; second; third; fourth; fifth; sixth; seventh;\n"
299         + "        eighth; ninth;\n"
300         + "    tenth; eleventh; twelfth; thirteenth; fourteenth;\n"
301         + "        fifteenth; sixteenth; seventeenth; eighteenth;\n"
302         + "        nineteenth;\n"
303         + "    twentieth; twenty->>;\n"
304         + "    30: thirtieth; thirty->>;\n"
305         + "    40: fortieth; forty->>;\n"
306         + "    50: fiftieth; fifty->>;\n"
307         + "    60: sixtieth; sixty->>;\n"
308         + "    70: seventieth; seventy->>;\n"
309         + "    80: eightieth; eighty->>;\n"
310         + "    90: ninetieth; ninety->>;\n"
311         + "    100: <%simplified< hundredth; <%simplified< hundred >>;\n"
312         + "    1000: <%simplified< thousandth; <%simplified< thousand >>;\n"
313         + "    1,000,000: <%simplified< millionth; <%simplified< million >>;\n"
314         + "    1,000,000,000,000: <%simplified< billionth;\n"
315         + "        <%simplified< billion >>;\n"
316         + "    1,000,000,000,000,000: =#,##0=;"
317         + "%default:\n"
318         + "    -x: minus >>;\n"
319         + "    x.x: << point >>;\n"
320         + "    =%simplified=;\n"
321         + "    100: << hundred[ >%%and>];\n"
322         + "    1000: << thousand[ >%%and>];\n"
323         + "    100,000>>: << thousand[>%%commas>];\n"
324         + "    1,000,000: << million[>%%commas>];\n"
325         + "    1,000,000,000,000: << billion[>%%commas>];\n"
326         + "    1,000,000,000,000,000: =#,##0=;\n"
327         + "%%and:\n"
328         + "    and =%default=;\n"
329         + "    100: =%default=;\n"
330         + "%%commas:\n"
331         + "    ' and =%default=;\n"
332         + "    100: , =%default=;\n"
333         + "    1000: , <%default< thousand, >%default>;\n"
334         + "    1,000,000: , =%default=;"
335         + "%%lenient-parse:\n"
336         + "    & ' ' , ',' ;\n";
337     // Could someone please correct me if I'm wrong about "milliard" falling
338     // into disuse, or have missed any other details of how large numbers
339     // are rendered.  Also, could someone please provide me with information
340     // on which other English-speaking countries use which system?  Right now,
341     // I'm assuming that the U.S. system is used in Canada and that all the
342     // other English-speaking countries follow the British system.  Can
343     // someone out there confirm this?
344
345     /**
346      * Spellout rules for Spanish.  The Spanish rules are quite similar to
347      * the English rules, but there are some important differences:
348      * First, we have to provide separate rules for most of the twenties
349      * because the ones digit frequently picks up an accent mark that it
350      * doesn't have when standing alone.  Second, each multiple of 100 has
351      * to be specified separately because the multiplier on 100 very often
352      * changes form in the contraction: 500 is "quinientos," not
353      * "cincocientos."  In addition, the word for 100 is "cien" when
354      * standing alone, but changes to "ciento" when followed by more digits.
355      * There also some other differences.
356      */
357     public static final String spanish =
358         // negative-number and fraction rules
359         "-x: menos >>;\n"
360         + "x.x: << punto >>;\n"
361         // words for values from 0 to 19
362         + "cero; uno; dos; tres; cuatro; cinco; seis; siete; ocho; nueve;\n"
363         + "diez; once; doce; trece; catorce; quince; diecis\u00e9is;\n"
364         + "    diecisiete; dieciocho; diecinueve;\n"
365         // words for values from 20 to 29 (necessary because the ones digit
366         // often picks up an accent mark it doesn't have when standing alone)
367         + "veinte; veintiuno; veintid\u00f3s; veintitr\u00e9s; veinticuatro;\n"
368         + "    veinticinco; veintis\u00e9is; veintisiete; veintiocho;\n"
369         + "    veintinueve;\n"
370         // words for multiples of 10 (notice that the tens digit is separated
371         // from the ones digit by the word "y".)
372         + "30: treinta[ y >>];\n"
373         + "40: cuarenta[ y >>];\n"
374         + "50: cincuenta[ y >>];\n"
375         + "60: sesenta[ y >>];\n"
376         + "70: setenta[ y >>];\n"
377         + "80: ochenta[ y >>];\n"
378         + "90: noventa[ y >>];\n"
379         // 100 by itself is "cien," but 100 followed by something is "cineto"
380         + "100: cien;\n"
381         + "101: ciento >>;\n"
382         // words for multiples of 100 (must be stated because they're
383         // rarely simple concatenations)
384         + "200: doscientos[ >>];\n"
385         + "300: trescientos[ >>];\n"
386         + "400: cuatrocientos[ >>];\n"
387         + "500: quinientos[ >>];\n"
388         + "600: seiscientos[ >>];\n"
389         + "700: setecientos[ >>];\n"
390         + "800: ochocientos[ >>];\n"
391         + "900: novecientos[ >>];\n"
392         // for 1,000, the multiplier on "mil" is omitted: 2,000 is "dos mil,"
393         // but 1,000 is just "mil."
394         + "1000: mil[ >>];\n"
395         + "2000: << mil[ >>];\n"
396         // 1,000,000 is "un millon," not "uno millon"
397         + "1,000,000: un mill\u00f3n[ >>];\n"
398         + "2,000,000: << mill\u00f3n[ >>];\n"
399         // overflow rule
400         + "1,000,000,000: =#,##0= (incomplete data);";
401     // The Spanish rules are incomplete.  I'm missing information on negative
402     // numbers and numbers with fractional parts.  I also don't have
403     // information on numbers higher than the millions
404
405     /**
406      * Spellout rules for French.  French adds some interesting quirks of its
407      * own: 1) The word "et" is interposed between the tens and ones digits,
408      * but only if the ones digit if 1: 20 is "vingt," and 2 is "vingt-deux,"
409      * but 21 is "vingt-et-un."  2)  There are no words for 70, 80, or 90.
410      * "quatre-vingts" ("four twenties") is used for 80, and values proceed
411      * by score from 60 to 99 (e.g., 73 is "soixante-treize" ["sixty-thirteen"]).
412      * Numbers from 1,100 to 1,199 are rendered as hundreds rather than
413      * thousands: 1,100 is "onze cents" ("eleven hundred"), rather than
414      * "mille cent" ("one thousand one hundred")
415      */
416     public static final String french =
417         // the main rule set
418         "%main:\n"
419                // negative-number and fraction rules
420         + "    -x: moins >>;\n"
421         + "    x.x: << virgule >>;\n"
422                // words for numbers from 0 to 10
423         + "    z\u00e9ro; un; deux; trois; quatre; cinq; six; sept; huit; neuf;\n"
424         + "    dix; onze; douze; treize; quatorze; quinze; seize;\n"
425         + "        dix-sept; dix-huit; dix-neuf;\n"
426                // ords for the multiples of 10: %%alt-ones inserts "et"
427                // when needed
428         + "    20: vingt[->%%alt-ones>];\n"
429         + "    30: trente[->%%alt-ones>];\n"
430         + "    40: quarante[->%%alt-ones>];\n"
431         + "    50: cinquante[->%%alt-ones>];\n"
432                // rule for 60.  The /20 causes this rule's multiplier to be
433                // 20 rather than 10, allowinhg us to recurse for all values
434                // from 60 to 79...
435         + "    60/20: soixante[->%%alt-ones>];\n"
436                // ...except for 71, which must be special-cased
437         + "    71: soixante et onze;\n"
438                // at 72, we have to repeat the rule for 60 to get us to 79
439         + "    72/20: soixante->%%alt-ones>;\n"
440                // at 80, we state a new rule with the phrase for 80.  Since
441                // it changes form when there's a ones digit, we need a second
442                // rule at 81.  This rule also includes "/20," allowing it to
443                // be used correctly for all values up to 99
444         + "    80: quatre-vingts; 81/20: quatre-vingt->>;\n"
445                // "cent" becomes plural when preceded by a multiplier, and
446                // the multiplier is omitted from the singular form
447         + "    100: cent[ >>];\n"
448         + "    200: << cents[ >>];\n"
449         + "    1000: mille[ >>];\n"
450                // values from 1,100 to 1,199 are rendered as "onze cents..."
451                // instead of "mille cent..."  The > after "1000" decreases
452                // the rule's exponent, causing its multiplier to be 100 instead
453                // of 1,000.  This prevents us from getting "onze cents cent
454                // vingt-deux" ("eleven hundred one hundred twenty-two").
455         + "    1100>: onze cents[ >>];\n"
456                // at 1,200, we go back to formating in thousands, so we
457                // repeat the rule for 1,000
458         + "    1200: mille >>;\n"
459                // at 2,000, the multiplier is added
460         + "    2000: << mille[ >>];\n"
461         + "    1,000,000: << million[ >>];\n"
462         + "    1,000,000,000: << milliarde[ >>];\n"
463         + "    1,000,000,000,000: << billion[ >>];\n"
464         + "    1,000,000,000,000,000: =#,##0=;\n"
465         // %%alt-ones is used to insert "et" when the ones digit is 1
466         + "%%alt-ones:\n"
467         + "    ; et-un; =%main=;";
468
469     /**
470      * Spellout rules for Swiss French.  Swiss French differs from French French
471      * in that it does have words for 70, 80, and 90.  This rule set shows them,
472      * and is simpler as a result.
473      */
474     public static final String swissFrench =
475         "%main:\n"
476         + "    -x: moins >>;\n"
477         + "    x.x: << virgule >>;\n"
478         + "    z\u00e9ro; un; deux; trois; quatre; cinq; six; sept; huit; neuf;\n"
479         + "    dix; onze; douze; treize; quatorze; quinze; seize;\n"
480         + "        dix-sept; dix-huit; dix-neuf;\n"
481         + "    20: vingt[->%%alt-ones>];\n"
482         + "    30: trente[->%%alt-ones>];\n"
483         + "    40: quarante[->%%alt-ones>];\n"
484         + "    50: cinquante[->%%alt-ones>];\n"
485         + "    60: soixante[->%%alt-ones>];\n"
486                // notice new words for 70, 80, and 90
487         + "    70: septante[->%%alt-ones>];\n"
488         + "    80: octante[->%%alt-ones>];\n"
489         + "    90: nonante[->%%alt-ones>];\n"
490         + "    100: cent[ >>];\n"
491         + "    200: << cents[ >>];\n"
492         + "    1000: mille[ >>];\n"
493         + "    1100>: onze cents[ >>];\n"
494         + "    1200: mille >>;\n"
495         + "    2000: << mille[ >>];\n"
496         + "    1,000,000: << million[ >>];\n"
497         + "    1,000,000,000: << milliarde[ >>];\n"
498         + "    1,000,000,000,000: << billion[ >>];\n"
499         + "    1,000,000,000,000,000: =#,##0=;\n"
500         + "%%alt-ones:\n"
501         + "    ; et-un; =%main=;";
502     // I'm not 100% sure about Swiss French.  Is
503     // this correct?  Is "onze cents" commonly used for 1,100 in both France
504     // and Switzerland?  Can someone fill me in on the rules for the other
505     // French-speaking countries?  I've heard conflicting opinions on which
506     // version is used in Canada, and I understand there's an alternate set
507     // of words for 70, 80, and 90 that is used somewhere, but I don't know
508     // what those words are or where they're used.
509
510     /**
511      * Spellout rules for German.  German also adds some interesting
512      * characteristics.  For values below 1,000,000, numbers are customarily
513      * written out as a single word.  And the ones digit PRECEDES the tens
514      * digit (e.g., 23 is "dreiundzwanzig," not "zwanzigunddrei").
515      */
516     public static final String german =
517         // 1 is "eins" when by itself, but turns into "ein" in most
518         // combinations
519         "%alt-ones:\n"
520         + "    null; eins; =%%main=;\n"
521         + "%%main:\n"
522                // words for numbers from 0 to 12.  Notice that the values
523                // from 13 to 19 can derived algorithmically, unlike in most
524                // other languages
525         + "    null; ein; zwei; drei; vier; f\u00fcnf; sechs; sieben; acht; neun;\n"
526         + "    zehn; elf; zw\u00f6lf; >>zehn;\n"
527                // rules for the multiples of 10.  Notice that the ones digit
528                // goes on the front
529         + "    20: [>>und]zwanzig;\n"
530         + "    30: [>>und]drei\u00dfig;\n"
531         + "    40: [>>und]vierzig;\n"
532         + "    50: [>>und]f\u00fcnfzig;\n"
533         + "    60: [>>und]sechzig;\n"
534         + "    70: [>>und]siebzig;\n"
535         + "    80: [>>und]achtzig;\n"
536         + "    90: [>>und]neunzig;\n"
537         + "    100: hundert[>%alt-ones>];\n"
538         + "    200: <<hundert[>%alt-ones>];\n"
539         + "    1000: tausend[>%alt-ones>];\n"
540         + "    2000: <<tausend[>%alt-ones>];\n"
541         + "    1,000,000: eine Million[ >%alt-ones>];\n"
542         + "    2,000,000: << Millionen[ >%alt-ones>];\n"
543         + "    1,000,000,000: eine Milliarde[ >%alt-ones>];\n"
544         + "    2,000,000,000: << Milliarden[ >%alt-ones>];\n"
545         + "    1,000,000,000,000: eine Billion[ >%alt-ones>];\n"
546         + "    2,000,000,000,000: << Billionen[ >%alt-ones>];\n"
547         + "    1,000,000,000,000,000: =#,##0=;";
548     // again, I'm not 100% sure of these rules.  I think both "hundert" and
549     // "einhundert" are correct or 100, but I'm not sure which is preferable
550     // in situations where this framework is likely to be used.  Also, is it
551     // really true that numbers are run together into compound words all the
552     // time?  And again, I'm missing information on negative numbers and
553     // decimals.
554
555     /**
556      * Spellout rules for Italian.  Like German, most Italian numbers are
557      * written as single words.  What makes these rules complicated is the rule
558      * that says that when a word ending in a vowel and a word beginning with
559      * a vowel are combined into a compound, the vowel is dropped from the
560      * end of the first word: 180 is "centottanta," not "centoottanta."
561      * The complexity of this rule set is to produce this behavior.
562      */
563     public static final String italian =
564         // main rule set.  Follows the patterns of the preceding rule sets,
565         // except that the final vowel is omitted from words ending in
566         // vowels when they are followed by another word; instead, we have
567         // separate rule sets that are identical to this one, except that
568         // all the words that don't begin with a vowel have a vowel tacked
569         // onto them at the front.  A word ending in a vowel calls a
570         // substitution that will supply that vowel, unless that vowel is to
571         // be elided.
572         "%main:\n"
573         + "    -x: meno >>;\n"
574         + "    x.x: << virgola >>;\n"
575         + "    zero; uno; due; tre; quattro; cinque; sei; sette; otto;\n"
576         + "        nove;\n"
577         + "    dieci; undici; dodici; tredici; quattordici; quindici; sedici;\n"
578         + "        diciasette; diciotto; diciannove;\n"
579         + "    20: venti; vent>%%with-i>;\n"
580         + "    30: trenta; trent>%%with-i>;\n"
581         + "    40: quaranta; quarant>%%with-a>;\n"
582         + "    50: cinquanta; cinquant>%%with-a>;\n"
583         + "    60: sessanta; sessant>%%with-a>;\n"
584         + "    70: settanta; settant>%%with-a>;\n"
585         + "    80: ottanta; ottant>%%with-a>;\n"
586         + "    90: novanta; novant>%%with-a>;\n"
587         + "    100: cento; cent[>%%with-o>];\n"
588         + "    200: <<cento; <<cent[>%%with-o>];\n"
589         + "    1000: mille; mill[>%%with-i>];\n"
590         + "    2000: <<mila; <<mil[>%%with-a>];\n"
591         + "    100,000>>: <<mila[ >>];\n"
592         + "    1,000,000: =#,##0= (incomplete data);\n"
593         + "%%with-a:\n"
594         + "    azero; uno; adue; atre; aquattro; acinque; asei; asette; otto;\n"
595         + "        anove;\n"
596         + "    adieci; undici; adodici; atredici; aquattordici; aquindici; asedici;\n"
597         + "        adiciasette; adiciotto; adiciannove;\n"
598         + "    20: aventi; avent>%%with-i>;\n"
599         + "    30: atrenta; atrent>%%with-i>;\n"
600         + "    40: aquaranta; aquarant>%%with-a>;\n"
601         + "    50: acinquanta; acinquant>%%with-a>;\n"
602         + "    60: asessanta; asessant>%%with-a>;\n"
603         + "    70: asettanta; asettant>%%with-a>;\n"
604         + "    80: ottanta; ottant>%%with-a>;\n"
605         + "    90: anovanta; anovant>%%with-a>;\n"
606         + "    100: acento; acent[>%%with-o>];\n"
607         + "    200: <%%with-a<cento; <%%with-a<cent[>%%with-o>];\n"
608         + "    1000: amille; amill[>%%with-i>];\n"
609         + "    2000: <%%with-a<mila; <%%with-a<mil[>%%with-a>];\n"
610         + "    100,000: =%main=;\n"
611         + "%%with-i:\n"
612         + "    izero; uno; idue; itre; iquattro; icinque; isei; isette; otto;\n"
613         + "        inove;\n"
614         + "    idieci; undici; idodici; itredici; iquattordici; iquindici; isedici;\n"
615         + "        idiciasette; idiciotto; idiciannove;\n"
616         + "    20: iventi; ivent>%%with-i>;\n"
617         + "    30: itrenta; itrent>%%with-i>;\n"
618         + "    40: iquaranta; iquarant>%%with-a>;\n"
619         + "    50: icinquanta; icinquant>%%with-a>;\n"
620         + "    60: isessanta; isessant>%%with-a>;\n"
621         + "    70: isettanta; isettant>%%with-a>;\n"
622         + "    80: ottanta; ottant>%%with-a>;\n"
623         + "    90: inovanta; inovant>%%with-a>;\n"
624         + "    100: icento; icent[>%%with-o>];\n"
625         + "    200: <%%with-i<cento; <%%with-i<cent[>%%with-o>];\n"
626         + "    1000: imille; imill[>%%with-i>];\n"
627         + "    2000: <%%with-i<mila; <%%with-i<mil[>%%with-a>];\n"
628         + "    100,000: =%main=;\n"
629         + "%%with-o:\n"
630         + "    ozero; uno; odue; otre; oquattro; ocinque; osei; osette; otto;\n"
631         + "        onove;\n"
632         + "    odieci; undici; ododici; otredici; oquattordici; oquindici; osedici;\n"
633         + "        odiciasette; odiciotto; odiciannove;\n"
634         + "    20: oventi; ovent>%%with-i>;\n"
635         + "    30: otrenta; otrent>%%with-i>;\n"
636         + "    40: oquaranta; oquarant>%%with-a>;\n"
637         + "    50: ocinquanta; ocinquant>%%with-a>;\n"
638         + "    60: osessanta; osessant>%%with-a>;\n"
639         + "    70: osettanta; osettant>%%with-a>;\n"
640         + "    80: ottanta; ottant>%%with-a>;\n"
641         + "    90: onovanta; onovant>%%with-a>;\n"
642         + "    100: ocento; ocent[>%%with-o>];\n"
643         + "    200: <%%with-o<cento; <%%with-o<cent[>%%with-o>];\n"
644         + "    1000: omille; omill[>%%with-i>];\n"
645         + "    2000: <%%with-o<mila; <%%with-o<mil[>%%with-a>];\n"
646         + "    100,000: =%main=;\n";
647     // Can someone confirm that I did the vowel-eliding thing right?  I'm
648     // not 100% sure I'm doing it in all the right places, or completely
649     // correctly.  Also, I don't have information for negatives and decimals,
650     // and I lack words fror values from 1,000,000 on up.
651
652     /**
653      * Spellout rules for Swedish.
654      */
655     public static final String swedish =
656         "noll; ett; tv\u00e5; tre; fyra; fem; sex; sjo; \u00e5tta; nio;\n"
657         + "tio; elva; tolv; tretton; fjorton; femton; sexton; sjutton; arton; nitton;\n"
658         + "20: tjugo[>>];\n"
659         + "30: trettio[>>];\n"
660         + "40: fyrtio[>>];\n"
661         + "50: femtio[>>];\n"
662         + "60: sextio[>>];\n"
663         + "70: sjuttio[>>];\n"
664         + "80: \u00e5ttio[>>];\n"
665         + "90: nittio[>>];\n"
666         + "100: hundra[>>];\n"
667         + "200: <<hundra[>>];\n"
668         + "1000: tusen[ >>];\n"
669         + "2000: << tusen[ >>];\n"
670         + "1,000,000: en miljon[ >>];\n"
671         + "2,000,000: << miljon[ >>];\n"
672         + "1,000,000,000: en miljard[ >>];\n"
673         + "2,000,000,000: << miljard[ >>];\n"
674         + "1,000,000,000,000: en biljon[ >>];\n"
675         + "2,000,000,000,000: << biljon[ >>];\n"
676         + "1,000,000,000,000,000: =#,##0=";
677     // can someone supply me with information on negatives and decimals?
678
679     /**
680      * Spellout rules for Dutch.  Notice that in Dutch, as in German,
681      * the ones digit precedes the tens digit.
682      */
683     public static final String dutch =
684         " -x: min >>;\n"
685         + "x.x: << komma >>;\n"
686         + "(zero?); een; twee; drie; vier; vijf; zes; zeven; acht; negen;\n"
687         + "tien; elf; twaalf; dertien; veertien; vijftien; zestien;\n"
688         + "zeventien; achtien; negentien;\n"
689         + "20: [>> en ]twintig;\n"
690         + "30: [>> en ]dertig;\n"
691         + "40: [>> en ]veertig;\n"
692         + "50: [>> en ]vijftig;\n"
693         + "60: [>> en ]zestig;\n"
694         + "70: [>> en ]zeventig;\n"
695         + "80: [>> en ]tachtig;\n"
696         + "90: [>> en ]negentig;\n"
697         + "100: << honderd[ >>];\n"
698         + "1000: << duizend[ >>];\n"
699         + "1,000,000: << miljoen[ >>];\n"
700         + "1,000,000,000: << biljoen[ >>];\n"
701         + "1,000,000,000,000: =#,##0=";
702
703     /**
704      * Spellout rules for Japanese.  In Japanese, there really isn't any
705      * distinction between a number written out in digits and a number
706      * written out in words: the ideographic characters are both digits
707      * and words.  This rule set provides two variants:  %traditional
708      * uses the traditional CJK numerals (which are also used in China
709      * and Korea).  %financial uses alternate ideographs for many numbers
710      * that are harder to alter than the traditional numerals (one could
711      * fairly easily change a one to
712      * a three just by adding two strokes, for example).  This is also done in
713      * the other countries using Chinese idographs, but different ideographs
714      * are used in those places.
715      */
716     public static final String japanese =
717         "%financial:\n"
718         + "    \u96f6; \u58f1; \u5f10; \u53c2; \u56db; \u4f0d; \u516d; \u4e03; \u516b; \u4e5d;\n"
719         + "    \u62fe[>>];\n"
720         + "    20: <<\u62fe[>>];\n"
721         + "    100: <<\u767e[>>];\n"
722         + "    1000: <<\u5343[>>];\n"
723         + "    10,000: <<\u4e07[>>];\n"
724         + "    100,000,000: <<\u5104[>>];\n"
725         + "    1,000,000,000,000: <<\u5146[>>];\n"
726         + "    10,000,000,000,000,000: =#,##0=;\n"
727         + "%traditional:\n"
728         + "    \u96f6; \u4e00; \u4e8c; \u4e09; \u56db; \u4e94; \u516d; \u4e03; \u516b; \u4e5d;\n"
729         + "    \u5341[>>];\n"
730         + "    20: <<\u5341[>>];\n"
731         + "    100: <<\u767e[>>];\n"
732         + "    1000: <<\u5343[>>];\n"
733         + "    10,000: <<\u4e07[>>];\n"
734         + "    100,000,000: <<\u5104[>>];\n"
735         + "    1,000,000,000,000: <<\u5146[>>];\n"
736         + "    10,000,000,000,000,000: =#,##0=;";
737     // Can someone supply me with the right fraud-proof ideographs for
738     // Simplified and Traditional Chinese, and for Korean?  Can someone
739     // supply me with information on negatives and decimals?
740
741     /**
742      * Spellout rules for Greek.  Again in Greek we have to supply the words
743      * for the multiples of 100 because they can't be derived algorithmically.
744      * Also, the tens dgit changes form when followed by a ones digit: an
745      * accent mark disappears from the tens digit and moves to the ones digit.
746      * Therefore, instead of using the [] notation, we actually have to use
747      * two separate rules for each multiple of 10 to show the two forms of
748      * the word.
749      */
750     public static final String greek =
751         "zero (incomplete data); \u03ad\u03bd\u03b1; \u03b4\u03cd\u03bf; \u03b4\u03c1\u03af\u03b1; "
752         + "\u03c4\u03ad\u03c3\u03c3\u03b5\u03c1\u03b1; \u03c0\u03ad\u03bd\u03c4\u03b5; "
753         + "\u03ad\u03be\u03b9; \u03b5\u03c0\u03c4\u03ac; \u03bf\u03ba\u03c4\u03ce; "
754         + "\u03b5\u03bd\u03bd\u03ad\u03b1;\n"
755         + "10: \u03b4\u03ad\u03ba\u03b1; "
756         + "\u03ad\u03bd\u03b4\u03b5\u03ba\u03b1; \u03b4\u03ce\u03b4\u03b5\u03ba\u03b1; "
757         + "\u03b4\u03b5\u03ba\u03b1>>;\n"
758         + "20: \u03b5\u03af\u03ba\u03bf\u03c3\u03b9; \u03b5\u03b9\u03ba\u03bf\u03c3\u03b9>>;\n"
759         + "30: \u03c4\u03c1\u03b9\u03ac\u03bd\u03c4\u03b1; \u03c4\u03c1\u03b9\u03b1\u03bd\u03c4\u03b1>>;\n"
760         + "40: \u03c3\u03b1\u03c1\u03ac\u03bd\u03c4\u03b1; \u03c3\u03b1\u03c1\u03b1\u03bd\u03c4\u03b1>>;\n"
761         + "50: \u03c0\u03b5\u03bd\u03ae\u03bd\u03c4\u03b1; \u03c0\u03b5\u03bd\u03b7\u03bd\u03c4\u03b1>>;\n"
762         + "60: \u03b5\u03be\u03ae\u03bd\u03c4\u03b1; \u03b5\u03be\u03b7\u03bd\u03c4\u03b1>>;\n"
763         + "70: \u03b5\u03b2\u03b4\u03bf\u03bc\u03ae\u03bd\u03c4\u03b1; "
764         + "\u03b5\u03b2\u03b4\u03bf\u03bc\u03b7\u03bd\u03c4\u03b1>>;\n"
765         + "80: \u03bf\u03b3\u03b4\u03cc\u03bd\u03c4\u03b1; \u03bf\u03b3\u03b4\u03bf\u03bd\u03c4\u03b1>>;\n"
766         + "90: \u03b5\u03bd\u03bd\u03b5\u03bd\u03ae\u03bd\u03c4\u03b1; "
767         + "\u03b5\u03bd\u03bd\u03b5\u03bd\u03b7\u03bd\u03c4\u03b1>>;\n"
768         + "100: \u03b5\u03ba\u03b1\u03c4\u03cc[\u03bd >>];\n"
769         + "200: \u03b4\u03b9\u03b1\u03ba\u03cc\u03c3\u03b9\u03b1[ >>];\n"
770         + "300: \u03c4\u03c1\u03b9\u03b1\u03ba\u03cc\u03c3\u03b9\u03b1[ >>];\n"
771         + "400: \u03c4\u03b5\u03c4\u03c1\u03b1\u03ba\u03cc\u03c3\u03b9\u03b1[ >>];\n"
772         + "500: \u03c0\u03b5\u03bd\u03c4\u03b1\u03ba\u03cc\u03c3\u03b9\u03b1[ >>];\n"
773         + "600: \u03b5\u03be\u03b1\u03ba\u03cc\u03c3\u03b9\u03b1[ >>];\n"
774         + "700: \u03b5\u03c0\u03c4\u03b1\u03ba\u03cc\u03c3\u03b9\u03b1[ >>];\n"
775         + "800: \u03bf\u03ba\u03c4\u03b1\u03ba\u03cc\u03c3\u03b9\u03b1[ >>];\n"
776         + "900: \u03b5\u03bd\u03bd\u03b9\u03b1\u03ba\u03cc\u03c3\u03b9\u03b1[ >>];\n"
777         + "1000: \u03c7\u03af\u03bb\u03b9\u03b1[ >>];\n"
778         + "2000: << \u03c7\u03af\u03bb\u03b9\u03b1[ >>];\n"
779         + "1,000,000: << \u03b5\u03ba\u03b1\u03c4\u03bf\u03bc\u03bc\u03b9\u03cc\u03c1\u03b9\u03bf[ >>];\n"
780         + "1,000,000,000: << \u03b4\u03b9\u03c3\u03b5\u03ba\u03b1\u03c4\u03bf\u03bc\u03bc\u03b9\u03cc\u03c1\u03b9\u03bf[ >>];\n"
781         + "1,000,000,000,000: =#,##0=";
782     // Can someone supply me with information on negatives and decimals?
783     // I'm also missing the word for zero.  Can someone clue me in?
784
785     /**
786      * Spellout rules for Russian.
787      */
788     public static final String russian =
789         "\u043d\u043e\u043b\u044c; \u043e\u0434\u0438\u043d; \u0434\u0432\u0430; \u0442\u0440\u0438; "
790         + "\u0447\u0435\u0442\u044b\u0440\u0435; \u043f\u044f\u0442; \u0448\u0435\u0441\u0442; "
791         + "\u0441\u0435\u043c\u044c; \u0432\u043e\u0441\u0435\u043c\u044c; \u0434\u0435\u0432\u044f\u0442;\n"
792         + "10: \u0434\u0435\u0441\u044f\u0442; "
793         + "\u043e\u0434\u0438\u043d\u043d\u0430\u0434\u0446\u0430\u0442\u044c;\n"
794         + "\u0434\u0432\u0435\u043d\u043d\u0430\u0434\u0446\u0430\u0442\u044c; "
795         + "\u0442\u0440\u0438\u043d\u0430\u0434\u0446\u0430\u0442\u044c; "
796         + "\u0447\u0435\u0442\u044b\u0440\u043d\u0430\u0434\u0446\u0430\u0442\u044c;\n"
797         + "15: \u043f\u044f\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u044c; "
798         + "\u0448\u0435\u0441\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u044c; "
799         + "\u0441\u0435\u043c\u043d\u0430\u0434\u0446\u0430\u0442\u044c; "
800         + "\u0432\u043e\u0441\u0435\u043c\u043d\u0430\u0434\u0446\u0430\u0442\u044c; "
801         + "\u0434\u0435\u0432\u044f\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u044c;\n"
802         + "20: \u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044c[ >>];\n"
803         + "30: \u0442\u0440\u043b\u0434\u0446\u0430\u0442\u044c[ >>];\n"
804         + "40: \u0441\u043e\u0440\u043e\u043a[ >>];\n"
805         + "50: \u043f\u044f\u0442\u044c\u0434\u0435\u0441\u044f\u0442[ >>];\n"
806         + "60: \u0448\u0435\u0441\u0442\u044c\u0434\u0435\u0441\u044f\u0442[ >>];\n"
807         + "70: \u0441\u0435\u043c\u044c\u0434\u0435\u0441\u044f\u0442[ >>];\n"
808         + "80: \u0432\u043e\u0441\u0435\u043c\u044c\u0434\u0435\u0441\u044f\u0442[ >>];\n"
809         + "90: \u0434\u0435\u0432\u044f\u043d\u043e\u0441\u0442\u043e[ >>];\n"
810         + "100: \u0441\u0442\u043e[ >>];\n"
811         + "200: << \u0441\u0442\u043e[ >>];\n"
812         + "1000: \u0442\u044b\u0441\u044f\u0447\u0430[ >>];\n"
813         + "2000: << \u0442\u044b\u0441\u044f\u0447\u0430[ >>];\n"
814         + "1,000,000: \u043c\u0438\u043b\u043b\u0438\u043e\u043d[ >>];\n"
815         + "2,000,000: << \u043c\u0438\u043b\u043b\u0438\u043e\u043d[ >>];\n"
816         + "1,000,000,000: =#,##0=;";
817     // Can someone supply me with information on negatives and decimals?
818     // How about words for billions and trillions?
819
820     /**
821      * Spellout rules for Hebrew.  Hebrew actually has inflected forms for
822      * most of the lower-order numbers.  The masculine forms are shown
823      * here.
824      */
825     public static final String hebrew =
826         "zero (incomplete data); \u05d0\u05d4\u05d3; \u05e9\u05d2\u05d9\u05d9\u05dd; \u05e9\u05dc\u05d5\u05e9\u05d4;\n"
827         + "4: \u05d0\u05d3\u05d1\u05e6\u05d4; \u05d7\u05d2\u05d5\u05d9\u05e9\u05d4; \u05e9\u05e9\u05d4;\n"
828         + "7: \u05e9\u05d1\u05e6\u05d4; \u05e9\u05de\u05d5\u05d2\u05d4; \u05ea\u05e9\u05e6\u05d4;\n"
829         + "10: \u05e6\u05e9\u05d3\u05d4[ >>];\n"
830         + "20: \u05e6\u05e9\u05d3\u05d9\u05dd[ >>];\n"
831         + "30: \u05e9\u05dc\u05d5\u05e9\u05d9\u05dd[ >>];\n"
832         + "40: \u05d0\u05d3\u05d1\u05e6\u05d9\u05dd[ >>];\n"
833         + "50: \u05d7\u05de\u05d9\u05e9\u05d9\u05dd[ >>];\n"
834         + "60: \u05e9\u05e9\u05d9\u05dd[ >>];\n"
835         + "70: \u05e9\u05d1\u05e6\u05d9\u05dd[ >>];\n"
836         + "80: \u05e9\u05de\u05d5\u05d2\u05d9\u05dd[ >>];\n"
837         + "90: \u05ea\u05e9\u05e6\u05d9\u05dd[ >>];\n"
838         + "100: \u05de\u05d0\u05d4[ >>];\n"
839         + "200: << \u05de\u05d0\u05d4[ >>];\n"
840         + "1000: \u05d0\u05dc\u05e3[ >>];\n"
841         + "2000: << \u05d0\u05dc\u05e3[ >>];\n"
842         + "1,000,000: =#,##0= (incomplete data);";
843     // This data is woefully incomplete.  Can someone fill me in on the
844     // various inflected forms of the numbers, which seem to be necessary
845     // to do Hebrew correctly?  Can somone supply me with data for values
846     // from 1,000,000 on up?  What about the word for zero?  What about
847     // information on negatives and decimals?
848
849     //========================================================================
850     // Simple examples
851     //========================================================================
852
853     /**
854      * This rule set adds an English ordinal abbreviation to the end of a
855      * number.  For example, 2 is formatted as "2nd".  Parsing doesn't work with
856      * this rule set.  To parse, use DecimalFormat on the numeral.
857      */
858     public static final String ordinal =
859         // this rule set formats the numeral and calls %%abbrev to
860         // supply the abbreviation
861         "%main:\n"
862         + "    =#,##0==%%abbrev=;\n"
863         // this rule set supplies the abbreviation
864         + "%%abbrev:\n"
865                // the abbreviations.  Everything from 4 to 19 ends in "th"
866         + "    th; st; nd; rd; th;\n"
867                // at 20, we begin repeating the cycle every 10 (13 is "13th",
868                // but 23 and 33 are "23rd" and "33rd")  We do this by
869                // ignoring all bug the ones digit in selecting the abbreviation
870         + "    20: >>;\n"
871                // at 100, we repeat the whole cycle by considering only the
872                // tens and ones digits in picking an abbreviation
873         + "    100: >>;\n";
874
875     /**
876      * This is a simple message-formatting example.  Normally one would
877      * use ChoiceFormat and MessageFormat to do something this simple,
878      * but this shows it could be done with RuleBasedNumberFormat too.
879      * A message-formatting example that might work better with
880      * RuleBasedNumberFormat appears later.
881      */
882     public static final String message1 =
883         // this rule surrounds whatever the other rules produce with the
884         // rest of the sentence
885         "x.0: The search found <<.;\n"
886         // use words for values below 10 (and change to "file" for 1)
887         + "no files; one file; two files; three files; four files; five files;\n"
888         + "    six files; seven files; eight files; nine files;\n"
889         // use numerals for values higher than 10
890         + "=#,##0= files;";
891
892     //========================================================================
893     // Fraction handling
894     //
895     // The next few examples show how RuleBasedNumberFormat can be used for
896     // more flexible handling of fractions
897     //========================================================================
898
899     /**
900      * This example formats a number in one of the two styles often used
901      * on checks.  %dollars-and-hundredths formats cents as hundredths of
902      * a dollar (23.40 comes out as "twenty-three and 40/100 dollars").
903      * %dollars-and-cents formats in dollars and cents (23.40 comes out as
904      * "twenty-three dollars and forty cents")
905      */
906     public static final String dollarsAndCents =
907         // this rule set formats numbers as dollars and cents
908         "%dollars-and-cents:\n"
909                // if the value is 1 or more, put "xx dollars and yy cents".
910                // the "and y cents" part is suppressed if the value is an
911                // even number of dollars
912         + "    x.0: << [and >%%cents>];\n"
913                // if the value is between 0 and 1, put "xx cents"
914         + "    0.x: >%%cents>;\n"
915                // these three rules take care of the singular and plural
916                // forms of "dollar" and use %%main to format the number
917         + "    0: zero dollars; one dollar; =%%main= dollars;\n"
918         // these are the regular U.S. English number spellout rules
919         + "%%main:\n"
920         + "    zero; one; two; three; four; five; six; seven; eight; nine;\n"
921         + "    ten; eleven; twelve; thirteen; fourteen; fifteen; sixteen;\n"
922         + "        seventeen; eighteen; nineteen;\n"
923         + "    20: twenty[->>];\n"
924         + "    30: thirty[->>];\n"
925         + "    40: forty[->>];\n"
926         + "    50: fifty[->>];\n"
927         + "    60: sixty[->>];\n"
928         + "    70: seventy[->>];\n"
929         + "    80: eighty[->>];\n"
930         + "    90: ninety[->>];\n"
931         + "    100: << hundred[ >>];\n"
932         + "    1000: << thousand[ >>];\n"
933         + "    1,000,000: << million[ >>];\n"
934         + "    1,000,000,000: << billion[ >>];\n"
935         + "    1,000,000,000,000: << trillion[ >>];\n"
936         + "    1,000,000,000,000,000: =#,##0=;\n"
937         // this rule takes care of the fractional part of the value.  It
938         // multiplies the fractional part of the number being formatted by
939         // 100, formats it with %%main, and then addes the word "cent" or
940         // "cents" to the end.  (The text in brackets is omitted if the
941         // numerator of the fraction is 1.)
942         + "%%cents:\n"
943         + "    100: <%%main< cent[s];\n"
944
945         // this rule set formats numbers as dollars and hundredths of dollars
946         + "%dollars-and-hundredths:\n"
947                // this rule takes care of the general shell of the output
948                // string.  We always show the cents, even when there aren't
949                // any.  Because of this, the word is always "dollars"--
950                // we don't have to worry about the singular form.  We use
951                // %%main to format the number of dollars and %%hundredths to
952                // format the number of cents
953         + "    x.0: <%%main< and >%%hundredths>/100 dollars;\n"
954         // this rule set formats the cents for %dollars-and-hundredths.
955         // It multiplies the fractional part of the number by 100 and formats
956         // the result using a DecimalFormat ("00" tells the DecimalFormat to
957         // always use two digits, even for numbers under 10)
958         + "%%hundredths:\n"
959         + "    100: <00<;\n";
960
961     /**
962      * This rule set shows the fractional part of the number as a fraction
963      * with a power of 10 as the denominator.  Some languages don't spell
964      * out the fractional part of a number as "point one two three," but
965      * always render it as a fraction.  If we still want to treat the fractional
966      * part of the number as a decimal, then the fraction's denominator
967      * is always a power of 10.  This example does that: 23.125 is formatted
968      * as "twenty-three and one hundred twenty-five thousandths" (as opposed
969      * to "twenty-three point one two five" or "twenty-three and one eighth").
970      */
971     public static final String decimalAsFraction =
972         // the regular U.S. English spellout rules, with one difference
973         "%main:\n"
974         + "    -x: minus >>;\n"
975                // the difference.  This rule uses %%frac to show the fractional
976                // part of the number.  Text in brackets is omitted when the
977                // value is between 0 and 1 (causing 0.3 to come out as "three
978                // tenths" instead of "zero and three tenths").
979         + "    x.x: [<< and ]>%%frac>;\n"
980         + "    zero; one; two; three; four; five; six; seven; eight; nine;\n"
981         + "    ten; eleven; twelve; thirteen; fourteen; fifteen; sixteen;\n"
982         + "        seventeen; eighteen; nineteen;\n"
983         + "    twenty[->>];\n"
984         + "    30: thirty[->>];\n"
985         + "    40: forty[->>];\n"
986         + "    50: fifty[->>];\n"
987         + "    60: sixty[->>];\n"
988         + "    70: seventy[->>];\n"
989         + "    80: eighty[->>];\n"
990         + "    90: ninety[->>];\n"
991         + "    100: << hundred[ >>];\n"
992         + "    1000: << thousand[ >>];\n"
993         + "    1,000,000: << million[ >>];\n"
994         + "    1,000,000,000: << billion[ >>];\n"
995         + "    1,000,000,000,000: << trillion[ >>];\n"
996         + "    1,000,000,000,000,000: =#,##0=;\n"
997         // the rule set that formats the fractional part of the number.
998         // The rule that is used is the one that, when its baase value is
999         // multiplied by the fractional part of the number being formatted,
1000         // produces the result closest to zero.  Thus, the base values are
1001         // prospective denominators of the fraction.  The << marks the place
1002         // where the numerator of the fraction (the result of multiplying the
1003         // fractional part of the number by the rule's base value) is
1004         // placed.  Text in brackets is omitted when the numerator is 1, giving
1005         // us the singular and plural forms of the words.
1006         // [In languages where the singular and plural are completely different
1007         // words, the rule can just be stated twice: the second time with
1008         // the plural form.]
1009         + "%%frac:\n"
1010         + "    10: << tenth[s];\n"
1011         + "    100: << hundredth[s];\n"
1012         + "    1000: << thousandth[s];\n"
1013         + "    10,000: << ten-thousandth[s];\n"
1014         + "    100,000: << hundred-thousandth[s];\n"
1015         + "    1,000,000: << millionth[s];";
1016
1017     /**
1018      * Number with closest fraction.  This example formats a value using
1019      * numerals, but shows the fractional part as a ratio (fraction) rather
1020      * than a decimal.  The fraction always has a denominator between 2 and 10.
1021      */
1022     public static final String closestFraction =
1023         "%main:\n"
1024                // this rule formats the number if it's 1 or more.  It formats
1025                // the integral part using a DecimalFormat ("#,##0" puts
1026                // thousands separators in the right places) and the fractional
1027                // part using %%frac.  If there is no fractional part, it
1028                // just shows the integral part.
1029         + "    x.0: <#,##0<[ >%%frac>];\n"
1030                // this rule formats the number if it's between 0 and 1.  It
1031                // shows only the fractional part (0.5 shows up as "1/2," not
1032                // "0 1/2")
1033         + "    0.x: >%%frac>;\n"
1034         // the fraction rule set.  This works the same way as the one in the
1035         // preceding example: We multiply the fractional part of the number
1036         // being formatted by each rule's base value and use the rule that
1037         // produces the result closest to 0 (or the first rule that produces 0).
1038         // Since we only provide rules for the numbers from 2 to 10, we know
1039         // we'll get a fraction with a denominator between 2 and 10.
1040         // "<0<" causes the numerator of the fraction to be formatted
1041         // using numerals
1042         + "%%frac:\n"
1043         + "    2: 1/2;\n"
1044         + "    3: <0</3;\n"
1045         + "    4: <0</4;\n"
1046         + "    5: <0</5;\n"
1047         + "    6: <0</6;\n"
1048         + "    7: <0</7;\n"
1049         + "    8: <0</8;\n"
1050         + "    9: <0</9;\n"
1051         + "    10: <0</10;\n";
1052
1053     /**
1054      * American stock-price formatting.  Non-integral stock prices are still
1055      * generally shown in eighths or sixteenths of dollars instead of dollars
1056      * and cents.  This example formats stock prices in this way if possible,
1057      * and in dollars and cents if not.
1058      */
1059     public static final String stock =
1060         "%main:\n"
1061                // this rule formats the integral part of the number in numerals
1062                // and (if necessary) the fractional part using %%frac1
1063         + "    x.0: <#,##0<[>%%frac1>];\n"
1064                // this rule is used for values between 0 and 1 and omits the
1065                // integral part
1066         + "    0.x: >%%frac2>;\n"
1067         // this rule set is used to format the fractional part of the number when
1068         // there's an integral part before it (again, we try all denominators
1069         // and use the "best" one)
1070         + "%%frac1:\n"
1071                // for even multiples of 1/4, format the fraction using the
1072                // typographer's fractions
1073         + "    4: <%%quarters<;\n"
1074                // format the value as a number of eighths, sixteenths, or
1075                // thirty-seconds, whichever produces the most accurate value.
1076                // The apostrophe at the front of these rules is ignored, but
1077                // it makes the space that follows it significant.  This puts a
1078                // space between the value's integral and fractional parts so
1079                // you can read it
1080         + "    8: ' <0</8;\n"
1081         + "    16: ' <0</16;\n"
1082         + "    32: ' <0</32;\n"
1083                // if we can't reasonably format the number in powers of 2,
1084                // then show it as dollars and cents
1085         + "    100: .<00<;\n"
1086         // this rule set is used when the fractional part of the value stands
1087         // alone
1088         + "%%frac2:\n"
1089         + "    4: <%%quarters<;\n"
1090                // for fractions that we can't show using typographer's fractions,
1091                // we don't have to put a space before the fraction
1092         + "    8: <0</8;\n"
1093         + "    16: <0</16;\n"
1094         + "    32: <0</32;\n"
1095                // but dollars and cents look better with a leading 0
1096         + "    100: 0.<00<;\n"
1097         // this rule set formats 1/4, 1/2, and 3/4 using typographer's fractions
1098         + "%%quarters:\n"
1099         + "    ; \u00bc; \u00bd; \u00be;\n"
1100         // there are the lenient-parse rules.  These allow the user to type
1101         // "1/4," "1/2," and "3/4" instead of their typographical counterparts
1102         // and still have them be understood by the formatter
1103         + "%%lenient-parse:\n"
1104         + "    & '1/4' , \u00bc\n"
1105         + "    & '1/2' , \u00bd\n"
1106         + "    & '3/4' , \u00be\n;";
1107
1108     //========================================================================
1109     // Changing dimensions
1110     //
1111     // The next few examples demonstrate using a RuleBasedNumberFormat to
1112     // change the units a value is denominated in depending on its magnitude
1113     //========================================================================
1114
1115     /**
1116      * The example shows large numbers the way they often appear is nwespapers:
1117      * 1,200,000 is formatted as "1.2 million".
1118      */
1119     public static final String abbEnglish =
1120         "=#,##0=;\n"
1121         // this is fairly self-explanatory, but note that the << substitution
1122         // can show the fractional part of the substitution value if the user
1123         // wants it
1124         + "1,000,000: <##0.###< million;\n"
1125         + "1,000,000,000: <##0.###< billion;\n"
1126         + "1,000,000,000,000: <##0.###< trillion;\n";
1127
1128     /**
1129      * This example takes a number of meters and formats it in whatever unit
1130      * will produce a number with from one to three digits before the decimal
1131      * point.  For example, 230,000 is formatted as "230 km".
1132      */
1133     public static final String units =
1134         "%main:\n"
1135                // for values between 0 and 1, delegate to %%small
1136         + "    0.x: >%%small>;\n"
1137                // otherwise, show between 3 and 6 significant digits of the value
1138                // along with the most appropriate unit
1139         + "    0: =##0.###= m;\n"
1140         + "    1,000: <##0.###< km;\n"
1141         + "    1,000,000: <##0.###< Mm;\n"
1142         + "    1,000,000,000: <##0.###< Gm;\n"
1143         + "    1,000,000,000,000: <#,##0.###< Tm;\n"
1144         // %%small formats the number when it's less then 1.  It multiplies the
1145         // value by one billion, and then uses %%small2 to actually do the
1146         // formatting.
1147         + "%%small:\n"
1148         + "    1,000,000,000,000: <%%small2<;\n"
1149         // this rule set actually formats small values.  %%small passes this
1150         // rule set a number of picometers, and it takes care of scaling up as
1151         // appropriate in exactly the same way %main does (we can't normally
1152         // handle fractional values this way: here, we're concerned about
1153         // magnitude; most of the time, we're concerned about precsion)
1154         + "%%small2:\n"
1155         + "    0: =##0= pm;\n"
1156         + "    1,000: <##0.###< nm;\n"
1157         + "    1,000,000: <##0.###< \u00b5m;\n"
1158         + "    1,000,000,000: <##0.###< mm;\n";
1159
1160     /**
1161      * A more complicated message-formatting example.  Here, in addition to
1162      * handling the singular and plural versions of the word, the value is
1163      * denominated in bytes, kilobytes, or megabytes depending on its magnitude.
1164      * Also notice that it correctly treats a kilobyte as 1,024 bytes (not 1,000),
1165      * and a megabyte as 1,024 kilobytes (not 1,000).
1166      */
1167     public static final String message2 =
1168         // this rule supplies the shell of the sentence
1169         "x.0: There << free space on the disk.;\n"
1170         // handle singular and plural forms of "byte" (and format 0 as
1171         // "There is no free space...")
1172         + "0: is no;\n"
1173         + "is one byte of;\n"
1174         + "are =0= bytes of;\n"
1175         // for values above 1,024, format the number in K (since "K" is usually
1176         // promounced "K" regardless of whether it's singular or plural, we
1177         // don't worry about the plural form).  The "/1024" here causes us to
1178         // treat a K as 1,024 bytes rather than 1,000 bytes.
1179         + "1024/1024: is <0<K of;\n"
1180         // for values about 1,048,576, format the number in Mb.  Since "Mb" is
1181         // usually promounced "meg" in singular and "megs" in plural, we do have
1182         // both singular and plural forms.  Again, notice we treat a megabyte
1183         // as 1,024 kilobytes.
1184         + "1,048,576/1024: is 1 Mb of;\n"
1185         + "2,097,152/1024: are <0< Mb of;";
1186
1187     //========================================================================
1188     // Alternate radices
1189     //========================================================================
1190
1191     /**
1192      * This example formats a number in dozens and gross.  This is intended to
1193      * demonstrate how this rule set can be used to format numbers in systems
1194      * other than base 10.  The "/12" after the rules' base values controls this.
1195      * Also notice that the base doesn't have to be consistent throughout the
1196      * whole rule set: we go back to base 10 for values over 1,000.
1197      */
1198     public static final String dozens =
1199         // words for numbers...
1200         "zero; one; two; three; four; five; six;\n"
1201         + "seven; eight; nine; ten; eleven;\n"
1202         // format values over 12 in dozens
1203         + "12/12: << dozen[ and >>];\n"
1204         // format values over 144 in gross
1205         + "144/12: << gross[, >>];\n"
1206         // format values over 1,000 in thousands
1207         + "1000: << thousand[, >>];\n"
1208         // overflow rule.  Format values over 10,000 in numerals
1209         + "10,000: =#,##0=;\n";
1210
1211     //========================================================================
1212     // Major and minor units
1213     //
1214     // These examples show how a single value can be divided up into major
1215     // and minor units that don't relate to each other by a factor of 10.
1216     //========================================================================
1217
1218     /**
1219      * This example formats a number of seconds in sexagesimal notation
1220      * (i.e., hours, minutes, and seconds).  %with-words formats it with
1221      * words (3740 is "1 hour, 2 minutes, 20 seconds") and %in-numerals
1222      * formats it entirely in numerals (3740 is "1:02:20").
1223      */
1224     public static final String durationInSeconds =
1225         // main rule set for formatting with words
1226         "%with-words:\n"
1227                // take care of singular and plural forms of "second"
1228         + "    0 seconds; 1 second; =0= seconds;\n"
1229                // use %%min to format values greater than 60 seconds
1230         + "    60/60: <%%min<[, >>];\n"
1231                // use %%hr to format values greater than 3,600 seconds
1232                // (the ">>>" below causes us to see the number of minutes
1233                // when when there are zero minutes)
1234         + "    3600/60: <%%hr<[, >>>];\n"
1235         // this rule set takes care of the singular and plural forms
1236         // of "minute"
1237         + "%%min:\n"
1238         + "    0 minutes; 1 minute; =0= minutes;\n"
1239         // this rule set takes care of the singular and plural forms
1240         // of "hour"
1241         + "%%hr:\n"
1242         + "    0 hours; 1 hour; =0= hours;\n"
1243
1244         // main rule set for formatting in numerals
1245         + "%in-numerals:\n"
1246                // values below 60 seconds are shown with "sec."
1247         + "    =0= sec.;\n"
1248                // higher values are shown with colons: %%min-sec is used for
1249                // values below 3,600 seconds...
1250         + "    60: =%%min-sec=;\n"
1251                // ...and %%hr-min-sec is used for values of 3,600 seconds
1252                // and above
1253         + "    3600: =%%hr-min-sec=;\n"
1254         // this rule causes values of less than 10 minutes to show without
1255         // a leading zero
1256         + "%%min-sec:\n"
1257         + "    0: :=00=;\n"
1258         + "    60/60: <0<>>;\n"
1259         // this rule set is used for values of 3,600 or more.  Minutes are always
1260         // shown, and always shown with two digits
1261         + "%%hr-min-sec:\n"
1262         + "    0: :=00=;\n"
1263         + "    60/60: <00<>>;\n"
1264         + "    3600/60: <#,##0<:>>>;\n"
1265         // the lenient-parse rules allow several different characters to be used
1266         // as delimiters between hours, minutes, and seconds
1267         + "%%lenient-parse:\n"
1268         + "    & : = . = ' ' = -;\n";
1269
1270     /**
1271      * This example formats a number of hours in sexagesimal notation (i.e.,
1272      * hours, minutes, and seconds).  %with-words formats the value using
1273      * words for the units, and %in-numerals formats the value using only
1274      * numerals.
1275      */
1276     public static final String durationInHours =
1277         // main entry point for formatting with words
1278         "%with-words:\n"
1279                // this rule omits minutes and seconds when the value is
1280                // an even number of hours
1281         + "    x.0: <<[, >%%min-sec>];\n"
1282                // these rules take care of the singular and plural forms
1283                // of hours
1284         + "    0 hours; 1 hour; =#,##0= hours;\n"
1285         // this rule set takes the fractional part of the number and multiplies
1286         // it by 3,600 (turning it into a number of seconds).  Then it delegates
1287         // to %%min-sec-implementation to format the resulting value
1288         + "%%min-sec:\n"
1289         + "    3600: =%%min-sec-implementation=;\n"
1290         // this rule set formats the seconds as either seconds or minutes and
1291         // seconds, and takes care of the singular and plural forms of
1292         // "minute" and "second"
1293         + "%%min-sec-implementation:\n"
1294         + "    0 seconds; 1 second; =0= seconds;\n"
1295         + "    60/60: 1 minute[, >>];\n"
1296         + "    120/60: <0< minutes[, >>];\n"
1297
1298         // main entry point for formatting in numerals
1299         + "%in-numerals:\n"
1300                // show minutes even for even numbers of hours
1301         + "    x.0: <#,##0<:00;\n"
1302                // delegate to %%min-sec2 to format minutes and seconds
1303         + "    x.x: <#,##0<:>%%min-sec2>;\n"
1304         // this rule set formats minutes when there is an even number of
1305         // minutes, and delegates to %%min-sec2-implementation when there
1306         // are seconds
1307         + "%%min-sec2:\n"
1308         + "    60: <00<;\n"
1309         + "    3600: <%%min-sec2-implementation<;\n"
1310         // these two rule sets are used to format the minutes and seconds
1311         + "%%min-sec2-implementation:\n"
1312                // if there are fewer than 60 seconds, show the minutes anyway
1313         + "    0: 00:=00=;\n"
1314                // if there are minutes, format them too, and always use 2 digits
1315                // for both minutes and seconds
1316         + "    60: =%%min-sec3=;\n"
1317         + "%%min-sec3:\n"
1318         + "    0: :=00=;\n"
1319         + "    60/60: <00<>>;\n"
1320         // the lenient-parse rules allow the user to use any of several
1321         // characters as delimiters between hours, minutes, and seconds
1322         + "%%lenient-parse:\n"
1323         + "    & : = . = ' ' = -;\n";
1324
1325     /**
1326      * This rule set formats a number of pounds as pounds, shillings, and
1327      * pence in the old English system of currency.
1328      */
1329     public static final String poundsShillingsAndPence =
1330         // for values of 1 or more, format the integral part with a pound
1331         // sign in front, and show shillings and pence if necessary
1332         "%main:\n"
1333         + "    x.0: \u00a3<#,##0<[ >%%shillings-and-pence>];\n"
1334         // for values between 0 and 1, omit the number of pounds
1335         + "    0.x: >%%pence-alone>;\n"
1336         // this rule set is used to show shillings and pence.  It multiplies
1337         // the fractional part of the number by 240 (the number of pence in a
1338         // pound) and uses %%shillings-and-pence-implementation to format
1339         // the result
1340         + "%%shillings-and-pence:\n"
1341         + "    240: <%%shillings-and-pence-implementation<;\n"
1342         // this rule set is used to show shillings and pence when there are
1343         // no pounds.  It also multiplies the value by 240, and then it uses
1344         // %%pence-alone-implementation to format the result.
1345         + "%%pence-alone:\n"
1346         + "    240: <%%pence-alone-implementation<;\n"
1347         // this rule set formats a number of pence when we know we also
1348         // have pounds.  We always show shillings (with a 0 if necessary),
1349         // but only show pence if the value isn't an even number of shillings
1350         + "%%shillings-and-pence-implementation:\n"
1351         + "    0/; 0/=0=;\n"
1352         + "    12/12: <0</[>0>];\n"
1353         // this rule set formats a number of pence when we know there are
1354         // no pounds.  Values less than a shilling are shown with "d." (the
1355         // abbreviation for pence), and values greater than a shilling are
1356         // shown with a shilling bar (and without pence when the value is
1357         // an even number of shillings)
1358         + "%%pence-alone-implementation:\n"
1359         + "    =0= d.;\n"
1360         + "    12/12: <0</[>0>];\n";
1361
1362     //========================================================================
1363     // Alternate numeration systems
1364     //
1365     // These examples show how RuleBasedNumberFormat can be used to format
1366     // numbers using non-positional numeration systems.
1367     //========================================================================
1368
1369     /**
1370      * Arabic digits.  This example formats numbers in Arabic numerals.
1371      * Normally, you'd do this with DecimalFormat, but this shows that
1372      * RuleBasedNumberFormat can handle it too.
1373      */
1374     public static final String arabicNumerals =
1375         "0; 1; 2; 3; 4; 5; 6; 7; 8; 9;\n"
1376         + "10: <<>>;\n"
1377         + "100: <<>>>;\n"
1378         + "1000: <<,>>>;\n"
1379         + "1,000,000: <<,>>>;\n"
1380         + "1,000,000,000: <<,>>>;\n"
1381         + "1,000,000,000,000: <<,>>>;\n"
1382         + "1,000,000,000,000,000: =#,##0=;\n"
1383         + "-x: ->>;\n"
1384         + "x.x: <<.>>;";
1385
1386     /**
1387      * Words for digits.  Follows the same pattern as the Arabic-numerals
1388      * example above, but uses words for the various digits (e.g., 123 comes
1389      * out as "one two three").
1390      */
1391     public static final String wordsForDigits =
1392         "-x: minus >>;\n"
1393         + "x.x: << point >>;\n"
1394         + "zero; one; two; three; four; five; six;\n"
1395         + "    seven; eight; nine;\n"
1396         + "10: << >>;\n"
1397         + "100: << >>>;\n"
1398         + "1000: <<, >>>;\n"
1399         + "1,000,000: <<, >>>;\n"
1400         + "1,000,000,000: <<, >>>;\n"
1401         + "1,000,000,000,000: <<, >>>;\n"
1402         + "1,000,000,000,000,000: =#,##0=;\n";
1403
1404     /**
1405      * This example formats numbers using Chinese characters in the Arabic
1406      * place-value method.  This was used historically in China for a while.
1407      */
1408     public static final String chinesePlaceValue =
1409         "\u3007; \u4e00; \u4e8c; \u4e09; \u56db; \u4e94; \u516d; \u4e03; \u516b; \u4e5d;\n"
1410         + "10: <<>>;\n"
1411         + "100: <<>>>;\n"
1412         + "1000: <<>>>;\n"
1413         + "1,000,000: <<>>>;\n"
1414         + "1,000,000,000: <<>>>;\n"
1415         + "1,000,000,000,000: <<>>>;\n"
1416         + "1,000,000,000,000,000: =#,##0=;\n";
1417
1418     /**
1419      * Roman numerals.  This example has two variants: %modern shows how large
1420      * numbers are usually handled today; %historical ses the older symbols for
1421      * thousands.
1422      */
1423     public static final String romanNumerals =
1424         "%historical:\n"
1425         + "    =%modern=;\n"
1426                // in early Roman numerals, 1,000 was shown with a circle
1427                // bisected by a vertical line.  Additional thousands were
1428                // shown by adding more concentric circles, and fives were
1429                // shown by cutting the symbol for next-higher power of 10
1430                // in half (the letter D for 500 evolved from this).
1431                // We could go beyond 40,000, but Unicode doesn't encode
1432                // the symbols for higher numbers/
1433         + "    1000: \u2180[>>]; 2000: \u2180\u2180[>>]; 3000: \u2180\u2180\u2180[>>]; 4000: \u2180\u2181[>>];\n"
1434         + "    5000: \u2181[>>]; 6000: \u2181\u2180[>>]; 7000: \u2181\u2180\u2180[>>];\n"
1435         + "    8000: \u2181\u2180\u2180\u2180[>>]; 9000: \u2180\u2182[>>];\n"
1436         + "    10,000: \u2182[>>]; 20,000: \u2182\u2182[>>]; 30,000: \u2182\u2182\u2182[>>];\n"
1437         + "    40,000: =#,##0=;\n"
1438         + "%modern:\n"
1439         + "    ; I; II; III; IV; V; VI; VII; VIII; IX;\n"
1440         + "    10: X[>>]; 20: XX[>>]; 30: XXX[>>]; 40: XL[>>]; 50: L[>>];\n"
1441         + "    60: LX[>>]; 70: LXX[>>]; 80: LXXX[>>]; 90: XC[>>];\n"
1442         + "    100: C[>>]; 200: CC[>>]; 300: CCC[>>]; 400: CD[>>]; 500: D[>>];\n"
1443         + "    600: DC[>>]; 700: DCC[>>]; 800: DCCC[>>]; 900: CM[>>];\n"
1444                // in modern Roman numerals, high numbers are generally shown
1445                // by placing a bar over the letters for the lower numbers:
1446                // the bar multiplied a letter's value by 1,000
1447         + "    1000: M[>>]; 2000: MM[>>]; 3000: MMM[>>]; 4000: MV\u0306[>>];\n"
1448         + "    5000: V\u0306[>>]; 6000: V\u0306M[>>]; 7000: V\u0306MM[>>];\n"
1449         + "    8000: V\u0306MMM[>>]; 9000: MX\u0306[>>];\n"
1450         + "    10,000: X\u0306[>>]; 20,000: X\u0306X\u0306[>>]; 30,000: X\u0306X\u0306X\u0306[>>];\n"
1451         + "    40,000: X\u0306L\u0306[>>]; 50,000: L\u0306[>>]; 60,000: L\u0306X\u0306[>>];\n"
1452         + "    70,000: L\u0306X\u0306X\u0306[>>]; 80,000: L\u0306X\u0306X\u0306X\u0306[>>];\n"
1453         + "    90,000: X\u0306C\u0306[>>];\n"
1454         + "    100,000: C\u0306[>>]; 200,000: C\u0306C\u0306[>>]; 300,000: C\u0306C\u0306[>>];\n"
1455         + "    400,000: C\u0306D\u0306[>>]; 500,000: D\u0306[>>]; 600,000: D\u0306C\u0306[>>];\n"
1456         + "    700,000: D\u0306C\u0306C\u0306[>>]; 800,000: D\u0306C\u0306C\u0306C\u0306[>>];\n"
1457         + "    900,000: =#,##0=;\n";
1458
1459     /**
1460      * Hebrew alphabetic numerals.  Before adoption of Arabic numerals, Hebrew speakers
1461      * used the letter of their alphabet as numerals.  The first nine letters of
1462      * the alphabet repesented the values from 1 to 9, the second nine letters the
1463      * multiples of 10, and the remaining letters the multiples of 100.  Since they
1464      * ran out of letters at 400, the remaining multiples of 100 were represented
1465      * using combinations of the existing letters for the hundreds.  Numbers were
1466      * distinguished from words in a number of different ways: the way shown here
1467      * uses a single mark after a number consisting of one letter, and a double
1468      * mark between the last two letters of a number consisting of two or more
1469      * letters.  Two dots over a letter multiplied its value by 1,000.  Also, since
1470      * the letter for 10 is the first letter of God's name and the letters for 5 and 6
1471      * are letters in God's name, which wasn't supposed to be written or spoken, 15 and
1472      * 16 were usually written as 9 + 6 and 9 + 7 instead of 10 + 5 and 10 + 6.
1473      */
1474     public static final String hebrewAlphabetic =
1475         // letters for the ones
1476         "%%ones:\n"
1477         + "    (no zero); \u05d0; \u05d1; \u05d2; \u05d3; \u05d4; \u05d5; \u05d6; \u05d7; \u05d8;\n"
1478         // letters for the tens
1479         + "%%tens:\n"
1480         + "    ; \u05d9; \u05db; \u05dc; \u05de; \u05e0; \u05e1; \u05e2; \u05e4; \u05e6;\n"
1481         // letters for the first four hundreds
1482         + "%%hundreds:\n"
1483         + "    ; \u05e7; \u05e8; \u05e9; \u05ea;\n"
1484         // this rule set is used to write the combination of the tens and ones digits
1485         // when we know that no other digits precede them: they put the numeral marks
1486         // in the right place and properly handle 15 and 16 (I'm using the mathematical
1487         // prime characters for the numeral marks because my Unicode font doesn't
1488         // include the real Hebrew characters, which look just like the prime marks)
1489         + "%%tens-and-ones:\n"
1490                // for values less than 10, just use %%ones and put the numeral mark
1491                // afterward
1492         + "    =%%ones=\u2032;\n"
1493                // put the numeral mark at the end for 10, but in the middle for
1494                // 11 through 14
1495         + "    10: <%%tens<\u2032; <%%tens<\u2033>%%ones>;\n"
1496                // special-case 15 and 16
1497         + "    15: \u05d8\u2033\u05d5; 16: \u05d8\u2033\u05d6;\n"
1498                // go back to the normal method at 17
1499         + "    17: <%%tens<\u2033>%%ones>;\n"
1500                // repeat the rules for 10 and 11 to cover the values from 20 to 99
1501         + "    20: <%%tens<\u2032; <%%tens<\u2033>%%ones>;\n"
1502         // this rule set is used to format numbers below 1,000.  It relies on
1503         // %%tens-and-ones to format the tens and ones places, and adds logic
1504         // to handle the high hundreds and the numeral marks when there is no
1505         // tens digit.  Notice how the rules are paired: all of these pairs of
1506         // rules take advantage of the rollback rule: if the value (between 100
1507         // and 499) is an even multiple of 100, the rule for 100 is used; otherwise,
1508         // the rule for 101 (the following rule) is used.  The first rule in each
1509         // pair (the one for the even multiple) places the numeral mark in a different
1510         // spot than the second rule in each pair (which knows there are more digits
1511         // and relies on the rule supplying them to also supply the numeral mark).
1512         // The call to %%null in line 10 is there simply to invoke the rollback
1513         // rule.
1514         + "%%low-order:\n"
1515                // this rule is only called when there are other characters before.
1516                // It places the numeral mark before the last digit
1517         + "    \u2033=%%ones=;\n"
1518                // the rule for 10 places the numeral mark before the 10 character
1519                // (because we know it's the last character); the rule for 11 relies
1520                // on %%tens-and-ones to place the numeral mark
1521         + "    10: \u2033<%%tens<; =%%tens-and-ones=>%%null>;\n"
1522                // the rule for 100 places the numeral mark before the 100 character
1523                // (we know it's the last character); the rule for 101 recurses to
1524                // fill in the remaining digits and the numeral mark
1525         + "    100: <%%hundreds<\u2032; <%%hundreds<>>;\n"
1526                // special-case the hundreds from 500 to 900 because they consist of
1527                // more than one character
1528         + "    500: \u05ea\u2033\u05e7; \u05ea\u05e7>>;\n"
1529         + "    600: \u05ea\u2033\u05e8; \u05ea\u05e8>>;\n"
1530         + "    700: \u05ea\u2033\u05e9; \u05ea\u05e9>>;\n"
1531         + "    800: \u05ea\u2033\u05ea; \u05ea\u05ea>>;\n"
1532         + "    900: \u05ea\u05ea\u2033\u05e7; \u05ea\u05ea\u05e7>>;\n"
1533         // this rule set is used to format values of 1,000 or more.  Here, we don't
1534         // worry about the numeral mark, and we add two dots (the Unicode combining
1535         // diaeresis character) to ever letter
1536         + "%%high-order:\n"
1537                // put the ones digit, followed by the diaeresis
1538         + "    =%%ones=\u0308;\n"
1539                // the tens can be handled with recursion
1540         + "    10: <%%tens<\u0308[>>];\n"
1541                // still have to special-case 15 and 16
1542         + "    15: \u05d8\u0308\u05d5\u0308; 16: \u05d8\u003078\u05d6\u0308;\n"
1543                // back to the regular rules at 17
1544         + "    17: <%%tens<\u0308[>>];\n"
1545                // the hundreds with the dots added (and without worrying about
1546                // placing the numeral mark)
1547         + "    100: <%%hundreds<\u0308[>>];\n"
1548         + "    500: \u05ea\u0308\u05e7\u0308[>>];\n"
1549         + "    600: \u05ea\u0308\u05e8\u0308[>>];\n"
1550         + "    700: \u05ea\u0308\u05e9\u0308[>>];\n"
1551         + "    800: \u05ea\u0308\u05ea\u0308[>>];\n"
1552         + "    900: \u05ea\u0308\u05ea\u0308\u05e7\u0308[>>];\n"
1553         // this rule set doesn't do anything; it's used by some other rules to
1554         // invoke the rollback rule
1555         + " %%null:\n"
1556         + "    ;\n"
1557         // the main rule set.
1558         + "%main:\n"
1559                // for values below 10, just output the letter and the numeral mark
1560         + "    =%%ones=\u2032;\n"
1561                // for values from 10 to 99, use %%tens-and-ones to do the formatting
1562         + "    10: =%%tens-and-ones=;\n"
1563                // for values from 100 to 999, use %%low-order to do the formatting
1564         + "    100: =%%low-order=;\n"
1565                // for values of 1,000 and over, use %%high-order to do the formatting
1566         + "    1000: <%%high-order<[>%%low-order>];\n";
1567
1568     /**
1569      * Greek alphabetic numerals.  The Greeks, before adopting the Arabic numerals,
1570      * also used the letters of their alphabet as numerals.  There are three now-
1571      * obsolete Greek letters that are used as numerals; many fonts don't have them.
1572      * Large numbers were handled many different ways; the way shown here divides
1573      * large numbers into groups of four letters (factors of 10,000), and separates
1574      * the groups with the capital letter mu (for myriad).  Capital letters are used
1575      * for values below 10,000; small letters for higher numbers (to make the capital
1576      * mu stand out).
1577      */
1578     public static final String greekAlphabetic =
1579         // this rule set is used for formatting numbers below 10,000.  It uses
1580         // capital letters.
1581         "%%low-order:\n"
1582         + "    (no zero); \u0391; \u0392; \u0393; \u0394; \u0395; \u03dc; \u0396; \u0397; \u0398;\n"
1583         + "    10: \u0399[>>]; 20: \u039a[>>]; 30: \u039b[>>]; 40: \u039c[>>]; 50: \u039d[>>];\n"
1584         + "    60: \u039e[>>]; 70: \u039f[>>]; 80: \u03a0[>>]; 90: \u03de[>>];\n"
1585         + "    100: \u03a1[>>]; 200: \u03a3[>>]; 300: \u03a4[>>]; 400: \u03a5[>>];\n"
1586         + "    500: \u03a6[>>]; 600: \u03a7[>>]; 700: \u03a8[>>]; 800: \u03a9[>>];\n"
1587         + "    900: \u03e0[>>];\n"
1588                // the thousands are represented by the same numbers as the ones, but
1589                // with a comma-like mark added to their left shoulder
1590         + "    1000: \u0391\u0313[>>]; 2000: \u0392\u0313[>>]; 3000: \u0393\u0313[>>];\n"
1591         + "    4000: \u0394\u0313[>>]; 5000: \u0395\u0313[>>]; 6000: \u03dc\u0313[>>];\n"
1592         + "    7000: \u0396\u0313[>>]; 8000: \u0397\u0313[>>]; 9000: \u0398\u0313[>>];\n"
1593         // this rule set is the same as above, but uses lowercase letters.  It is used
1594         // for formatting the groups in numbers above 10,000.
1595         + "%%high-order:\n"
1596         + "    (no zero); \u03b1; \u03b2; \u03b3; \u03b4; \u03b5; \u03dc; \u03b6; \u03b7; \u03b8;\n"
1597         + "    10: \u03b9[>>]; 20: \u03ba[>>]; 30: \u03bb[>>]; 40: \u03bc[>>]; 50: \u03bd[>>];\n"
1598         + "    60: \u03be[>>]; 70: \u03bf[>>]; 80: \u03c0[>>]; 90: \u03de[>>];\n"
1599         + "    100: \u03c1[>>]; 200: \u03c3[>>]; 300: \u03c4[>>]; 400: \u03c5[>>];\n"
1600         + "    500: \u03c6[>>]; 600: \u03c7[>>]; 700: \u03c8[>>]; 800: \u03c9[>>];\n"
1601         + "    900: \u03c0[>>];\n"
1602         + "    1000: \u03b1\u0313[>>]; 2000: \u03b2\u0313[>>]; 3000: \u03b3\u0313[>>];\n"
1603         + "    4000: \u03b4\u0313[>>]; 5000: \u03b5\u0313[>>]; 6000: \u03dc\u0313[>>];\n"
1604         + "    7000: \u03b6\u0313[>>]; 8000: \u03b7\u0313[>>]; 9000: \u03b8\u0313[>>];\n"
1605         // the main rule set
1606         + "%main:\n"
1607                // for values below 10,000, just use %%low-order
1608         + "    =%%low-order=;\n"
1609                // for values above 10,000, split into two groups of four digits
1610                // and format each with %%high-order (putting an M in betwen)
1611         + "    10,000: <%%high-order<\u039c>%%high-order>;\n"
1612                // for values above 100,000,000, add another group onto the front
1613                // and another M
1614         + "    100,000,000: <%%high-order<\u039c>>\n";
1615
1616     /**
1617      * A list of all the sample rule sets, used by the demo program.
1618      */
1619     public static final String[] sampleRuleSets =
1620         { usEnglish,
1621           ukEnglish,
1622           spanish,
1623           french,
1624           swissFrench,
1625           german,
1626           italian,
1627           swedish,
1628           dutch,
1629           japanese,
1630           greek,
1631           russian,
1632           hebrew,
1633           ordinal,
1634           message1,
1635           dollarsAndCents,
1636           decimalAsFraction,
1637           closestFraction,
1638           stock,
1639           abbEnglish,
1640           units,
1641           message2,
1642           dozens,
1643           durationInSeconds,
1644           durationInHours,
1645           poundsShillingsAndPence,
1646           arabicNumerals,
1647           wordsForDigits,
1648           chinesePlaceValue,
1649           romanNumerals,
1650           hebrewAlphabetic,
1651           greekAlphabetic };
1652
1653     /**
1654      * The displayable names for all the sample rule sets, in the same order as
1655      * the preceding array.
1656      */
1657     public static final String[] sampleRuleSetNames =
1658         { "English (US)",
1659           "English (UK)",
1660           "Spanish",
1661           "French (France)",
1662           "French (Switzerland)",
1663           "German",
1664           "Italian",
1665           "Swedish",
1666           "Dutch",
1667           "Japanese",
1668           "Greek",
1669           "Russian",
1670           "Hebrew",
1671           "English ordinal abbreviations",
1672           "Simple message formatting",
1673           "Dollars and cents",
1674           "Decimals as fractions",
1675           "Closest fraction",
1676           "Stock prices",
1677           "Abbreviated US English",
1678           "Changing dimensions",
1679           "Complex message formatting",
1680           "Dozens",
1681           "Duration (value in seconds)",
1682           "Duration (value in hours)",
1683           "Pounds, shillings, and pence",
1684           "Arabic numerals",
1685           "Words for digits",
1686           "Chinese place-value notation",
1687           "Roman numerals",
1688           "Hebrew ahlphabetic numerals",
1689           "Greek alphabetic numerals" };
1690
1691     /**
1692      * The base locale for each of the sample rule sets.  The locale is used to
1693      * determine DecimalFormat behavior, lenient-parse behavior, and text-display
1694      * selection (we have a hack in here to allow display of non-Latin scripts).
1695      * Null means the locale setting is irrelevant and the default can be used.
1696      */
1697     public static final Locale[] sampleRuleSetLocales =
1698         { Locale.US,
1699           Locale.UK,
1700           new Locale("es", "", ""),
1701           Locale.FRANCE,
1702           new Locale("fr", "CH", ""),
1703           Locale.GERMAN,
1704           Locale.ITALIAN,
1705           new Locale("sv", "", ""),
1706           new Locale("nl", "", ""),
1707           Locale.JAPANESE,
1708           new Locale("el", "", ""),
1709           new Locale("ru", "", ""),
1710           new Locale("iw", "", ""),
1711           Locale.ENGLISH,
1712           Locale.ENGLISH,
1713           Locale.US,
1714           Locale.ENGLISH,
1715           null,
1716           null,
1717           Locale.ENGLISH,
1718           null,
1719           Locale.ENGLISH,
1720           Locale.ENGLISH,
1721           null,
1722           null,
1723           Locale.UK,
1724           null,
1725           Locale.ENGLISH,
1726           new Locale("zh", "", ""),
1727           null,
1728           new Locale("iw", "", ""),
1729           new Locale("el", "", ""),
1730           null };
1731
1732         public static final String[] sampleRuleSetCommentary = {
1733             "This demonstration version of the "
1734             + "U.S. English spellout rules has four variants: 1) %simplified is a "
1735             + "set of rules showing the simple method of spelling out numbers in "
1736             + "English: 289 is formatted as \"two hundred eighty-nine\".  2) %alt-teens "
1737             + "is the same as %simplified, except that values between 1,000 and 9,999 "
1738             + "whose hundreds place isn't zero are formatted in hundreds.  For example, "
1739             + "1,983 is formatted as \"nineteen hundred eighty-three,\" and 2,183 is "
1740             + "formatted as \"twenty-one hundred eighty-three,\" but 2,083 is still "
1741             + "formatted as \"two thousand eighty-three.\"  3) %ordinal formats the "
1742             + "values as ordinal numbers in English (e.g., 289 is \"two hundred eighty-"
1743             + "ninth\").  4) %default uses a more complicated algorithm to format "
1744             + "numbers in a more natural way: 289 is formatted as \"two hundred AND "
1745             + "eighty-nine\" and commas are inserted between the thousands groups for "
1746             + "values above 100,000.",
1747
1748             "U.K. English has one significant "
1749             + "difference from U.S. English: the names for values of 1,000,000,000 "
1750             + "and higher.  In American English, each successive \"-illion\" is 1,000 "
1751             + "times greater than the preceding one: 1,000,000,000 is \"one billion\" "
1752             + "and 1,000,000,000,000 is \"one trillion.\"  In British English, each "
1753             + "successive \"-illion\" is one million times greater than the one before: "
1754             + "\"one billion\" is 1,000,000,000,000 (or what Americans would call a "
1755             + "\"trillion\"), and \"one trillion\" is 1,000,000,000,000,000,000.  "
1756             + "1,000,000,000 in British English is \"one thousand million.\"  (This "
1757             + "value is sometimes called a \"milliard,\" but this word seems to have "
1758             + "fallen into disuse.)",
1759
1760             "The Spanish rules are quite similar to "
1761             + "the English rules, but there are some important differences: "
1762             + "First, we have to provide separate rules for most of the twenties "
1763             + "because the ones digit frequently picks up an accent mark that it "
1764             + "doesn't have when standing alone.  Second, each multiple of 100 has "
1765             + "to be specified separately because the multiplier on 100 very often "
1766             + "changes form in the contraction: 500 is \"quinientos,\" not "
1767             + "\"cincocientos.\"  In addition, the word for 100 is \"cien\" when "
1768             + "standing alone, but changes to \"ciento\" when followed by more digits.  "
1769             + "There also some other differences.",
1770
1771             "French adds some interesting quirks of its "
1772             + "own: 1) The word \"et\" is interposed between the tens and ones digits, "
1773             + "but only if the ones digit if 1: 20 is \"vingt,\" and 2 is \"vingt-deux,\" "
1774             + "but 21 is \"vingt-et-un.\"  2)  There are no words for 70, 80, or 90.  "
1775             + "\"quatre-vingts\" (\"four twenties\") is used for 80, and values proceed "
1776             + "by score from 60 to 99 (e.g., 73 is \"soixante-treize\" [\"sixty-thirteen\"]).  "
1777             + "Numbers from 1,100 to 1,199 are rendered as hundreds rather than "
1778             + "thousands: 1,100 is \"onze cents\" (\"eleven hundred\"), rather than "
1779             + "\"mille cent\" (\"one thousand one hundred\")",
1780
1781             "Swiss French differs from French French "
1782             + "in that it does have words for 70, 80, and 90.  This rule set shows them, "
1783             + "and is simpler as a result.",
1784
1785             "German also adds some interesting "
1786             + "characteristics.  For values below 1,000,000, numbers are customarily "
1787             + "written out as a single word.  And the ones digit PRECEDES the tens "
1788             + "digit (e.g., 23 is \"dreiundzwanzig,\" not \"zwanzigunddrei\").",
1789
1790             "Like German, most Italian numbers are "
1791             + "written as single words.  What makes these rules complicated is the rule "
1792             + "that says that when a word ending in a vowel and a word beginning with "
1793             + "a vowel are combined into a compound, the vowel is dropped from the "
1794             + "end of the first word: 180 is \"centottanta,\" not \"centoottanta.\"  "
1795             + "The complexity of this rule set is to produce this behavior.",
1796
1797             "Spellout rules for Swedish.",
1798
1799             "Spellout rules for Dutch.  Notice that in Dutch, as in German,"
1800             + "the ones digit precedes the tens digit.",
1801
1802             "In Japanese, there really isn't any "
1803             + "distinction between a number written out in digits and a number "
1804             + "written out in words: the ideographic characters are both digits "
1805             + "and words.  This rule set provides two variants:  %traditional "
1806             + "uses the traditional CJK numerals (which are also used in China "
1807             + "and Korea).  %financial uses alternate ideographs for many numbers "
1808             + "that are harder to alter than the traditional numerals (one could "
1809             + "fairly easily change a one to "
1810             + "a three just by adding two strokes, for example).  This is also done in "
1811             + "the other countries using Chinese idographs, but different ideographs "
1812             + "are used in those places.",
1813
1814             "Again in Greek we have to supply the words "
1815             + "for the multiples of 100 because they can't be derived algorithmically.  "
1816             + "Also, the tens dgit changes form when followed by a ones digit: an "
1817             + "accent mark disappears from the tens digit and moves to the ones digit.  "
1818             + "Therefore, instead of using the [] notation, we actually have to use "
1819             + "two separate rules for each multiple of 10 to show the two forms of "
1820             + "the word.",
1821
1822             "Spellout rules for Russian.",
1823
1824             "Spellout rules for Hebrew.  Hebrew actually has inflected forms for "
1825             + "most of the lower-order numbers.  The masculine forms are shown "
1826             + "here.",
1827
1828             "This rule set adds an English ordinal abbreviation to the end of a "
1829             + "number.  For example, 2 is formatted as \"2nd\".  Parsing doesn't work with "
1830             + "this rule set.  To parse, use DecimalFormat on the numeral.",
1831
1832             "This is a simple message-formatting example.  Normally one would "
1833             + "use ChoiceFormat and MessageFormat to do something this simple, "
1834             + "but this shows it could be done with RuleBasedNumberFormat too.  "
1835             + "A message-formatting example that might work better with "
1836             + "RuleBasedNumberFormat appears later.",
1837
1838             "The next few examples demonstrate fraction handling.  "
1839             + "This example formats a number in one of the two styles often used "
1840             + "on checks.  %dollars-and-hundredths formats cents as hundredths of "
1841             + "a dollar (23.40 comes out as \"twenty-three and 40/100 dollars\").  "
1842             + "%dollars-and-cents formats in dollars and cents (23.40 comes out as "
1843             + "\"twenty-three dollars and forty cents\")",
1844
1845             "This rule set shows the fractional part of the number as a fraction "
1846             + "with a power of 10 as the denominator.  Some languages don't spell "
1847             + "out the fractional part of a number as \"point one two three,\" but "
1848             + "always render it as a fraction.  If we still want to treat the fractional "
1849             + "part of the number as a decimal, then the fraction's denominator "
1850             + "is always a power of 10.  This example does that: 23.125 is formatted "
1851             + "as \"twenty-three and one hundred twenty-five thousandths\" (as opposed "
1852             + "to \"twenty-three point one two five\" or \"twenty-three and one eighth\").",
1853
1854             "Number with closest fraction.  This example formats a value using "
1855             + "numerals, but shows the fractional part as a ratio (fraction) rather "
1856             + "than a decimal.  The fraction always has a denominator between 2 and 10.",
1857
1858             "American stock-price formatting.  Non-integral stock prices are still "
1859             + "generally shown in eighths or sixteenths of dollars instead of dollars "
1860             + "and cents.  This example formats stock prices in this way if possible, "
1861             + "and in dollars and cents if not.",
1862
1863             "The next few examples demonstrate using a RuleBasedNumberFormat to "
1864             + "change the units a value is denominated in depending on its magnitude.  "
1865             + "The example shows large numbers the way they often appear is nwespapers: "
1866             + "1,200,000 is formatted as \"1.2 million\".",
1867
1868             "This example takes a number of meters and formats it in whatever unit "
1869             + "will produce a number with from one to three digits before the decimal "
1870             + "point.  For example, 230,000 is formatted as \"230 km\".",
1871
1872             "A more complicated message-formatting example.  Here, in addition to "
1873             + "handling the singular and plural versions of the word, the value is "
1874             + "denominated in bytes, kilobytes, or megabytes depending on its magnitude.  "
1875             + "Also notice that it correctly treats a kilobyte as 1,024 bytes (not 1,000), "
1876             + "and a megabyte as 1,024 kilobytes (not 1,000).",
1877
1878             "This example formats a number in dozens and gross.  This is intended to "
1879             + "demonstrate how this rule set can be used to format numbers in systems "
1880             + "other than base 10.  The \"/12\" after the rules' base values controls this.  "
1881             + "Also notice that the base doesn't have to be consistent throughout the "
1882             + "whole rule set: we go back to base 10 for values over 1,000.",
1883
1884             "The next few examples show how a single value can be divided up into major "
1885             + "and minor units that don't relate to each other by a factor of 10.  "
1886             + "This example formats a number of seconds in sexagesimal notation "
1887             + "(i.e., hours, minutes, and seconds).  %with-words formats it with "
1888             + "words (3740 is \"1 hour, 2 minutes, 20 seconds\") and %in-numerals "
1889             + "formats it entirely in numerals (3740 is \"1:02:20\").",
1890
1891             "This example formats a number of hours in sexagesimal notation (i.e., "
1892             + "hours, minutes, and seconds).  %with-words formats the value using "
1893             + "words for the units, and %in-numerals formats the value using only "
1894             + "numerals.",
1895
1896             "This rule set formats a number of pounds as pounds, shillings, and "
1897             + "pence in the old English system of currency.",
1898
1899             "These examples show how RuleBasedNumberFormat can be used to format "
1900             + "numbers using non-positional numeration systems.  "
1901             + "This example formats numbers in Arabic numerals.  "
1902             + "Normally, you'd do this with DecimalFormat, but this shows that "
1903             + "RuleBasedNumberFormat can handle it too.",
1904
1905             "This example follows the same pattern as the Arabic-numerals "
1906             + "example, but uses words for the various digits (e.g., 123 comes "
1907             + "out as \"one two three\").",
1908
1909             "This example formats numbers using Chinese characters in the Arabic "
1910             + "place-value method.  This was used historically in China for a while.",
1911
1912             "Roman numerals.  This example has two variants: %modern shows how large "
1913             + "numbers are usually handled today; %historical ses the older symbols for "
1914             + "thousands.  Not all of the characters are displayable with most fonts.",
1915
1916             "Hebrew alphabetic numerals.  Before adoption of Arabic numerals, Hebrew speakers "
1917             + "used the letter of their alphabet as numerals.  The first nine letters of "
1918             + "the alphabet repesented the values from 1 to 9, the second nine letters the "
1919             + "multiples of 10, and the remaining letters the multiples of 100.  Since they "
1920             + "ran out of letters at 400, the remaining multiples of 100 were represented "
1921             + "using combinations of the existing letters for the hundreds.  Numbers were "
1922             + "distinguished from words in a number of different ways: the way shown here "
1923             + "uses a single mark after a number consisting of one letter, and a double "
1924             + "mark between the last two letters of a number consisting of two or more "
1925             + "letters.  Two dots over a letter multiplied its value by 1,000.  Also, since "
1926             + "the letter for 10 is the first letter of God's name and the letters for 5 and 6 "
1927             + "are letters in God's name, which wasn't supposed to be written or spoken, 15 and "
1928             + "16 were usually written as 9 + 6 and 9 + 7 instead of 10 + 5 and 10 + 6.",
1929
1930             "Greek alphabetic numerals.  The Greeks, before adopting the Arabic numerals, "
1931             + "also used the letters of their alphabet as numerals.  There are three now-"
1932             + "obsolete Greek letters that are used as numerals; many fonts don't have them.  "
1933             + "Large numbers were handled many different ways; the way shown here divides "
1934             + "large numbers into groups of four letters (factors of 10,000), and separates "
1935             + "the groups with the capital letter mu (for myriad).  Capital letters are used "
1936             + "for values below 10,000; small letters for higher numbers (to make the capital "
1937             + "mu stand out).",
1938
1939             "This is a custom (user-defined) rule set."
1940         };
1941 }