1f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)/*
2f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)*******************************************************************************
3f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)* Copyright (C) 1997-2010, International Business Machines Corporation and others.
4f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)* All Rights Reserved.
5f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)*******************************************************************************
6f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)*/
7f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
8f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#ifndef RBNF_H
9f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#define RBNF_H
10f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
11f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#include "unicode/utypes.h"
12f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
13f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)/**
14f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * \file
15f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * \brief C++ API: Rule Based Number Format
16f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */
17f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
18f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)/**
19f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * \def U_HAVE_RBNF
20f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * This will be 0 if RBNF support is not included in ICU
21f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * and 1 if it is.
22f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
23f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @stable ICU 2.4
24f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */
25f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#if UCONFIG_NO_FORMATTING
26f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#define U_HAVE_RBNF 0
27f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#else
28f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#define U_HAVE_RBNF 1
29f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
30f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#include "unicode/coll.h"
31f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#include "unicode/dcfmtsym.h"
32f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#include "unicode/fmtable.h"
33f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#include "unicode/locid.h"
34f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#include "unicode/numfmt.h"
35f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#include "unicode/unistr.h"
36f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#include "unicode/strenum.h"
37f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
38f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)U_NAMESPACE_BEGIN
39f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
40f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)class NFRuleSet;
41f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)class LocalizationInfo;
42f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
43f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)/**
44f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Tags for the predefined rulesets.
45f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
46f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @stable ICU 2.2
47f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */
48f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)enum URBNFRuleSetTag {
49f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    URBNF_SPELLOUT,
50f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    URBNF_ORDINAL,
51f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    URBNF_DURATION,
52f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    URBNF_NUMBERING_SYSTEM,
53f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    URBNF_COUNT
54f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)};
55f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
56f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#if UCONFIG_NO_COLLATION
57f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)class Collator;
58f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#endif
59f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
60f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)/**
61f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * The RuleBasedNumberFormat class formats numbers according to a set of rules. This number formatter is
62f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * typically used for spelling out numeric values in words (e.g., 25,3476 as
63f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * "twenty-five thousand three hundred seventy-six" or "vingt-cinq mille trois
64f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * cents soixante-seize" or
65f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * "fünfundzwanzigtausenddreihundertsechsundsiebzig"), but can also be used for
66f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * other complicated formatting tasks, such as formatting a number of seconds as hours,
67f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * minutes and seconds (e.g., 3,730 as "1:02:10").
68f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
69f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>The resources contain three predefined formatters for each locale: spellout, which
70f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * spells out a value in words (123 is &quot;one hundred twenty-three&quot;); ordinal, which
71f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * appends an ordinal suffix to the end of a numeral (123 is &quot;123rd&quot;); and
72f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * duration, which shows a duration in seconds as hours, minutes, and seconds (123 is
73f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * &quot;2:03&quot;).&nbsp; The client can also define more specialized <tt>RuleBasedNumberFormat</tt>s
74f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * by supplying programmer-defined rule sets.</p>
75f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
76f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>The behavior of a <tt>RuleBasedNumberFormat</tt> is specified by a textual description
77f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * that is either passed to the constructor as a <tt>String</tt> or loaded from a resource
78f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * bundle. In its simplest form, the description consists of a semicolon-delimited list of <em>rules.</em>
79f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Each rule has a string of output text and a value or range of values it is applicable to.
80f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * In a typical spellout rule set, the first twenty rules are the words for the numbers from
81f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 0 to 19:</p>
82f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
83f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <pre>zero; one; two; three; four; five; six; seven; eight; nine;
84f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * ten; eleven; twelve; thirteen; fourteen; fifteen; sixteen; seventeen; eighteen; nineteen;</pre>
85f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
86f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>For larger numbers, we can use the preceding set of rules to format the ones place, and
87f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * we only have to supply the words for the multiples of 10:</p>
88f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
89f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <pre> 20: twenty[-&gt;&gt;];
90f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 30: thirty[-&gt;&gt;];
91f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 40: forty[-&gt;&gt;];
92f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 50: fifty[-&gt;&gt;];
93f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 60: sixty[-&gt;&gt;];
94f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 70: seventy[-&gt;&gt;];
95f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 80: eighty[-&gt;&gt;];
96f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 90: ninety[-&gt;&gt;];</pre>
97f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
98f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>In these rules, the <em>base value</em> is spelled out explicitly and set off from the
99f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * rule's output text with a colon. The rules are in a sorted list, and a rule is applicable
100f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * to all numbers from its own base value to one less than the next rule's base value. The
101f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * &quot;&gt;&gt;&quot; token is called a <em>substitution</em> and tells the fomatter to
102f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * isolate the number's ones digit, format it using this same set of rules, and place the
103f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * result at the position of the &quot;&gt;&gt;&quot; token. Text in brackets is omitted if
104f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * the number being formatted is an even multiple of 10 (the hyphen is a literal hyphen; 24
105f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * is &quot;twenty-four,&quot; not &quot;twenty four&quot;).</p>
106f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
107f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>For even larger numbers, we can actually look up several parts of the number in the
108f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * list:</p>
109f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
110f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <pre>100: &lt;&lt; hundred[ &gt;&gt;];</pre>
111f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
112f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>The &quot;&lt;&lt;&quot; represents a new kind of substitution. The &lt;&lt; isolates
113f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * the hundreds digit (and any digits to its left), formats it using this same rule set, and
114f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * places the result where the &quot;&lt;&lt;&quot; was. Notice also that the meaning of
115f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * &gt;&gt; has changed: it now refers to both the tens and the ones digits. The meaning of
116f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * both substitutions depends on the rule's base value. The base value determines the rule's <em>divisor,</em>
117f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * which is the highest power of 10 that is less than or equal to the base value (the user
118f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * can change this). To fill in the substitutions, the formatter divides the number being
119f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * formatted by the divisor. The integral quotient is used to fill in the &lt;&lt;
120f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * substitution, and the remainder is used to fill in the &gt;&gt; substitution. The meaning
121f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * of the brackets changes similarly: text in brackets is omitted if the value being
122f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * formatted is an even multiple of the rule's divisor. The rules are applied recursively, so
123f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * if a substitution is filled in with text that includes another substitution, that
124f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * substitution is also filled in.</p>
125f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
126f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>This rule covers values up to 999, at which point we add another rule:</p>
127f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
128f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <pre>1000: &lt;&lt; thousand[ &gt;&gt;];</pre>
129f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
130f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>Again, the meanings of the brackets and substitution tokens shift because the rule's
131f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * base value is a higher power of 10, changing the rule's divisor. This rule can actually be
132f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * used all the way up to 999,999. This allows us to finish out the rules as follows:</p>
133f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
134f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <pre> 1,000,000: &lt;&lt; million[ &gt;&gt;];
135f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 1,000,000,000: &lt;&lt; billion[ &gt;&gt;];
136f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 1,000,000,000,000: &lt;&lt; trillion[ &gt;&gt;];
137f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 1,000,000,000,000,000: OUT OF RANGE!;</pre>
138f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
139f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>Commas, periods, and spaces can be used in the base values to improve legibility and
140f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * are ignored by the rule parser. The last rule in the list is customarily treated as an
141f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * &quot;overflow rule,&quot; applying to everything from its base value on up, and often (as
142f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * in this example) being used to print out an error message or default representation.
143f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Notice also that the size of the major groupings in large numbers is controlled by the
144f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * spacing of the rules: because in English we group numbers by thousand, the higher rules
145f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * are separated from each other by a factor of 1,000.</p>
146f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
147f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>To see how these rules actually work in practice, consider the following example:
148f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Formatting 25,430 with this rule set would work like this:</p>
149f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
150f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <table border="0" width="100%">
151f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
152f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td><strong>&lt;&lt; thousand &gt;&gt;</strong></td>
153f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>[the rule whose base value is 1,000 is applicable to 25,340]</td>
154f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
155f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
156f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td><strong>twenty-&gt;&gt;</strong> thousand &gt;&gt;</td>
157f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>[25,340 over 1,000 is 25. The rule for 20 applies.]</td>
158f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
159f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
160f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>twenty-<strong>five</strong> thousand &gt;&gt;</td>
161f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>[25 mod 10 is 5. The rule for 5 is &quot;five.&quot;</td>
162f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
163f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
164f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>twenty-five thousand <strong>&lt;&lt; hundred &gt;&gt;</strong></td>
165f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>[25,340 mod 1,000 is 340. The rule for 100 applies.]</td>
166f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
167f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
168f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>twenty-five thousand <strong>three</strong> hundred &gt;&gt;</td>
169f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>[340 over 100 is 3. The rule for 3 is &quot;three.&quot;]</td>
170f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
171f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
172f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>twenty-five thousand three hundred <strong>forty</strong></td>
173f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>[340 mod 100 is 40. The rule for 40 applies. Since 40 divides
174f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     evenly by 10, the hyphen and substitution in the brackets are omitted.]</td>
175f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
176f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * </table>
177f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
178f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>The above syntax suffices only to format positive integers. To format negative numbers,
179f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * we add a special rule:</p>
180f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
181f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <pre>-x: minus &gt;&gt;;</pre>
182f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
183f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>This is called a <em>negative-number rule,</em> and is identified by &quot;-x&quot;
184f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * where the base value would be. This rule is used to format all negative numbers. the
185f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * &gt;&gt; token here means &quot;find the number's absolute value, format it with these
186f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * rules, and put the result here.&quot;</p>
187f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
188f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>We also add a special rule called a <em>fraction rule </em>for numbers with fractional
189f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * parts:</p>
190f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
191f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <pre>x.x: &lt;&lt; point &gt;&gt;;</pre>
192f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
193f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>This rule is used for all positive non-integers (negative non-integers pass through the
194f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * negative-number rule first and then through this rule). Here, the &lt;&lt; token refers to
195f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * the number's integral part, and the &gt;&gt; to the number's fractional part. The
196f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * fractional part is formatted as a series of single-digit numbers (e.g., 123.456 would be
197f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * formatted as &quot;one hundred twenty-three point four five six&quot;).</p>
198f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
199f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>To see how this rule syntax is applied to various languages, examine the resource data.</p>
200f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
201f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>There is actually much more flexibility built into the rule language than the
202f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * description above shows. A formatter may own multiple rule sets, which can be selected by
203f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * the caller, and which can use each other to fill in their substitutions. Substitutions can
204f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * also be filled in with digits, using a DecimalFormat object. There is syntax that can be
205f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * used to alter a rule's divisor in various ways. And there is provision for much more
206f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * flexible fraction handling. A complete description of the rule syntax follows:</p>
207f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
208f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <hr>
209f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
210f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>The description of a <tt>RuleBasedNumberFormat</tt>'s behavior consists of one or more <em>rule
211f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * sets.</em> Each rule set consists of a name, a colon, and a list of <em>rules.</em> A rule
212f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * set name must begin with a % sign. Rule sets with names that begin with a single % sign
213f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * are <em>public:</em> the caller can specify that they be used to format and parse numbers.
214f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Rule sets with names that begin with %% are <em>private:</em> they exist only for the use
215f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * of other rule sets. If a formatter only has one rule set, the name may be omitted.</p>
216f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
217f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>The user can also specify a special &quot;rule set&quot; named <tt>%%lenient-parse</tt>.
218f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * The body of <tt>%%lenient-parse</tt> isn't a set of number-formatting rules, but a <tt>RuleBasedCollator</tt>
219f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * description which is used to define equivalences for lenient parsing. For more information
220f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * on the syntax, see <tt>RuleBasedCollator</tt>. For more information on lenient parsing,
221f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * see <tt>setLenientParse()</tt>.  <em>Note:</em> symbols that have syntactic meaning
222f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * in collation rules, such as '&amp;', have no particular meaning when appearing outside
223f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * of the <tt>lenient-parse</tt> rule set.</p>
224f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
225f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>The body of a rule set consists of an ordered, semicolon-delimited list of <em>rules.</em>
226f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Internally, every rule has a base value, a divisor, rule text, and zero, one, or two <em>substitutions.</em>
227f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * These parameters are controlled by the description syntax, which consists of a <em>rule
228f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * descriptor,</em> a colon, and a <em>rule body.</em></p>
229f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
230f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>A rule descriptor can take one of the following forms (text in <em>italics</em> is the
231f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * name of a token):</p>
232f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
233f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <table border="0" width="100%">
234f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
235f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td><em>bv</em>:</td>
236f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td><em>bv</em> specifies the rule's base value. <em>bv</em> is a decimal
237f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     number expressed using ASCII digits. <em>bv</em> may contain spaces, period, and commas,
238f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     which are ignored. The rule's divisor is the highest power of 10 less than or equal to
239f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     the base value.</td>
240f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
241f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
242f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td><em>bv</em>/<em>rad</em>:</td>
243f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td><em>bv</em> specifies the rule's base value. The rule's divisor is the
244f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     highest power of <em>rad</em> less than or equal to the base value.</td>
245f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
246f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
247f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td><em>bv</em>&gt;:</td>
248f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td><em>bv</em> specifies the rule's base value. To calculate the divisor,
249f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     let the radix be 10, and the exponent be the highest exponent of the radix that yields a
250f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     result less than or equal to the base value. Every &gt; character after the base value
251f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     decreases the exponent by 1. If the exponent is positive or 0, the divisor is the radix
252f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     raised to the power of the exponent; otherwise, the divisor is 1.</td>
253f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
254f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
255f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td><em>bv</em>/<em>rad</em>&gt;:</td>
256f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td><em>bv</em> specifies the rule's base value. To calculate the divisor,
257f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     let the radix be <em>rad</em>, and the exponent be the highest exponent of the radix that
258f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     yields a result less than or equal to the base value. Every &gt; character after the radix
259f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     decreases the exponent by 1. If the exponent is positive or 0, the divisor is the radix
260f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     raised to the power of the exponent; otherwise, the divisor is 1.</td>
261f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
262f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
263f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>-x:</td>
264f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>The rule is a negative-number rule.</td>
265f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
266f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
267f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>x.x:</td>
268f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>The rule is an <em>improper fraction rule.</em></td>
269f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
270f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
271f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>0.x:</td>
272f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>The rule is a <em>proper fraction rule.</em></td>
273f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
274f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
275f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>x.0:</td>
276f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>The rule is a <em>master rule.</em></td>
277f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
278f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
279f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td><em>nothing</em></td>
280f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>If the rule's rule descriptor is left out, the base value is one plus the
281f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     preceding rule's base value (or zero if this is the first rule in the list) in a normal
282f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     rule set.&nbsp; In a fraction rule set, the base value is the same as the preceding rule's
283f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     base value.</td>
284f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
285f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * </table>
286f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
287f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>A rule set may be either a regular rule set or a <em>fraction rule set,</em> depending
288f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * on whether it is used to format a number's integral part (or the whole number) or a
289f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * number's fractional part. Using a rule set to format a rule's fractional part makes it a
290f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * fraction rule set.</p>
291f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
292f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>Which rule is used to format a number is defined according to one of the following
293f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * algorithms: If the rule set is a regular rule set, do the following:
294f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
295f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <ul>
296f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <li>If the rule set includes a master rule (and the number was passed in as a <tt>double</tt>),
297f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     use the master rule.&nbsp; (If the number being formatted was passed in as a <tt>long</tt>,
298f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     the master rule is ignored.)</li>
299f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <li>If the number is negative, use the negative-number rule.</li>
300f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <li>If the number has a fractional part and is greater than 1, use the improper fraction
301f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     rule.</li>
302f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <li>If the number has a fractional part and is between 0 and 1, use the proper fraction
303f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     rule.</li>
304f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <li>Binary-search the rule list for the rule with the highest base value less than or equal
305f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     to the number. If that rule has two substitutions, its base value is not an even multiple
306f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     of its divisor, and the number <em>is</em> an even multiple of the rule's divisor, use the
307f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     rule that precedes it in the rule list. Otherwise, use the rule itself.</li>
308f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * </ul>
309f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
310f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>If the rule set is a fraction rule set, do the following:
311f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
312f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <ul>
313f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <li>Ignore negative-number and fraction rules.</li>
314f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <li>For each rule in the list, multiply the number being formatted (which will always be
315f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     between 0 and 1) by the rule's base value. Keep track of the distance between the result
316f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     the nearest integer.</li>
317f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <li>Use the rule that produced the result closest to zero in the above calculation. In the
318f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     event of a tie or a direct hit, use the first matching rule encountered. (The idea here is
319f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     to try each rule's base value as a possible denominator of a fraction. Whichever
320f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     denominator produces the fraction closest in value to the number being formatted wins.) If
321f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     the rule following the matching rule has the same base value, use it if the numerator of
322f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     the fraction is anything other than 1; if the numerator is 1, use the original matching
323f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     rule. (This is to allow singular and plural forms of the rule text without a lot of extra
324f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     hassle.)</li>
325f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * </ul>
326f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
327f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>A rule's body consists of a string of characters terminated by a semicolon. The rule
328f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * may include zero, one, or two <em>substitution tokens,</em> and a range of text in
329f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * brackets. The brackets denote optional text (and may also include one or both
330f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * substitutions). The exact meanings of the substitution tokens, and under what conditions
331f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * optional text is omitted, depend on the syntax of the substitution token and the context.
332f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * The rest of the text in a rule body is literal text that is output when the rule matches
333f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * the number being formatted.</p>
334f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
335f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>A substitution token begins and ends with a <em>token character.</em> The token
336f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * character and the context together specify a mathematical operation to be performed on the
337f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * number being formatted. An optional <em>substitution descriptor </em>specifies how the
338f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * value resulting from that operation is used to fill in the substitution. The position of
339f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * the substitution token in the rule body specifies the location of the resultant text in
340f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * the original rule text.</p>
341f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
342f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>The meanings of the substitution token characters are as follows:</p>
343f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
344f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <table border="0" width="100%">
345f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
346f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>&gt;&gt;</td>
347f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>in normal rule</td>
348f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>Divide the number by the rule's divisor and format the remainder</td>
349f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
350f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
351f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td></td>
352f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>in negative-number rule</td>
353f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>Find the absolute value of the number and format the result</td>
354f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
355f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
356f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td></td>
357f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>in fraction or master rule</td>
358f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>Isolate the number's fractional part and format it.</td>
359f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
360f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
361f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td></td>
362f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>in rule in fraction rule set</td>
363f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>Not allowed.</td>
364f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
365f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
366f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>&gt;&gt;&gt;</td>
367f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>in normal rule</td>
368f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>Divide the number by the rule's divisor and format the remainder,
369f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *       but bypass the normal rule-selection process and just use the
370f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *       rule that precedes this one in this rule list.</td>
371f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
372f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
373f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td></td>
374f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>in all other rules</td>
375f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>Not allowed.</td>
376f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
377f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
378f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>&lt;&lt;</td>
379f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>in normal rule</td>
380f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>Divide the number by the rule's divisor and format the quotient</td>
381f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
382f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
383f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td></td>
384f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>in negative-number rule</td>
385f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>Not allowed.</td>
386f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
387f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
388f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td></td>
389f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>in fraction or master rule</td>
390f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>Isolate the number's integral part and format it.</td>
391f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
392f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
393f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td></td>
394f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>in rule in fraction rule set</td>
395f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>Multiply the number by the rule's base value and format the result.</td>
396f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
397f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
398f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>==</td>
399f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>in all rule sets</td>
400f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>Format the number unchanged</td>
401f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
402f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
403f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>[]</td>
404f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>in normal rule</td>
405f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>Omit the optional text if the number is an even multiple of the rule's divisor</td>
406f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
407f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
408f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td></td>
409f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>in negative-number rule</td>
410f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>Not allowed.</td>
411f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
412f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
413f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td></td>
414f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>in improper-fraction rule</td>
415f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>Omit the optional text if the number is between 0 and 1 (same as specifying both an
416f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     x.x rule and a 0.x rule)</td>
417f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
418f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
419f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td></td>
420f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>in master rule</td>
421f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>Omit the optional text if the number is an integer (same as specifying both an x.x
422f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     rule and an x.0 rule)</td>
423f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
424f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
425f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td></td>
426f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>in proper-fraction rule</td>
427f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>Not allowed.</td>
428f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
429f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
430f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td></td>
431f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>in rule in fraction rule set</td>
432f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>Omit the optional text if multiplying the number by the rule's base value yields 1.</td>
433f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
434f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * </table>
435f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
436f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>The substitution descriptor (i.e., the text between the token characters) may take one
437f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * of three forms:</p>
438f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
439f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <table border="0" width="100%">
440f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
441f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>a rule set name</td>
442f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>Perform the mathematical operation on the number, and format the result using the
443f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     named rule set.</td>
444f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
445f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
446f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>a DecimalFormat pattern</td>
447f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>Perform the mathematical operation on the number, and format the result using a
448f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     DecimalFormat with the specified pattern.&nbsp; The pattern must begin with 0 or #.</td>
449f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
450f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   <tr>
451f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>nothing</td>
452f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <td>Perform the mathematical operation on the number, and format the result using the rule
453f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     set containing the current rule, except:
454f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     <ul>
455f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *       <li>You can't have an empty substitution descriptor with a == substitution.</li>
456f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *       <li>If you omit the substitution descriptor in a &gt;&gt; substitution in a fraction rule,
457f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *         format the result one digit at a time using the rule set containing the current rule.</li>
458f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *       <li>If you omit the substitution descriptor in a &lt;&lt; substitution in a rule in a
459f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *         fraction rule set, format the result using the default rule set for this formatter.</li>
460f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     </ul>
461f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *     </td>
462f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   </tr>
463f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * </table>
464f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
465f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>Whitespace is ignored between a rule set name and a rule set body, between a rule
466f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * descriptor and a rule body, or between rules. If a rule body begins with an apostrophe,
467f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * the apostrophe is ignored, but all text after it becomes significant (this is how you can
468f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * have a rule's rule text begin with whitespace). There is no escape function: the semicolon
469f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * is not allowed in rule set names or in rule text, and the colon is not allowed in rule set
470f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * names. The characters beginning a substitution token are always treated as the beginning
471f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * of a substitution token.</p>
472f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
473f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>See the resource data and the demo program for annotated examples of real rule sets
474f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * using these features.</p>
475f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
476f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p><em>User subclasses are not supported.</em> While clients may write
477f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * subclasses, such code will not necessarily work and will not be
478f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * guaranteed to work stably from release to release.
479f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *
480f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p><b>Localizations</b></p>
481f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>Constructors are available that allow the specification of localizations for the
482f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * public rule sets (and also allow more control over what public rule sets are available).
483f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Localization data is represented as a textual description.  The description represents
484f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * an array of arrays of string.  The first element is an array of the public rule set names,
485f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * each of these must be one of the public rule set names that appear in the rules.  Only
486f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * names in this array will be treated as public rule set names by the API.  Each subsequent
487f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * element is an array of localizations of these names.  The first element of one of these
488f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * subarrays is the locale name, and the remaining elements are localizations of the
489f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * public rule set names, in the same order as they were listed in the first arrray.</p>
490f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>In the syntax, angle brackets '<', '>' are used to delimit the arrays, and comma ',' is used
491f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * to separate elements of an array.  Whitespace is ignored, unless quoted.</p>
492f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p>For example:<pre>
493f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * < < %foo, %bar, %baz >,
494f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   < en, Foo, Bar, Baz >,
495f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   < fr, 'le Foo', 'le Bar', 'le Baz' >
496f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) *   < zh, \\u7532, \\u4e59, \\u4e19 > >
497f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * </pre></p>
498f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @author Richard Gillam
499f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @see NumberFormat
500f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @see DecimalFormat
501f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @stable ICU 2.0
502f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */
503f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)class U_I18N_API RuleBasedNumberFormat : public NumberFormat {
504f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)public:
505f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
506f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  //-----------------------------------------------------------------------
507f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  // constructors
508f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  //-----------------------------------------------------------------------
509f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
510f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    /**
511f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * Creates a RuleBasedNumberFormat that behaves according to the description
512f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * passed in.  The formatter uses the default locale.
513f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * @param rules A description of the formatter's desired behavior.
514f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * See the class documentation for a complete explanation of the description
515f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * syntax.
516f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * @param perror The parse error if an error was encountered.
517f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * @param status The status indicating whether the constructor succeeded.
518f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * @stable ICU 3.2
519f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     */
520f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    RuleBasedNumberFormat(const UnicodeString& rules, UParseError& perror, UErrorCode& status);
521f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
522f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    /**
523f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * Creates a RuleBasedNumberFormat that behaves according to the description
524f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * passed in.  The formatter uses the default locale.
525f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * <p>
526f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * The localizations data provides information about the public
527f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * rule sets and their localized display names for different
528f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * locales. The first element in the list is an array of the names
529f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * of the public rule sets.  The first element in this array is
530f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * the initial default ruleset.  The remaining elements in the
531f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * list are arrays of localizations of the names of the public
532f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * rule sets.  Each of these is one longer than the initial array,
533f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * with the first String being the ULocale ID, and the remaining
534f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * Strings being the localizations of the rule set names, in the
535f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * same order as the initial array.  Arrays are NULL-terminated.
536f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * @param rules A description of the formatter's desired behavior.
537f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * See the class documentation for a complete explanation of the description
538f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * syntax.
539f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * @param localizations the localization information.
540f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * names in the description.  These will be copied by the constructor.
541f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * @param perror The parse error if an error was encountered.
542f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * @param status The status indicating whether the constructor succeeded.
543f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * @stable ICU 3.2
544f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     */
545f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    RuleBasedNumberFormat(const UnicodeString& rules, const UnicodeString& localizations,
546f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                        UParseError& perror, UErrorCode& status);
547f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
548f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
549f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Creates a RuleBasedNumberFormat that behaves according to the rules
550f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * passed in.  The formatter uses the specified locale to determine the
551f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * characters to use when formatting numerals, and to define equivalences
552f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * for lenient parsing.
553f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param rules The formatter rules.
554f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * See the class documentation for a complete explanation of the rule
555f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * syntax.
556f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param locale A locale that governs which characters are used for
557f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * formatting values in numerals and which characters are equivalent in
558f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * lenient parsing.
559f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param perror The parse error if an error was encountered.
560f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param status The status indicating whether the constructor succeeded.
561f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 2.0
562f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
563f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  RuleBasedNumberFormat(const UnicodeString& rules, const Locale& locale,
564f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                        UParseError& perror, UErrorCode& status);
565f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
566f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    /**
567f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * Creates a RuleBasedNumberFormat that behaves according to the description
568f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * passed in.  The formatter uses the default locale.
569f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * <p>
570f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * The localizations data provides information about the public
571f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * rule sets and their localized display names for different
572f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * locales. The first element in the list is an array of the names
573f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * of the public rule sets.  The first element in this array is
574f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * the initial default ruleset.  The remaining elements in the
575f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * list are arrays of localizations of the names of the public
576f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * rule sets.  Each of these is one longer than the initial array,
577f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * with the first String being the ULocale ID, and the remaining
578f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * Strings being the localizations of the rule set names, in the
579f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * same order as the initial array.  Arrays are NULL-terminated.
580f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * @param rules A description of the formatter's desired behavior.
581f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * See the class documentation for a complete explanation of the description
582f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * syntax.
583f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * @param localizations a list of localizations for the rule set
584f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * names in the description.  These will be copied by the constructor.
585f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * @param locale A locale that governs which characters are used for
586f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * formatting values in numerals and which characters are equivalent in
587f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * lenient parsing.
588f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * @param perror The parse error if an error was encountered.
589f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * @param status The status indicating whether the constructor succeeded.
590f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * @stable ICU 3.2
591f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     */
592f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    RuleBasedNumberFormat(const UnicodeString& rules, const UnicodeString& localizations,
593f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                        const Locale& locale, UParseError& perror, UErrorCode& status);
594f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
595f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
596f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Creates a RuleBasedNumberFormat from a predefined ruleset.  The selector
597f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * code choosed among three possible predefined formats: spellout, ordinal,
598f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * and duration.
599f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param tag A selector code specifying which kind of formatter to create for that
600f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * locale.  There are four legal values: URBNF_SPELLOUT, which creates a formatter that
601f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * spells out a value in words in the desired language, URBNF_ORDINAL, which attaches
602f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * an ordinal suffix from the desired language to the end of a number (e.g. "123rd"),
603f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * URBNF_DURATION, which formats a duration in seconds as hours, minutes, and seconds,
604f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * and URBNF_NUMBERING_SYSTEM, which is used to invoke rules for alternate numbering
605f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * systems such as the Hebrew numbering system, or for Roman Numerals, etc.
606f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param locale The locale for the formatter.
607f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param status The status indicating whether the constructor succeeded.
608f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 2.0
609f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
610f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  RuleBasedNumberFormat(URBNFRuleSetTag tag, const Locale& locale, UErrorCode& status);
611f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
612f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  //-----------------------------------------------------------------------
613f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  // boilerplate
614f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  //-----------------------------------------------------------------------
615f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
616f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
617f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Copy constructor
618f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param rhs    the object to be copied from.
619f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 2.6
620f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
621f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  RuleBasedNumberFormat(const RuleBasedNumberFormat& rhs);
622f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
623f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
624f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Assignment operator
625f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param rhs    the object to be copied from.
626f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 2.6
627f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
628f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  RuleBasedNumberFormat& operator=(const RuleBasedNumberFormat& rhs);
629f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
630f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
631f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Release memory allocated for a RuleBasedNumberFormat when you are finished with it.
632f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 2.6
633f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
634f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  virtual ~RuleBasedNumberFormat();
635f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
636f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
637f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Clone this object polymorphically.  The caller is responsible
638f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * for deleting the result when done.
639f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @return  A copy of the object.
640f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 2.6
641f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
642f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  virtual Format* clone(void) const;
643f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
644f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
645f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Return true if the given Format objects are semantically equal.
646f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Objects of different subclasses are considered unequal.
647f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param other    the object to be compared with.
648f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @return        true if the given Format objects are semantically equal.
649f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 2.6
650f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
651f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  virtual UBool operator==(const Format& other) const;
652f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
653f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)//-----------------------------------------------------------------------
654f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)// public API functions
655f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)//-----------------------------------------------------------------------
656f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
657f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
658f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * return the rules that were provided to the RuleBasedNumberFormat.
659f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @return the result String that was passed in
660f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 2.0
661f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
662f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  virtual UnicodeString getRules() const;
663f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
664f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
665f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Return the number of public rule set names.
666f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @return the number of public rule set names.
667f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 2.0
668f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
669f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  virtual int32_t getNumberOfRuleSetNames() const;
670f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
671f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
672f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Return the name of the index'th public ruleSet.  If index is not valid,
673f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * the function returns null.
674f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param index the index of the ruleset
675f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @return the name of the index'th public ruleSet.
676f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 2.0
677f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
678f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  virtual UnicodeString getRuleSetName(int32_t index) const;
679f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
680f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
681f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Return the number of locales for which we have localized rule set display names.
682f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @return the number of locales for which we have localized rule set display names.
683f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 3.2
684f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
685f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  virtual int32_t getNumberOfRuleSetDisplayNameLocales(void) const;
686f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
687f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
688f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Return the index'th display name locale.
689f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param index the index of the locale
690f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param status set to a failure code when this function fails
691f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @return the locale
692f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @see #getNumberOfRuleSetDisplayNameLocales
693f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 3.2
694f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
695f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  virtual Locale getRuleSetDisplayNameLocale(int32_t index, UErrorCode& status) const;
696f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
697f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    /**
698f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * Return the rule set display names for the provided locale.  These are in the same order
699f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * as those returned by getRuleSetName.  The locale is matched against the locales for
700f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * which there is display name data, using normal fallback rules.  If no locale matches,
701f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * the default display names are returned.  (These are the internal rule set names minus
702f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * the leading '%'.)
703f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * @param index the index of the rule set
704f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * @param locale the locale (returned by getRuleSetDisplayNameLocales) for which the localized
705f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * display name is desired
706f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * @return the display name for the given index, which might be bogus if there is an error
707f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * @see #getRuleSetName
708f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * @stable ICU 3.2
709f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     */
710f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  virtual UnicodeString getRuleSetDisplayName(int32_t index,
711f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                          const Locale& locale = Locale::getDefault());
712f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
713f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    /**
714f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * Return the rule set display name for the provided rule set and locale.
715f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * The locale is matched against the locales for which there is display name data, using
716f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * normal fallback rules.  If no locale matches, the default display name is returned.
717f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * @return the display name for the rule set
718f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * @stable ICU 3.2
719f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * @see #getRuleSetDisplayName
720f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     */
721f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  virtual UnicodeString getRuleSetDisplayName(const UnicodeString& ruleSetName,
722f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                          const Locale& locale = Locale::getDefault());
723f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
724f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
725f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  using NumberFormat::format;
726f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
727f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
728f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Formats the specified 32-bit number using the default ruleset.
729f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param number The number to format.
730f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param toAppendTo the string that will hold the (appended) result
731f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param pos the fieldposition
732f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @return A textual representation of the number.
733f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 2.0
734f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
735f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  virtual UnicodeString& format(int32_t number,
736f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                                UnicodeString& toAppendTo,
737f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                                FieldPosition& pos) const;
738f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
739f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
740f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Formats the specified 64-bit number using the default ruleset.
741f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param number The number to format.
742f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param toAppendTo the string that will hold the (appended) result
743f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param pos the fieldposition
744f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @return A textual representation of the number.
745f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 2.1
746f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
747f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  virtual UnicodeString& format(int64_t number,
748f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                                UnicodeString& toAppendTo,
749f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                                FieldPosition& pos) const;
750f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
751f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Formats the specified number using the default ruleset.
752f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param number The number to format.
753f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param toAppendTo the string that will hold the (appended) result
754f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param pos the fieldposition
755f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @return A textual representation of the number.
756f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 2.0
757f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
758f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  virtual UnicodeString& format(double number,
759f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                                UnicodeString& toAppendTo,
760f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                                FieldPosition& pos) const;
761f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
762f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
763f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Formats the specified number using the named ruleset.
764f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param number The number to format.
765f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param ruleSetName The name of the rule set to format the number with.
766f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * This must be the name of a valid public rule set for this formatter.
767f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param toAppendTo the string that will hold the (appended) result
768f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param pos the fieldposition
769f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param status the status
770f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @return A textual representation of the number.
771f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 2.0
772f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
773f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  virtual UnicodeString& format(int32_t number,
774f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                                const UnicodeString& ruleSetName,
775f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                                UnicodeString& toAppendTo,
776f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                                FieldPosition& pos,
777f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                                UErrorCode& status) const;
778f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
779f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Formats the specified 64-bit number using the named ruleset.
780f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param number The number to format.
781f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param ruleSetName The name of the rule set to format the number with.
782f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * This must be the name of a valid public rule set for this formatter.
783f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param toAppendTo the string that will hold the (appended) result
784f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param pos the fieldposition
785f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param status the status
786f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @return A textual representation of the number.
787f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 2.1
788f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
789f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  virtual UnicodeString& format(int64_t number,
790f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                                const UnicodeString& ruleSetName,
791f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                                UnicodeString& toAppendTo,
792f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                                FieldPosition& pos,
793f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                                UErrorCode& status) const;
794f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
795f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Formats the specified number using the named ruleset.
796f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param number The number to format.
797f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param ruleSetName The name of the rule set to format the number with.
798f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * This must be the name of a valid public rule set for this formatter.
799f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param toAppendTo the string that will hold the (appended) result
800f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param pos the fieldposition
801f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param status the status
802f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @return A textual representation of the number.
803f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 2.0
804f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
805f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  virtual UnicodeString& format(double number,
806f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                                const UnicodeString& ruleSetName,
807f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                                UnicodeString& toAppendTo,
808f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                                FieldPosition& pos,
809f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                                UErrorCode& status) const;
810f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
811f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
812f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Formats the specified number using the default ruleset.
813f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param obj The number to format.
814f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param toAppendTo the string that will hold the (appended) result
815f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param pos the fieldposition
816f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param status the status
817f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @return A textual representation of the number.
818f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 2.0
819f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
820f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  virtual UnicodeString& format(const Formattable& obj,
821f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                                UnicodeString& toAppendTo,
822f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                                FieldPosition& pos,
823f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                                UErrorCode& status) const;
824f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
825f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Redeclared Format method.
826f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param obj    the object to be formatted.
827f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param result Output param which will receive the formatted string.
828f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param status Output param set to success/failure code
829f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @return       A reference to 'result'.
830f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 2.0
831f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
832f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  UnicodeString& format(const Formattable& obj,
833f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                        UnicodeString& result,
834f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                        UErrorCode& status) const;
835f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
836f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
837f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Redeclared NumberFormat method.
838f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param number    the double value to be formatted.
839f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param output    Output param which will receive the formatted string.
840f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @return          A reference to 'output'.
841f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 2.0
842f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
843f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   UnicodeString& format(double number,
844f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                         UnicodeString& output) const;
845f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
846f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
847f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Redeclared NumberFormat method.
848f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param number    the long value to be formatted.
849f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param output    Output param which will receive the formatted string.
850f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @return          A reference to 'output'.
851f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 2.0
852f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
853f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   UnicodeString& format(int32_t number,
854f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                         UnicodeString& output) const;
855f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
856f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
857f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Parses the specfied string, beginning at the specified position, according
858f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * to this formatter's rules.  This will match the string against all of the
859f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * formatter's public rule sets and return the value corresponding to the longest
860f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * parseable substring.  This function's behavior is affected by the lenient
861f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * parse mode.
862f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param text The string to parse
863f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param result the result of the parse, either a double or a long.
864f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param parsePosition On entry, contains the position of the first character
865f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * in "text" to examine.  On exit, has been updated to contain the position
866f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * of the first character in "text" that wasn't consumed by the parse.
867f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @see #setLenient
868f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 2.0
869f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
870f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  virtual void parse(const UnicodeString& text,
871f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                     Formattable& result,
872f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                     ParsePosition& parsePosition) const;
873f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
874f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
875f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
876f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Redeclared Format method.
877f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param text   The string to parse
878f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param result the result of the parse, either a double or a long.
879f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param status Output param set to failure code when a problem occurs.
880f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 2.0
881f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
882f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  virtual inline void parse(const UnicodeString& text,
883f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                      Formattable& result,
884f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                      UErrorCode& status) const;
885f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
886f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#if !UCONFIG_NO_COLLATION
887f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
888f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
889f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Turns lenient parse mode on and off.
890f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   *
891f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * When in lenient parse mode, the formatter uses a Collator for parsing the text.
892f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Only primary differences are treated as significant.  This means that case
893f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * differences, accent differences, alternate spellings of the same letter
894f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * (e.g., ae and a-umlaut in German), ignorable characters, etc. are ignored in
895f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * matching the text.  In many cases, numerals will be accepted in place of words
896f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * or phrases as well.
897f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   *
898f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * For example, all of the following will correctly parse as 255 in English in
899f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * lenient-parse mode:
900f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * <br>"two hundred fifty-five"
901f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * <br>"two hundred fifty five"
902f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * <br>"TWO HUNDRED FIFTY-FIVE"
903f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * <br>"twohundredfiftyfive"
904f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * <br>"2 hundred fifty-5"
905f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   *
906f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * The Collator used is determined by the locale that was
907f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * passed to this object on construction.  The description passed to this object
908f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * on construction may supply additional collation rules that are appended to the
909f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * end of the default collator for the locale, enabling additional equivalences
910f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * (such as adding more ignorable characters or permitting spelled-out version of
911f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * symbols; see the demo program for examples).
912f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   *
913f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * It's important to emphasize that even strict parsing is relatively lenient: it
914f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * will accept some text that it won't produce as output.  In English, for example,
915f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * it will correctly parse "two hundred zero" and "fifteen hundred".
916f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   *
917f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param enabled If true, turns lenient-parse mode on; if false, turns it off.
918f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @see RuleBasedCollator
919f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 2.0
920f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
921f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  virtual void setLenient(UBool enabled);
922f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
923f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
924f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Returns true if lenient-parse mode is turned on.  Lenient parsing is off
925f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * by default.
926f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @return true if lenient-parse mode is turned on.
927f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @see #setLenient
928f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 2.0
929f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
930f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  virtual inline UBool isLenient(void) const;
931f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
932f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#endif
933f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
934f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
935f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Override the default rule set to use.  If ruleSetName is null, reset
936f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * to the initial default rule set.  If the rule set is not a public rule set name,
937f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * U_ILLEGAL_ARGUMENT_ERROR is returned in status.
938f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param ruleSetName the name of the rule set, or null to reset the initial default.
939f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @param status set to failure code when a problem occurs.
940f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 2.6
941f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
942f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  virtual void setDefaultRuleSet(const UnicodeString& ruleSetName, UErrorCode& status);
943f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
944f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  /**
945f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * Return the name of the current default rule set.  If the current rule set is
946f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * not public, returns a bogus (and empty) UnicodeString.
947f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @return the name of the current default rule set
948f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   * @stable ICU 3.0
949f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)   */
950f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)  virtual UnicodeString getDefaultRuleSetName() const;
951f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
952f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)public:
953f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    /**
954f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * ICU "poor man's RTTI", returns a UClassID for this class.
955f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     *
956f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * @stable ICU 2.8
957f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     */
958f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    static UClassID U_EXPORT2 getStaticClassID(void);
959f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
960f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    /**
961f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * ICU "poor man's RTTI", returns a UClassID for the actual class.
962f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     *
963f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     * @stable ICU 2.8
964f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)     */
965f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    virtual UClassID getDynamicClassID(void) const;
966f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
967f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)private:
968f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    RuleBasedNumberFormat(); // default constructor not implemented
969f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
970f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    // this will ref the localizations if they are not NULL
971f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    // caller must deref to get adoption
972f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    RuleBasedNumberFormat(const UnicodeString& description, LocalizationInfo* localizations,
973f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)              const Locale& locale, UParseError& perror, UErrorCode& status);
974f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
975f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    void init(const UnicodeString& rules, LocalizationInfo* localizations, UParseError& perror, UErrorCode& status);
976f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    void dispose();
977f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    void stripWhitespace(UnicodeString& src);
978f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    void initDefaultRuleSet();
979f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    void format(double number, NFRuleSet& ruleSet);
980f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    NFRuleSet* findRuleSet(const UnicodeString& name, UErrorCode& status) const;
981f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
982f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    /* friend access */
983f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    friend class NFSubstitution;
984f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    friend class NFRule;
985f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    friend class FractionalPartSubstitution;
986f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
987f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    inline NFRuleSet * getDefaultRuleSet() const;
988f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    Collator * getCollator() const;
989f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    DecimalFormatSymbols * getDecimalFormatSymbols() const;
990f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
991f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)private:
992f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    NFRuleSet **ruleSets;
993f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    NFRuleSet *defaultRuleSet;
994f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    Locale locale;
995f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    Collator* collator;
996f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    DecimalFormatSymbols* decimalFormatSymbols;
997f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    UBool lenient;
998f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    UnicodeString* lenientParseRules;
999f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    LocalizationInfo* localizations;
1000f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
1001f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    // Temporary workaround - when noParse is true, do noting in parse.
1002f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    // TODO: We need a real fix - see #6895/#6896
1003f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    UBool noParse;
1004f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)};
1005f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
1006f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)// ---------------
1007f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
1008f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)inline UnicodeString&
1009f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)RuleBasedNumberFormat::format(const Formattable& obj,
1010f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                              UnicodeString& result,
1011f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)                              UErrorCode& status) const
1012f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles){
1013f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    // Don't use Format:: - use immediate base class only,
1014f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    // in case immediate base modifies behavior later.
1015f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    // dlf - the above comment is bogus, if there were a reason to modify
1016f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    // it, it would be virtual, and there's no reason because it is
1017f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    // a one-line macro in NumberFormat anyway, just like this one.
1018f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    return NumberFormat::format(obj, result, status);
1019f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)}
1020f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
1021f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)inline UnicodeString&
1022f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)RuleBasedNumberFormat::format(double number, UnicodeString& output) const {
1023f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    FieldPosition pos(0);
1024f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    return format(number, output, pos);
1025f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)}
1026f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
1027f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)inline UnicodeString&
1028f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)RuleBasedNumberFormat::format(int32_t number, UnicodeString& output) const {
1029f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    FieldPosition pos(0);
1030f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    return format(number, output, pos);
1031f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)}
1032f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
1033f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)inline void
1034f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)RuleBasedNumberFormat::parse(const UnicodeString& text, Formattable& result, UErrorCode& status) const
1035f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles){
1036f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    NumberFormat::parse(text, result, status);
1037f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)}
1038f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
1039f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#if !UCONFIG_NO_COLLATION
1040f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
1041f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)inline UBool
1042f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)RuleBasedNumberFormat::isLenient(void) const {
1043f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    return lenient;
1044f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)}
1045f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
1046f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#endif
1047f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
1048f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)inline NFRuleSet*
1049f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)RuleBasedNumberFormat::getDefaultRuleSet() const {
1050f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)    return defaultRuleSet;
1051f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)}
1052f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
1053f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)U_NAMESPACE_END
1054f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
1055f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)/* U_HAVE_RBNF */
1056f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#endif
1057f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)
1058f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)/* RBNF_H */
1059f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#endif
1060