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.DecimalFormatProperties; |
5 import com.ibm.icu.impl.number.DecimalQuantity; | 6 import com.ibm.icu.impl.number.DecimalQuantity; |
6 import com.ibm.icu.impl.number.PatternStringParser.ParsedPatternInfo; | 7 import com.ibm.icu.impl.number.PatternStringParser.ParsedPatternInfo; |
7 | 8 |
8 /** | 9 /** |
9 * @internal | 10 * @internal |
10 * @deprecated This API is a technical preview. It is likely to change in an upc
oming release. | 11 * @deprecated This API is a technical preview. It is likely to change in an upc
oming release. |
11 */ | 12 */ |
12 @Deprecated | 13 @Deprecated |
13 public class Grouper { | 14 public class Grouper { |
14 | 15 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 return GROUPING_3_2; | 78 return GROUPING_3_2; |
78 } else if (min2 && grouping1 == 3 && grouping2 == 3) { | 79 } else if (min2 && grouping1 == 3 && grouping2 == 3) { |
79 return GROUPING_3_MIN2; | 80 return GROUPING_3_MIN2; |
80 } else if (min2 && grouping1 == 3 && grouping2 == 2) { | 81 } else if (min2 && grouping1 == 3 && grouping2 == 2) { |
81 return GROUPING_3_2_MIN2; | 82 return GROUPING_3_2_MIN2; |
82 } else { | 83 } else { |
83 return new Grouper(grouping1, grouping2, min2); | 84 return new Grouper(grouping1, grouping2, min2); |
84 } | 85 } |
85 } | 86 } |
86 | 87 |
87 Grouper withLocaleData(ParsedPatternInfo patternInfo) { | 88 /** |
| 89 * @internal |
| 90 * @deprecated This API is ICU internal only. |
| 91 */ |
| 92 @Deprecated |
| 93 public Grouper withProperties(DecimalFormatProperties properties) { |
| 94 if (grouping1 != -2) { |
| 95 return this; |
| 96 } |
| 97 byte grouping1 = (byte) properties.getGroupingSize(); |
| 98 byte grouping2 = (byte) properties.getSecondaryGroupingSize(); |
| 99 int minGrouping = properties.getMinimumGroupingDigits(); |
| 100 grouping1 = grouping1 > 0 ? grouping1 : grouping2 > 0 ? grouping2 : -1; |
| 101 grouping2 = grouping2 > 0 ? grouping2 : grouping1; |
| 102 // TODO: Is it important to handle minGrouping > 2? |
| 103 return getInstance(grouping1, grouping2, minGrouping == 2); |
| 104 } |
| 105 |
| 106 /** |
| 107 * @internal |
| 108 * @deprecated This API is ICU internal only. |
| 109 */ |
| 110 @Deprecated |
| 111 public Grouper withLocaleData(ParsedPatternInfo patternInfo) { |
88 if (grouping1 != -2) { | 112 if (grouping1 != -2) { |
89 return this; | 113 return this; |
90 } | 114 } |
91 // TODO: short or byte? | 115 // TODO: short or byte? |
92 byte grouping1 = (byte) (patternInfo.positive.groupingSizes & 0xffff); | 116 byte grouping1 = (byte) (patternInfo.positive.groupingSizes & 0xffff); |
93 byte grouping2 = (byte) ((patternInfo.positive.groupingSizes >>> 16) & 0
xffff); | 117 byte grouping2 = (byte) ((patternInfo.positive.groupingSizes >>> 16) & 0
xffff); |
94 byte grouping3 = (byte) ((patternInfo.positive.groupingSizes >>> 32) & 0
xffff); | 118 byte grouping3 = (byte) ((patternInfo.positive.groupingSizes >>> 32) & 0
xffff); |
95 if (grouping2 == -1) { | 119 if (grouping2 == -1) { |
96 grouping1 = -1; | 120 grouping1 = -1; |
97 } | 121 } |
98 if (grouping3 == -1) { | 122 if (grouping3 == -1) { |
99 grouping2 = grouping1; | 123 grouping2 = grouping1; |
100 } | 124 } |
101 return getInstance(grouping1, grouping2, min2); | 125 return getInstance(grouping1, grouping2, min2); |
102 } | 126 } |
103 | 127 |
104 boolean groupAtPosition(int position, DecimalQuantity value) { | 128 boolean groupAtPosition(int position, DecimalQuantity value) { |
105 assert grouping1 != -2; | 129 assert grouping1 != -2; |
106 if (grouping1 == -1 || grouping1 == 0) { | 130 if (grouping1 == -1 || grouping1 == 0) { |
107 // Either -1 or 0 means "no grouping" | 131 // Either -1 or 0 means "no grouping" |
108 return false; | 132 return false; |
109 } | 133 } |
110 position -= grouping1; | 134 position -= grouping1; |
111 return position >= 0 && (position % grouping2) == 0 | 135 return position >= 0 |
| 136 && (position % grouping2) == 0 |
112 && value.getUpperDisplayMagnitude() - grouping1 + 1 >= (min2 ? 2
: 1); | 137 && value.getUpperDisplayMagnitude() - grouping1 + 1 >= (min2 ? 2
: 1); |
113 } | 138 } |
| 139 |
| 140 /** |
| 141 * @internal |
| 142 * @deprecated This API is ICU internal only. |
| 143 */ |
| 144 @Deprecated |
| 145 public byte getPrimary() { |
| 146 return grouping1; |
| 147 } |
| 148 |
| 149 /** |
| 150 * @internal |
| 151 * @deprecated This API is ICU internal only. |
| 152 */ |
| 153 @Deprecated |
| 154 public byte getSecondary() { |
| 155 return grouping2; |
| 156 } |
114 } | 157 } |
LEFT | RIGHT |