LEFT | RIGHT |
(no file at all) | |
1 // © 2017 and later: Unicode, Inc. and others. | 1 // © 2017 and later: Unicode, Inc. and others. |
2 // License & terms of use: http://www.unicode.org/copyright.html#License | 2 // License & terms of use: http://www.unicode.org/copyright.html#License |
3 package com.ibm.icu.number; | 3 package com.ibm.icu.number; |
4 | 4 |
5 import com.ibm.icu.impl.number.MacroProps; | 5 import com.ibm.icu.impl.number.MacroProps; |
6 import com.ibm.icu.impl.number.Padder; | 6 import com.ibm.icu.impl.number.Padder; |
7 import com.ibm.icu.number.NumberFormatter.DecimalSeparatorDisplay; | 7 import com.ibm.icu.number.NumberFormatter.DecimalSeparatorDisplay; |
8 import com.ibm.icu.number.NumberFormatter.SignDisplay; | 8 import com.ibm.icu.number.NumberFormatter.SignDisplay; |
9 import com.ibm.icu.number.NumberFormatter.UnitWidth; | 9 import com.ibm.icu.number.NumberFormatter.UnitWidth; |
10 import com.ibm.icu.text.DecimalFormatSymbols; | 10 import com.ibm.icu.text.DecimalFormatSymbols; |
11 import com.ibm.icu.text.NumberingSystem; | 11 import com.ibm.icu.text.NumberingSystem; |
12 import com.ibm.icu.util.Currency; | 12 import com.ibm.icu.util.Currency; |
13 import com.ibm.icu.util.Measure; | 13 import com.ibm.icu.util.Measure; |
14 import com.ibm.icu.util.MeasureUnit; | 14 import com.ibm.icu.util.MeasureUnit; |
15 import com.ibm.icu.util.NoUnit; | 15 import com.ibm.icu.util.NoUnit; |
16 import com.ibm.icu.util.ULocale; | 16 import com.ibm.icu.util.ULocale; |
17 | 17 |
18 /** | 18 /** |
19 * An abstract base class for specifying settings related to number formatting.
This class is implemented by | 19 * An abstract base class for specifying settings related to number formatting.
This class is implemented |
20 * {@link UnlocalizedNumberFormatter} and {@link LocalizedNumberFormatter}. This
class is not intended for public | 20 * by {@link UnlocalizedNumberFormatter} and {@link LocalizedNumberFormatter}. T
his class is not intended |
21 * subclassing. | 21 * for public subclassing. |
22 * | 22 * |
23 * @draft ICU 60 | 23 * @draft ICU 60 |
24 * @provisional This API might change or be removed in a future release. | 24 * @provisional This API might change or be removed in a future release. |
25 * @see NumberFormatter | 25 * @see NumberFormatter |
26 */ | 26 */ |
27 public abstract class NumberFormatterSettings<T extends NumberFormatterSettings<
?>> { | 27 public abstract class NumberFormatterSettings<T extends NumberFormatterSettings<
?>> { |
28 | 28 |
29 static final int KEY_MACROS = 0; | 29 static final int KEY_MACROS = 0; |
30 static final int KEY_LOCALE = 1; | 30 static final int KEY_LOCALE = 1; |
31 static final int KEY_NOTATION = 2; | 31 static final int KEY_NOTATION = 2; |
32 static final int KEY_UNIT = 3; | 32 static final int KEY_UNIT = 3; |
33 static final int KEY_ROUNDER = 4; | 33 static final int KEY_ROUNDER = 4; |
34 static final int KEY_GROUPER = 5; | 34 static final int KEY_GROUPER = 5; |
35 static final int KEY_PADDER = 6; | 35 static final int KEY_PADDER = 6; |
36 static final int KEY_INTEGER = 7; | 36 static final int KEY_INTEGER = 7; |
37 static final int KEY_SYMBOLS = 8; | 37 static final int KEY_SYMBOLS = 8; |
38 static final int KEY_UNIT_WIDTH = 9; | 38 static final int KEY_UNIT_WIDTH = 9; |
39 static final int KEY_SIGN = 10; | 39 static final int KEY_SIGN = 10; |
40 static final int KEY_DECIMAL = 11; | 40 static final int KEY_DECIMAL = 11; |
41 static final int KEY_THRESHOLD = 12; | 41 static final int KEY_THRESHOLD = 12; |
42 static final int KEY_MAX = 13; | 42 static final int KEY_PER_UNIT = 13; |
| 43 static final int KEY_MAX = 14; |
43 | 44 |
44 final NumberFormatterSettings<?> parent; | 45 final NumberFormatterSettings<?> parent; |
45 final int key; | 46 final int key; |
46 final Object value; | 47 final Object value; |
47 volatile MacroProps resolvedMacros; | 48 volatile MacroProps resolvedMacros; |
48 | 49 |
49 NumberFormatterSettings(NumberFormatterSettings<?> parent, int key, Object v
alue) { | 50 NumberFormatterSettings(NumberFormatterSettings<?> parent, int key, Object v
alue) { |
50 this.parent = parent; | 51 this.parent = parent; |
51 this.key = key; | 52 this.key = key; |
52 this.value = value; | 53 this.value = value; |
53 } | 54 } |
54 | 55 |
55 /** | 56 /** |
56 * Specifies the notation style (simple, scientific, or compact) for renderi
ng numbers. | 57 * Specifies the notation style (simple, scientific, or compact) for renderi
ng numbers. |
57 * | 58 * |
58 * <ul> | 59 * <ul> |
59 * <li>Simple notation: "12,300" | 60 * <li>Simple notation: "12,300" |
60 * <li>Scientific notation: "1.23E4" | 61 * <li>Scientific notation: "1.23E4" |
61 * <li>Compact notation: "12K" | 62 * <li>Compact notation: "12K" |
62 * </ul> | 63 * </ul> |
63 * | 64 * |
64 * <p> | 65 * <p> |
65 * All notation styles will be properly localized with locale data, and all
notation styles are compatible with | 66 * All notation styles will be properly localized with locale data, and all
notation styles are |
66 * units, rounding strategies, and other number formatter settings. | 67 * compatible with units, rounding strategies, and other number formatter se
ttings. |
67 * | 68 * |
68 * <p> | 69 * <p> |
69 * Pass this method the return value of a {@link Notation} factory method. F
or example: | 70 * Pass this method the return value of a {@link Notation} factory method. F
or example: |
70 * | 71 * |
71 * <pre> | 72 * <pre> |
72 * NumberFormatter.with().notation(Notation.compactShort()) | 73 * NumberFormatter.with().notation(Notation.compactShort()) |
73 * </pre> | 74 * </pre> |
74 * | 75 * |
75 * The default is to use simple notation. | 76 * The default is to use simple notation. |
76 * | 77 * |
(...skipping 12 matching lines...) Expand all Loading... |
89 * Specifies the unit (unit of measure, currency, or percent) to associate w
ith rendered numbers. | 90 * Specifies the unit (unit of measure, currency, or percent) to associate w
ith rendered numbers. |
90 * | 91 * |
91 * <ul> | 92 * <ul> |
92 * <li>Unit of measure: "12.3 meters" | 93 * <li>Unit of measure: "12.3 meters" |
93 * <li>Currency: "$12.30" | 94 * <li>Currency: "$12.30" |
94 * <li>Percent: "12.3%" | 95 * <li>Percent: "12.3%" |
95 * </ul> | 96 * </ul> |
96 * | 97 * |
97 * <p> | 98 * <p> |
98 * <strong>Note:</strong> The unit can also be specified by passing a {@link
Measure} to | 99 * <strong>Note:</strong> The unit can also be specified by passing a {@link
Measure} to |
99 * {@link LocalizedNumberFormatter#format(Measure)}. Units specified via the
format method take precedence over | 100 * {@link LocalizedNumberFormatter#format(Measure)}. Units specified via the
format method take |
100 * units specified here. This setter is designed for situations when the uni
t is constant for the duration of the | 101 * precedence over units specified here. This setter is designed for situati
ons when the unit is |
101 * number formatting process. | 102 * constant for the duration of the number formatting process. |
102 * | 103 * |
103 * <p> | 104 * <p> |
104 * All units will be properly localized with locale data, and all units are
compatible with notation styles, | 105 * All units will be properly localized with locale data, and all units are
compatible with notation |
105 * rounding strategies, and other number formatter settings. | 106 * styles, rounding strategies, and other number formatter settings. |
106 * | 107 * |
107 * <p> | 108 * <p> |
108 * Pass this method any instance of {@link MeasureUnit}. For units of measur
e: | 109 * Pass this method any instance of {@link MeasureUnit}. For units of measur
e: |
109 * | 110 * |
110 * <pre> | 111 * <pre> |
111 * NumberFormatter.with().unit(MeasureUnit.METER) | 112 * NumberFormatter.with().unit(MeasureUnit.METER) |
112 * </pre> | 113 * </pre> |
113 * | 114 * |
114 * Currency: | 115 * Currency: |
115 * | 116 * |
116 * <pre> | 117 * <pre> |
117 * NumberFormatter.with().unit(Currency.getInstance("USD")) | 118 * NumberFormatter.with().unit(Currency.getInstance("USD")) |
118 * </pre> | 119 * </pre> |
119 * | 120 * |
120 * Percent: | 121 * Percent: |
121 * | 122 * |
122 * <pre> | 123 * <pre> |
123 * NumberFormatter.with().unit(NoUnit.PERCENT) | 124 * NumberFormatter.with().unit(NoUnit.PERCENT) |
124 * </pre> | 125 * </pre> |
125 * | 126 * |
| 127 * <p> |
| 128 * See {@link #perUnit} for information on how to format strings like "5 met
ers per second". |
| 129 * |
| 130 * <p> |
126 * The default is to render without units (equivalent to {@link NoUnit#BASE}
). | 131 * The default is to render without units (equivalent to {@link NoUnit#BASE}
). |
127 * | 132 * |
128 * @param unit | 133 * @param unit |
129 * The unit to render. | 134 * The unit to render. |
130 * @return The fluent chain. | 135 * @return The fluent chain. |
131 * @see MeasureUnit | 136 * @see MeasureUnit |
132 * @see Currency | 137 * @see Currency |
133 * @see NoUnit | 138 * @see NoUnit |
| 139 * @see #perUnit |
134 * @draft ICU 60 | 140 * @draft ICU 60 |
135 * @provisional This API might change or be removed in a future release. | 141 * @provisional This API might change or be removed in a future release. |
136 */ | 142 */ |
137 public T unit(MeasureUnit unit) { | 143 public T unit(MeasureUnit unit) { |
138 return create(KEY_UNIT, unit); | 144 return create(KEY_UNIT, unit); |
| 145 } |
| 146 |
| 147 /** |
| 148 * Sets a unit to be used in the denominator. For example, to format "3 m/s"
, pass METER to the unit |
| 149 * and SECOND to the perUnit. |
| 150 * |
| 151 * <p> |
| 152 * Pass this method any instance of {@link MeasureUnit}. For example: |
| 153 * |
| 154 * <pre> |
| 155 * NumberFormatter.with().unit(MeasureUnit.METER).perUnit(MeasureUnit.SECOND
) |
| 156 * </pre> |
| 157 * |
| 158 * <p> |
| 159 * The default is not to display any unit in the denominator. |
| 160 * |
| 161 * <p> |
| 162 * If a per-unit is specified without a primary unit via {@link #unit}, the
behavior is undefined. |
| 163 * |
| 164 * @param perUnit |
| 165 * The unit to render in the denominator. |
| 166 * @return The fluent chain |
| 167 * @see #unit |
| 168 * @draft ICU 61 |
| 169 * @provisional This API might change or be removed in a future release. |
| 170 */ |
| 171 public T perUnit(MeasureUnit perUnit) { |
| 172 return create(KEY_PER_UNIT, perUnit); |
139 } | 173 } |
140 | 174 |
141 /** | 175 /** |
142 * Specifies the rounding strategy to use when formatting numbers. | 176 * Specifies the rounding strategy to use when formatting numbers. |
143 * | 177 * |
144 * <ul> | 178 * <ul> |
145 * <li>Round to 3 decimal places: "3.142" | 179 * <li>Round to 3 decimal places: "3.142" |
146 * <li>Round to 3 significant figures: "3.14" | 180 * <li>Round to 3 significant figures: "3.14" |
147 * <li>Round to the closest nickel: "3.15" | 181 * <li>Round to the closest nickel: "3.15" |
148 * <li>Do not perform rounding: "3.1415926..." | 182 * <li>Do not perform rounding: "3.1415926..." |
149 * </ul> | 183 * </ul> |
150 * | 184 * |
151 * <p> | 185 * <p> |
152 * Pass this method the return value of one of the factory methods on {@link
Rounder}. For example: | 186 * Pass this method the return value of one of the factory methods on {@link
Rounder}. For example: |
153 * | 187 * |
154 * <pre> | 188 * <pre> |
155 * NumberFormatter.with().rounding(Rounder.fixedFraction(2)) | 189 * NumberFormatter.with().rounding(Rounder.fixedFraction(2)) |
156 * </pre> | 190 * </pre> |
157 * | 191 * |
158 * <p> | 192 * <p> |
159 * In most cases, the default rounding strategy is to round to 6 fraction pl
aces; i.e., | 193 * In most cases, the default rounding strategy is to round to 6 fraction pl
aces; i.e., |
160 * <code>Rounder.maxFraction(6)</code>. The exceptions are if compact notati
on is being used, then the compact | 194 * <code>Rounder.maxFraction(6)</code>. The exceptions are if compact notati
on is being used, then |
161 * notation rounding strategy is used (see {@link Notation#compactShort} for
details), or if the unit is a currency, | 195 * the compact notation rounding strategy is used (see {@link Notation#compa
ctShort} for details), or |
162 * then standard currency rounding is used, which varies from currency to cu
rrency (see {@link Rounder#currency} for | 196 * if the unit is a currency, then standard currency rounding is used, which
varies from currency to |
163 * details). | 197 * currency (see {@link Rounder#currency} for details). |
164 * | 198 * |
165 * @param rounder | 199 * @param rounder |
166 * The rounding strategy to use. | 200 * The rounding strategy to use. |
167 * @return The fluent chain. | 201 * @return The fluent chain. |
168 * @see Rounder | 202 * @see Rounder |
169 * @draft ICU 60 | 203 * @draft ICU 60 |
170 * @provisional This API might change or be removed in a future release. | 204 * @provisional This API might change or be removed in a future release. |
171 */ | 205 */ |
172 public T rounding(Rounder rounder) { | 206 public T rounding(Rounder rounder) { |
173 return create(KEY_ROUNDER, rounder); | 207 return create(KEY_ROUNDER, rounder); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 * @return The fluent chain. | 264 * @return The fluent chain. |
231 * @see IntegerWidth | 265 * @see IntegerWidth |
232 * @draft ICU 60 | 266 * @draft ICU 60 |
233 * @provisional This API might change or be removed in a future release. | 267 * @provisional This API might change or be removed in a future release. |
234 */ | 268 */ |
235 public T integerWidth(IntegerWidth style) { | 269 public T integerWidth(IntegerWidth style) { |
236 return create(KEY_INTEGER, style); | 270 return create(KEY_INTEGER, style); |
237 } | 271 } |
238 | 272 |
239 /** | 273 /** |
240 * Specifies the symbols (decimal separator, grouping separator, percent sig
n, numerals, etc.) to use when rendering | 274 * Specifies the symbols (decimal separator, grouping separator, percent sig
n, numerals, etc.) to use |
241 * numbers. | 275 * when rendering numbers. |
242 * | 276 * |
243 * <ul> | 277 * <ul> |
244 * <li><em>en_US</em> symbols: "12,345.67" | 278 * <li><em>en_US</em> symbols: "12,345.67" |
245 * <li><em>fr_FR</em> symbols: "12 345,67" | 279 * <li><em>fr_FR</em> symbols: "12 345,67" |
246 * <li><em>de_CH</em> symbols: "12’345.67" | 280 * <li><em>de_CH</em> symbols: "12’345.67" |
247 * <li><em>my_MY</em> symbols: "၁၂,၃၄၅.၆၇" | 281 * <li><em>my_MY</em> symbols: "၁၂,၃၄၅.၆၇" |
248 * </ul> | 282 * </ul> |
249 * | 283 * |
250 * <p> | 284 * <p> |
251 * Pass this method an instance of {@link DecimalFormatSymbols}. For example
: | 285 * Pass this method an instance of {@link DecimalFormatSymbols}. For example
: |
252 * | 286 * |
253 * <pre> | 287 * <pre> |
254 * NumberFormatter.with().symbols(DecimalFormatSymbols.getInstance(new ULoca
le("de_CH"))) | 288 * NumberFormatter.with().symbols(DecimalFormatSymbols.getInstance(new ULoca
le("de_CH"))) |
255 * </pre> | 289 * </pre> |
256 * | 290 * |
257 * <p> | 291 * <p> |
258 * <strong>Note:</strong> DecimalFormatSymbols automatically chooses the bes
t numbering system based on the locale. | 292 * <strong>Note:</strong> DecimalFormatSymbols automatically chooses the bes
t numbering system based |
259 * In the examples above, the first three are using the Latin numbering syst
em, and the fourth is using the Myanmar | 293 * on the locale. In the examples above, the first three are using the Latin
numbering system, and |
260 * numbering system. | 294 * the fourth is using the Myanmar numbering system. |
261 * | 295 * |
262 * <p> | 296 * <p> |
263 * <strong>Note:</strong> The instance of DecimalFormatSymbols will be copie
d: changes made to the symbols object | 297 * <strong>Note:</strong> The instance of DecimalFormatSymbols will be copie
d: changes made to the |
264 * after passing it into the fluent chain will not be seen. | 298 * symbols object after passing it into the fluent chain will not be seen. |
265 * | 299 * |
266 * <p> | 300 * <p> |
267 * <strong>Note:</strong> Calling this method will override the NumberingSys
tem previously specified in | 301 * <strong>Note:</strong> Calling this method will override the NumberingSys
tem previously specified |
268 * {@link #symbols(NumberingSystem)}. | 302 * in {@link #symbols(NumberingSystem)}. |
269 * | 303 * |
270 * <p> | 304 * <p> |
271 * The default is to choose the symbols based on the locale specified in the
fluent chain. | 305 * The default is to choose the symbols based on the locale specified in the
fluent chain. |
272 * | 306 * |
273 * @param symbols | 307 * @param symbols |
274 * The DecimalFormatSymbols to use. | 308 * The DecimalFormatSymbols to use. |
275 * @return The fluent chain. | 309 * @return The fluent chain. |
276 * @see DecimalFormatSymbols | 310 * @see DecimalFormatSymbols |
277 * @draft ICU 60 | 311 * @draft ICU 60 |
278 * @provisional This API might change or be removed in a future release. | 312 * @provisional This API might change or be removed in a future release. |
279 */ | 313 */ |
280 public T symbols(DecimalFormatSymbols symbols) { | 314 public T symbols(DecimalFormatSymbols symbols) { |
281 symbols = (DecimalFormatSymbols) symbols.clone(); | 315 symbols = (DecimalFormatSymbols) symbols.clone(); |
282 return create(KEY_SYMBOLS, symbols); | 316 return create(KEY_SYMBOLS, symbols); |
283 } | 317 } |
284 | 318 |
285 /** | 319 /** |
286 * Specifies that the given numbering system should be used when fetching sy
mbols. | 320 * Specifies that the given numbering system should be used when fetching sy
mbols. |
287 * | 321 * |
288 * <ul> | 322 * <ul> |
289 * <li>Latin numbering system: "12,345" | 323 * <li>Latin numbering system: "12,345" |
290 * <li>Myanmar numbering system: "၁၂,၃၄၅" | 324 * <li>Myanmar numbering system: "၁၂,၃၄၅" |
291 * <li>Math Sans Bold numbering system: "𝟭𝟮,𝟯𝟰𝟱" | 325 * <li>Math Sans Bold numbering system: "𝟭𝟮,𝟯𝟰𝟱" |
292 * </ul> | 326 * </ul> |
293 * | 327 * |
294 * <p> | 328 * <p> |
295 * Pass this method an instance of {@link NumberingSystem}. For example, to
force the locale to always use the Latin | 329 * Pass this method an instance of {@link NumberingSystem}. For example, to
force the locale to |
296 * alphabet numbering system (ASCII digits): | 330 * always use the Latin alphabet numbering system (ASCII digits): |
297 * | 331 * |
298 * <pre> | 332 * <pre> |
299 * NumberFormatter.with().symbols(NumberingSystem.LATIN) | 333 * NumberFormatter.with().symbols(NumberingSystem.LATIN) |
300 * </pre> | 334 * </pre> |
301 * | 335 * |
302 * <p> | 336 * <p> |
303 * <strong>Note:</strong> Calling this method will override the DecimalForma
tSymbols previously specified in | 337 * <strong>Note:</strong> Calling this method will override the DecimalForma
tSymbols previously |
304 * {@link #symbols(DecimalFormatSymbols)}. | 338 * specified in {@link #symbols(DecimalFormatSymbols)}. |
305 * | 339 * |
306 * <p> | 340 * <p> |
307 * The default is to choose the best numbering system for the locale. | 341 * The default is to choose the best numbering system for the locale. |
308 * | 342 * |
309 * @param ns | 343 * @param ns |
310 * The NumberingSystem to use. | 344 * The NumberingSystem to use. |
311 * @return The fluent chain. | 345 * @return The fluent chain. |
312 * @see NumberingSystem | 346 * @see NumberingSystem |
313 * @draft ICU 60 | 347 * @draft ICU 60 |
314 * @provisional This API might change or be removed in a future release. | 348 * @provisional This API might change or be removed in a future release. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 * @return The fluent chain | 405 * @return The fluent chain |
372 * @see SignDisplay | 406 * @see SignDisplay |
373 * @draft ICU 60 | 407 * @draft ICU 60 |
374 * @provisional This API might change or be removed in a future release. | 408 * @provisional This API might change or be removed in a future release. |
375 */ | 409 */ |
376 public T sign(SignDisplay style) { | 410 public T sign(SignDisplay style) { |
377 return create(KEY_SIGN, style); | 411 return create(KEY_SIGN, style); |
378 } | 412 } |
379 | 413 |
380 /** | 414 /** |
381 * Sets the decimal separator display strategy. This affects integer numbers
with no fraction part. Most common | 415 * Sets the decimal separator display strategy. This affects integer numbers
with no fraction part. |
382 * values: | 416 * Most common values: |
383 * | 417 * |
384 * <ul> | 418 * <ul> |
385 * <li>Auto: "1" | 419 * <li>Auto: "1" |
386 * <li>Always: "1." | 420 * <li>Always: "1." |
387 * </ul> | 421 * </ul> |
388 * | 422 * |
389 * <p> | 423 * <p> |
390 * Pass an element from the {@link DecimalSeparatorDisplay} enum to this set
ter. For example: | 424 * Pass an element from the {@link DecimalSeparatorDisplay} enum to this set
ter. For example: |
391 * | 425 * |
392 * <pre> | 426 * <pre> |
(...skipping 30 matching lines...) Expand all Loading... |
423 * | 457 * |
424 * @internal | 458 * @internal |
425 * @deprecated ICU 60 This API is ICU internal only. | 459 * @deprecated ICU 60 This API is ICU internal only. |
426 */ | 460 */ |
427 @Deprecated | 461 @Deprecated |
428 public T padding(Padder padder) { | 462 public T padding(Padder padder) { |
429 return create(KEY_PADDER, padder); | 463 return create(KEY_PADDER, padder); |
430 } | 464 } |
431 | 465 |
432 /** | 466 /** |
433 * Internal fluent setter to support a custom regulation threshold. A thresh
old of 1 causes the data structures to | 467 * Internal fluent setter to support a custom regulation threshold. A thresh
old of 1 causes the data |
434 * be built right away. A threshold of 0 prevents the data structures from b
eing built. | 468 * structures to be built right away. A threshold of 0 prevents the data str
uctures from being built. |
435 * | 469 * |
436 * @internal | 470 * @internal |
437 * @deprecated ICU 60 This API is ICU internal only. | 471 * @deprecated ICU 60 This API is ICU internal only. |
438 */ | 472 */ |
439 @Deprecated | 473 @Deprecated |
440 public T threshold(Long threshold) { | 474 public T threshold(Long threshold) { |
441 return create(KEY_THRESHOLD, threshold); | 475 return create(KEY_THRESHOLD, threshold); |
442 } | 476 } |
443 | 477 |
444 /* package-protected */ abstract T create(int key, Object value); | 478 /* package-protected */ abstract T create(int key, Object value); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 case KEY_DECIMAL: | 545 case KEY_DECIMAL: |
512 if (macros.decimal == null) { | 546 if (macros.decimal == null) { |
513 macros.decimal = (DecimalSeparatorDisplay) current.value; | 547 macros.decimal = (DecimalSeparatorDisplay) current.value; |
514 } | 548 } |
515 break; | 549 break; |
516 case KEY_THRESHOLD: | 550 case KEY_THRESHOLD: |
517 if (macros.threshold == null) { | 551 if (macros.threshold == null) { |
518 macros.threshold = (Long) current.value; | 552 macros.threshold = (Long) current.value; |
519 } | 553 } |
520 break; | 554 break; |
| 555 case KEY_PER_UNIT: |
| 556 if (macros.perUnit == null) { |
| 557 macros.perUnit = (MeasureUnit) current.value; |
| 558 } |
| 559 break; |
521 default: | 560 default: |
522 throw new AssertionError("Unknown key: " + current.key); | 561 throw new AssertionError("Unknown key: " + current.key); |
523 } | 562 } |
524 current = current.parent; | 563 current = current.parent; |
525 } | 564 } |
526 resolvedMacros = macros; | 565 resolvedMacros = macros; |
527 return macros; | 566 return macros; |
528 } | 567 } |
529 | 568 |
530 /** | 569 /** |
(...skipping 20 matching lines...) Expand all Loading... |
551 } | 590 } |
552 if (other == null) { | 591 if (other == null) { |
553 return false; | 592 return false; |
554 } | 593 } |
555 if (!(other instanceof NumberFormatterSettings)) { | 594 if (!(other instanceof NumberFormatterSettings)) { |
556 return false; | 595 return false; |
557 } | 596 } |
558 return resolve().equals(((NumberFormatterSettings<?>) other).resolve()); | 597 return resolve().equals(((NumberFormatterSettings<?>) other).resolve()); |
559 } | 598 } |
560 } | 599 } |
LEFT | RIGHT |