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