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.impl.number; | 3 package com.ibm.icu.impl.number; |
4 | 4 |
5 /** | 5 /** |
6 * This interface is used when all number formatting settings, including the loc
ale, are known, except for the quantity | 6 * This interface is used when all number formatting settings, including the loc
ale, are known, except |
7 * itself. The {@link #processQuantity} method performs the final step in the nu
mber processing pipeline: it uses the | 7 * for the quantity itself. The {@link #processQuantity} method performs the fin
al step in the number |
8 * quantity to generate a finalized {@link MicroProps}, which can be used to ren
der the number to output. | 8 * processing pipeline: it uses the quantity to generate a finalized {@link Micr
oProps}, which can be |
| 9 * used to render the number to output. |
9 * | 10 * |
10 * <p> | 11 * <p> |
11 * In other words, this interface is used for the parts of number processing tha
t are <em>quantity-dependent</em>. | 12 * In other words, this interface is used for the parts of number processing tha
t are |
| 13 * <em>quantity-dependent</em>. |
12 * | 14 * |
13 * <p> | 15 * <p> |
14 * In order to allow for multiple different objects to all mutate the same Micro
Props, a "chain" of MicroPropsGenerators | 16 * In order to allow for multiple different objects to all mutate the same Micro
Props, a "chain" of |
15 * are linked together, and each one is responsible for manipulating a certain q
uantity-dependent part of the | 17 * MicroPropsGenerators are linked together, and each one is responsible for man
ipulating a certain |
16 * MicroProps. At the top of the linked list is a base instance of {@link MicroP
rops} with properties that are not | 18 * quantity-dependent part of the MicroProps. At the top of the linked list is a
base instance of |
17 * quantity-dependent. Each element in the linked list calls {@link #processQuan
tity} on its "parent", then does its | 19 * {@link MicroProps} with properties that are not quantity-dependent. Each elem
ent in the linked list |
18 * work, and then returns the result. | 20 * calls {@link #processQuantity} on its "parent", then does its work, and then
returns the result. |
19 * | 21 * |
20 * <p> | 22 * <p> |
21 * A class implementing MicroPropsGenerator looks something like this: | 23 * A class implementing MicroPropsGenerator looks something like this: |
22 * | 24 * |
23 * <pre> | 25 * <pre> |
24 * class Foo implements MicroPropsGenerator { | 26 * class Foo implements MicroPropsGenerator { |
25 * private final MicroPropsGenerator parent; | 27 * private final MicroPropsGenerator parent; |
26 * | 28 * |
27 * public Foo(MicroPropsGenerator parent) { | 29 * public Foo(MicroPropsGenerator parent) { |
28 * this.parent = parent; | 30 * this.parent = parent; |
29 * } | 31 * } |
30 * | 32 * |
31 * @Override | 33 * @Override |
32 * public MicroProps processQuantity(DecimalQuantity quantity) { | 34 * public MicroProps processQuantity(DecimalQuantity quantity) { |
33 * MicroProps micros = this.parent.processQuantity(quantity); | 35 * MicroProps micros = this.parent.processQuantity(quantity); |
34 * // Perform manipulations on micros and/or quantity | 36 * // Perform manipulations on micros and/or quantity |
35 * return micros; | 37 * return micros; |
36 * } | 38 * } |
37 * } | 39 * } |
38 * </pre> | 40 * </pre> |
39 * | 41 * |
40 * @author sffc | 42 * @author sffc |
41 * | 43 * |
42 */ | 44 */ |
43 public interface MicroPropsGenerator { | 45 public interface MicroPropsGenerator { |
44 /** | 46 /** |
45 * Considers the given {@link DecimalQuantity}, optionally mutates it, and r
eturns a {@link MicroProps}. | 47 * Considers the given {@link DecimalQuantity}, optionally mutates it, and r
eturns a |
| 48 * {@link MicroProps}. |
46 * | 49 * |
47 * @param quantity | 50 * @param quantity |
48 * The quantity for consideration and optional mutation. | 51 * The quantity for consideration and optional mutation. |
49 * @return A MicroProps instance resolved for the quantity. | 52 * @return A MicroProps instance resolved for the quantity. |
50 */ | 53 */ |
51 public MicroProps processQuantity(DecimalQuantity quantity); | 54 public MicroProps processQuantity(DecimalQuantity quantity); |
52 } | 55 } |
LEFT | RIGHT |