OLD | NEW |
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 import java.math.BigDecimal; | 5 import java.math.BigDecimal; |
6 import java.math.MathContext; | 6 import java.math.MathContext; |
7 | 7 |
8 import com.ibm.icu.impl.StandardPlural; | 8 import com.ibm.icu.impl.StandardPlural; |
9 import com.ibm.icu.text.PluralRules; | 9 import com.ibm.icu.text.PluralRules; |
10 | 10 |
11 /** | 11 /** |
12 * An interface representing a number to be processed by the decimal formatting
pipeline. Includes | 12 * An interface representing a number to be processed by the decimal formatting
pipeline. Includes |
13 * methods for rounding, plural rules, and decimal digit extraction. | 13 * methods for rounding, plural rules, and decimal digit extraction. |
14 * | 14 * |
15 * <p>By design, this is NOT IMMUTABLE and NOT THREAD SAFE. It is intended to be
an intermediate | 15 * <p>By design, this is NOT IMMUTABLE and NOT THREAD SAFE. It is intended to be
an intermediate |
16 * object holding state during a pass through the decimal formatting pipeline. | 16 * object holding state during a pass through the decimal formatting pipeline. |
17 * | 17 * |
18 * <p>Implementations of this interface are free to use any internal storage mec
hanism. | 18 * <p>Implementations of this interface are free to use any internal storage mec
hanism. |
19 * | 19 * |
20 * <p>TODO: Should I change this to an abstract class so that logic for min/max
digits doesn't need | 20 * <p>TODO: Should I change this to an abstract class so that logic for min/max
digits doesn't need |
21 * to be copied to every implementation? | 21 * to be copied to every implementation? |
22 */ | 22 */ |
23 public interface FormatQuantity extends PluralRules.IFixedDecimal { | 23 public interface FormatQuantity extends PluralRules.IFixedDecimal { |
24 | |
25 /** | 24 /** |
26 * Sets the minimum and maximum digits that this {@link FormatQuantity} should
generate. This | 25 * Sets the minimum and maximum integer digits that this {@link FormatQuantity
} should generate. |
27 * method does not perform rounding. | 26 * This method does not perform rounding. |
28 * | 27 * |
29 * @param minInt The minimum number of integer digits. | 28 * @param minInt The minimum number of integer digits. |
30 * @param maxInt The maximum number of integer digits. | 29 * @param maxInt The maximum number of integer digits. |
| 30 */ |
| 31 public void setIntegerLength(int minInt, int maxInt); |
| 32 |
| 33 /** |
| 34 * Sets the minimum and maximum fraction digits that this {@link FormatQuantit
y} should generate. |
| 35 * This method does not perform rounding. |
| 36 * |
31 * @param minFrac The minimum number of fraction digits. | 37 * @param minFrac The minimum number of fraction digits. |
32 * @param maxFrac The maximum number of fraction digits. | 38 * @param maxFrac The maximum number of fraction digits. |
33 */ | 39 */ |
34 public void setIntegerFractionLength(int minInt, int maxInt, int minFrac, int
maxFrac); | 40 public void setFractionLength(int minFrac, int maxFrac); |
35 | 41 |
36 /** | 42 /** |
37 * Rounds the number to a specified interval, such as 0.05. | 43 * Rounds the number to a specified interval, such as 0.05. |
38 * | 44 * |
39 * <p>If rounding to a power of ten, use the more efficient {@link #roundToMag
nitude} instead. | 45 * <p>If rounding to a power of ten, use the more efficient {@link #roundToMag
nitude} instead. |
40 * | 46 * |
41 * @param roundingInterval The increment to which to round. | 47 * @param roundingInterval The increment to which to round. |
42 * @param mathContext The {@link MathContext} to use if rounding is necessary.
Undefined behavior | 48 * @param mathContext The {@link MathContext} to use if rounding is necessary.
Undefined behavior |
43 * if null. | 49 * if null. |
44 */ | 50 */ |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 99 |
94 /** @return Whether the value represented by this {@link FormatQuantity} is no
t a number. */ | 100 /** @return Whether the value represented by this {@link FormatQuantity} is no
t a number. */ |
95 @Override | 101 @Override |
96 public boolean isNaN(); | 102 public boolean isNaN(); |
97 | 103 |
98 /** @return The value contained in this {@link FormatQuantity} approximated as
a double. */ | 104 /** @return The value contained in this {@link FormatQuantity} approximated as
a double. */ |
99 public double toDouble(); | 105 public double toDouble(); |
100 | 106 |
101 public BigDecimal toBigDecimal(); | 107 public BigDecimal toBigDecimal(); |
102 | 108 |
| 109 public void setToBigDecimal(BigDecimal input); |
| 110 |
103 public int maxRepresentableDigits(); | 111 public int maxRepresentableDigits(); |
104 | 112 |
105 // TODO: Should this method be removed, since FormatQuantity implements IFixed
Decimal now? | 113 // TODO: Should this method be removed, since FormatQuantity implements IFixed
Decimal now? |
106 /** | 114 /** |
107 * Computes the plural form for this number based on the specified set of rule
s. | 115 * Computes the plural form for this number based on the specified set of rule
s. |
108 * | 116 * |
109 * @param rules A {@link PluralRules} object representing the set of rules. | 117 * @param rules A {@link PluralRules} object representing the set of rules. |
110 * @return The {@link StandardPlural} according to the PluralRules. If the plu
ral form is not in | 118 * @return The {@link StandardPlural} according to the PluralRules. If the plu
ral form is not in |
111 * the set of standard plurals, {@link StandardPlural#OTHER} is returned i
nstead. | 119 * the set of standard plurals, {@link StandardPlural#OTHER} is returned i
nstead. |
112 */ | 120 */ |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 177 |
170 /** | 178 /** |
171 * Like clone, but without the restrictions of the Cloneable interface clone. | 179 * Like clone, but without the restrictions of the Cloneable interface clone. |
172 * | 180 * |
173 * @return A copy of this instance which can be mutated without affecting this
instance. | 181 * @return A copy of this instance which can be mutated without affecting this
instance. |
174 */ | 182 */ |
175 public FormatQuantity createCopy(); | 183 public FormatQuantity createCopy(); |
176 | 184 |
177 public void copyFrom(FormatQuantity other); | 185 public void copyFrom(FormatQuantity other); |
178 | 186 |
179 /** | 187 /** This method is for internal testing only. */ |
180 * This method is for internal testing only. | |
181 */ | |
182 public long getPositionFingerprint(); | 188 public long getPositionFingerprint(); |
183 } | 189 } |
OLD | NEW |