LEFT | RIGHT |
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.io.IOException; |
| 6 import java.io.ObjectInputStream; |
| 7 import java.io.ObjectOutputStream; |
| 8 import java.io.Serializable; |
5 import java.lang.reflect.Field; | 9 import java.lang.reflect.Field; |
| 10 import java.lang.reflect.Modifier; |
6 import java.math.BigDecimal; | 11 import java.math.BigDecimal; |
7 import java.math.MathContext; | 12 import java.math.MathContext; |
8 import java.math.RoundingMode; | 13 import java.math.RoundingMode; |
| 14 import java.util.ArrayList; |
9 | 15 |
10 import com.ibm.icu.impl.number.Parse.ParseMode; | 16 import com.ibm.icu.impl.number.Parse.ParseMode; |
11 import com.ibm.icu.impl.number.formatters.BigDecimalMultiplier; | 17 import com.ibm.icu.impl.number.formatters.BigDecimalMultiplier; |
12 import com.ibm.icu.impl.number.formatters.CompactDecimalFormat; | 18 import com.ibm.icu.impl.number.formatters.CompactDecimalFormat; |
13 import com.ibm.icu.impl.number.formatters.CurrencyFormat; | 19 import com.ibm.icu.impl.number.formatters.CurrencyFormat; |
14 import com.ibm.icu.impl.number.formatters.CurrencyFormat.CurrencyStyle; | 20 import com.ibm.icu.impl.number.formatters.CurrencyFormat.CurrencyStyle; |
15 import com.ibm.icu.impl.number.formatters.MagnitudeMultiplier; | 21 import com.ibm.icu.impl.number.formatters.MagnitudeMultiplier; |
16 import com.ibm.icu.impl.number.formatters.MeasureFormat; | 22 import com.ibm.icu.impl.number.formatters.MeasureFormat; |
17 import com.ibm.icu.impl.number.formatters.PaddingFormat; | 23 import com.ibm.icu.impl.number.formatters.PaddingFormat; |
18 import com.ibm.icu.impl.number.formatters.PaddingFormat.PaddingLocation; | 24 import com.ibm.icu.impl.number.formatters.PaddingFormat.PadPosition; |
19 import com.ibm.icu.impl.number.formatters.PositiveDecimalFormat; | 25 import com.ibm.icu.impl.number.formatters.PositiveDecimalFormat; |
20 import com.ibm.icu.impl.number.formatters.PositiveNegativeAffixFormat; | 26 import com.ibm.icu.impl.number.formatters.PositiveNegativeAffixFormat; |
21 import com.ibm.icu.impl.number.formatters.ScientificFormat; | 27 import com.ibm.icu.impl.number.formatters.ScientificFormat; |
22 import com.ibm.icu.impl.number.rounders.IntervalRounder; | 28 import com.ibm.icu.impl.number.rounders.IncrementRounder; |
23 import com.ibm.icu.impl.number.rounders.MagnitudeRounder; | 29 import com.ibm.icu.impl.number.rounders.MagnitudeRounder; |
24 import com.ibm.icu.impl.number.rounders.SignificantDigitsRounder; | 30 import com.ibm.icu.impl.number.rounders.SignificantDigitsRounder; |
25 import com.ibm.icu.impl.number.rounders.SignificantDigitsRounder.SignificantDigi
tsMode; | 31 import com.ibm.icu.impl.number.rounders.SignificantDigitsRounder.SignificantDigi
tsMode; |
26 import com.ibm.icu.text.CompactDecimalFormat.CompactStyle; | 32 import com.ibm.icu.text.CompactDecimalFormat.CompactStyle; |
27 import com.ibm.icu.text.CurrencyPluralInfo; | 33 import com.ibm.icu.text.CurrencyPluralInfo; |
28 import com.ibm.icu.text.MeasureFormat.FormatWidth; | 34 import com.ibm.icu.text.MeasureFormat.FormatWidth; |
29 import com.ibm.icu.util.Currency; | 35 import com.ibm.icu.util.Currency; |
30 import com.ibm.icu.util.Currency.CurrencyUsage; | 36 import com.ibm.icu.util.Currency.CurrencyUsage; |
31 import com.ibm.icu.util.MeasureUnit; | 37 import com.ibm.icu.util.MeasureUnit; |
32 | 38 |
33 public class Properties | 39 public class Properties |
34 implements Cloneable, | 40 implements Cloneable, |
| 41 Serializable, |
35 PositiveDecimalFormat.IProperties, | 42 PositiveDecimalFormat.IProperties, |
36 PositiveNegativeAffixFormat.IProperties, | 43 PositiveNegativeAffixFormat.IProperties, |
37 MagnitudeMultiplier.IProperties, | 44 MagnitudeMultiplier.IProperties, |
38 ScientificFormat.IProperties, | 45 ScientificFormat.IProperties, |
39 MeasureFormat.IProperties, | 46 MeasureFormat.IProperties, |
40 CompactDecimalFormat.IProperties, | 47 CompactDecimalFormat.IProperties, |
41 PaddingFormat.IProperties, | 48 PaddingFormat.IProperties, |
42 BigDecimalMultiplier.IProperties, | 49 BigDecimalMultiplier.IProperties, |
43 CurrencyFormat.IProperties, | 50 CurrencyFormat.IProperties, |
44 Parse.IProperties, | 51 Parse.IProperties, |
45 IntervalRounder.IProperties, | 52 IncrementRounder.IProperties, |
46 MagnitudeRounder.IProperties, | 53 MagnitudeRounder.IProperties, |
47 SignificantDigitsRounder.IProperties { | 54 SignificantDigitsRounder.IProperties { |
48 | 55 |
49 private static final Properties DEFAULT = new Properties(); | 56 private static final Properties DEFAULT = new Properties(); |
50 | 57 |
51 // TODO: Change all the CharSequence types to immutable Strings? | 58 /** Auto-generated. */ |
52 // This would also require either retiring CurrencyPluralInfo or copying it up
on receipt. | 59 private static final long serialVersionUID = 4095518955889349243L; |
53 // These two changes would make all fields in Properties immutable. | |
54 | 60 |
55 // The setters in this class should NOT have any side-effects or perform any v
alidation. It is | 61 // The setters in this class should NOT have any side-effects or perform any v
alidation. It is |
56 // up to the consumer of the property bag to deal with property validation. | 62 // up to the consumer of the property bag to deal with property validation. |
| 63 |
| 64 // The fields are all marked "transient" because custom serialization is being
used. |
57 | 65 |
58 /*----------------------------------------------------------------------------
----------------+/ | 66 /*----------------------------------------------------------------------------
----------------+/ |
59 /| IMPORTANT!
|/ | 67 /| IMPORTANT!
|/ |
60 /| WHEN ADDING A NEW PROPERTY, add it here, in #_clear(), in #_copyFrom(), in
#equals(), |/ | 68 /| WHEN ADDING A NEW PROPERTY, add it here, in #_clear(), in #_copyFrom(), in
#equals(), |/ |
61 /| and in #_hashCode().
|/ | 69 /| and in #_hashCode().
|/ |
62 /|
|/ | 70 /|
|/ |
63 /| The unit test PropertiesTest will catch if you forget to add it to #clear()
, #copyFrom(), |/ | 71 /| The unit test PropertiesTest will catch if you forget to add it to #clear()
, #copyFrom(), |/ |
64 /| or #equals(), but it will NOT catch if you forget to add it to #hashCode().
|/ | 72 /| or #equals(), but it will NOT catch if you forget to add it to #hashCode().
|/ |
65 /+----------------------------------------------------------------------------
----------------*/ | 73 /+----------------------------------------------------------------------------
----------------*/ |
66 | 74 |
67 private boolean alwaysShowDecimal; | 75 private transient CompactStyle compactStyle; |
68 private boolean alwaysShowPlusSign; | 76 private transient Currency currency; |
69 private CompactStyle compactStyle; | 77 private transient CurrencyPluralInfo currencyPluralInfo; |
70 private Currency currency; | 78 private transient CurrencyStyle currencyStyle; |
71 private CurrencyPluralInfo currencyPluralInfo; | 79 private transient CurrencyUsage currencyUsage; |
72 private CurrencyStyle currencyStyle; | 80 private transient boolean decimalPatternMatchRequired; |
73 private CurrencyUsage currencyUsage; | 81 private transient boolean decimalSeparatorAlwaysShown; |
74 private boolean decimalPatternMatchRequired; | 82 private transient boolean exponentSignAlwaysShown; |
75 private int exponentDigits; | 83 private transient int formatWidth; |
76 private boolean exponentShowPlusSign; | 84 private transient int groupingSize; |
77 private int groupingSize; | 85 private transient int magnitudeMultiplier; |
78 private int magnitudeMultiplier; | 86 private transient MathContext mathContext; |
79 private MathContext mathContext; | 87 private transient int maximumFractionDigits; |
80 private int maximumFractionDigits; | 88 private transient int maximumIntegerDigits; |
81 private int maximumIntegerDigits; | 89 private transient int maximumSignificantDigits; |
82 private int maximumSignificantDigits; | 90 private transient FormatWidth measureFormatWidth; |
83 private FormatWidth measureFormatWidth; | 91 private transient MeasureUnit measureUnit; |
84 private MeasureUnit measureUnit; | 92 private transient int minimumExponentDigits; |
85 private int minimumFractionDigits; | 93 private transient int minimumFractionDigits; |
86 private int minimumGroupingDigits; | 94 private transient int minimumGroupingDigits; |
87 private int minimumIntegerDigits; | 95 private transient int minimumIntegerDigits; |
88 private int minimumSignificantDigits; | 96 private transient int minimumSignificantDigits; |
89 private BigDecimal multiplier; | 97 private transient BigDecimal multiplier; |
90 private CharSequence negativePrefix; | 98 private transient String negativePrefix; |
91 private CharSequence negativePrefixPattern; | 99 private transient String negativePrefixPattern; |
92 private CharSequence negativeSuffix; | 100 private transient String negativeSuffix; |
93 private CharSequence negativeSuffixPattern; | 101 private transient String negativeSuffixPattern; |
94 private PaddingLocation paddingLocation; | 102 private transient PadPosition padPosition; |
95 private CharSequence paddingString; | 103 private transient String padString; |
96 private int paddingWidth; | 104 private transient boolean parseCaseSensitive; |
97 // private boolean parseCurrency; | 105 private transient boolean parseNoExponent; |
98 private boolean parseCaseSensitive; | 106 private transient boolean parseIntegerOnly; |
99 private boolean parseIgnoreExponent; | 107 private transient ParseMode parseMode; |
100 private boolean parseIntegerOnly; | 108 private transient boolean parseToBigDecimal; |
101 private ParseMode parseMode; | 109 private transient boolean plusSignAlwaysShown; |
102 private boolean parseToBigDecimal; | 110 private transient String positivePrefix; |
103 private CharSequence positivePrefix; | 111 private transient String positivePrefixPattern; |
104 private CharSequence positivePrefixPattern; | 112 private transient String positiveSuffix; |
105 private CharSequence positiveSuffix; | 113 private transient String positiveSuffixPattern; |
106 private CharSequence positiveSuffixPattern; | 114 private transient BigDecimal roundingIncrement; |
107 private BigDecimal roundingInterval; | 115 private transient RoundingMode roundingMode; |
108 private RoundingMode roundingMode; | 116 private transient int secondaryGroupingSize; |
109 private int secondaryGroupingSize; | 117 private transient SignificantDigitsMode significantDigitsMode; |
110 private SignificantDigitsMode significantDigitsMode; | |
111 | 118 |
112 /*----------------------------------------------------------------------------
----------------+/ | 119 /*----------------------------------------------------------------------------
----------------+/ |
113 /| IMPORTANT!
|/ | 120 /| IMPORTANT!
|/ |
114 /| WHEN ADDING A NEW PROPERTY, add it here, in #_clear(), in #_copyFrom(), in
#equals(), |/ | 121 /| WHEN ADDING A NEW PROPERTY, add it here, in #_clear(), in #_copyFrom(), in
#equals(), |/ |
115 /| and in #_hashCode().
|/ | 122 /| and in #_hashCode().
|/ |
116 /|
|/ | 123 /|
|/ |
117 /| The unit test PropertiesTest will catch if you forget to add it to #clear()
, #copyFrom(), |/ | 124 /| The unit test PropertiesTest will catch if you forget to add it to #clear()
, #copyFrom(), |/ |
118 /| or #equals(), but it will NOT catch if you forget to add it to #hashCode().
|/ | 125 /| or #equals(), but it will NOT catch if you forget to add it to #hashCode().
|/ |
119 /+----------------------------------------------------------------------------
----------------*/ | 126 /+----------------------------------------------------------------------------
----------------*/ |
120 | 127 |
121 public Properties() { | 128 public Properties() { |
122 clear(); | 129 clear(); |
123 } | 130 } |
124 | 131 |
125 private Properties _clear() { | 132 private Properties _clear() { |
126 alwaysShowDecimal = DEFAULT_ALWAYS_SHOW_DECIMAL; | |
127 alwaysShowPlusSign = DEFAULT_ALWAYS_SHOW_PLUS_SIGN; | |
128 compactStyle = DEFAULT_COMPACT_STYLE; | 133 compactStyle = DEFAULT_COMPACT_STYLE; |
129 currency = DEFAULT_CURRENCY; | 134 currency = DEFAULT_CURRENCY; |
130 currencyPluralInfo = DEFAULT_CURRENCY_PLURAL_INFO; | 135 currencyPluralInfo = DEFAULT_CURRENCY_PLURAL_INFO; |
131 currencyStyle = DEFAULT_CURRENCY_STYLE; | 136 currencyStyle = DEFAULT_CURRENCY_STYLE; |
132 currencyUsage = DEFAULT_CURRENCY_USAGE; | 137 currencyUsage = DEFAULT_CURRENCY_USAGE; |
133 decimalPatternMatchRequired = DEFAULT_DECIMAL_PATTERN_MATCH_REQUIRED; | 138 decimalPatternMatchRequired = DEFAULT_DECIMAL_PATTERN_MATCH_REQUIRED; |
134 exponentDigits = DEFAULT_EXPONENT_DIGITS; | 139 decimalSeparatorAlwaysShown = DEFAULT_DECIMAL_SEPARATOR_ALWAYS_SHOWN; |
135 exponentShowPlusSign = DEFAULT_EXPONENT_SHOW_PLUS_SIGN; | 140 exponentSignAlwaysShown = DEFAULT_EXPONENT_SIGN_ALWAYS_SHOWN; |
| 141 formatWidth = DEFAULT_FORMAT_WIDTH; |
136 groupingSize = DEFAULT_GROUPING_SIZE; | 142 groupingSize = DEFAULT_GROUPING_SIZE; |
137 magnitudeMultiplier = DEFAULT_MAGNITUDE_MULTIPLIER; | 143 magnitudeMultiplier = DEFAULT_MAGNITUDE_MULTIPLIER; |
138 mathContext = DEFAULT_MATH_CONTEXT; | 144 mathContext = DEFAULT_MATH_CONTEXT; |
139 maximumFractionDigits = DEFAULT_MAXIMUM_FRACTION_DIGITS; | 145 maximumFractionDigits = DEFAULT_MAXIMUM_FRACTION_DIGITS; |
140 maximumIntegerDigits = DEFAULT_MAXIMUM_INTEGER_DIGITS; | 146 maximumIntegerDigits = DEFAULT_MAXIMUM_INTEGER_DIGITS; |
141 maximumSignificantDigits = DEFAULT_MAXIMUM_SIGNIFICANT_DIGITS; | 147 maximumSignificantDigits = DEFAULT_MAXIMUM_SIGNIFICANT_DIGITS; |
142 measureFormatWidth = DEFAULT_MEASURE_FORMAT_WIDTH; | 148 measureFormatWidth = DEFAULT_MEASURE_FORMAT_WIDTH; |
143 measureUnit = DEFAULT_MEASURE_UNIT; | 149 measureUnit = DEFAULT_MEASURE_UNIT; |
| 150 minimumExponentDigits = DEFAULT_MINIMUM_EXPONENT_DIGITS; |
144 minimumFractionDigits = DEFAULT_MINIMUM_FRACTION_DIGITS; | 151 minimumFractionDigits = DEFAULT_MINIMUM_FRACTION_DIGITS; |
145 minimumGroupingDigits = DEFAULT_MINIMUM_GROUPING_DIGITS; | 152 minimumGroupingDigits = DEFAULT_MINIMUM_GROUPING_DIGITS; |
146 minimumIntegerDigits = DEFAULT_MINIMUM_INTEGER_DIGITS; | 153 minimumIntegerDigits = DEFAULT_MINIMUM_INTEGER_DIGITS; |
147 minimumSignificantDigits = DEFAULT_MINIMUM_SIGNIFICANT_DIGITS; | 154 minimumSignificantDigits = DEFAULT_MINIMUM_SIGNIFICANT_DIGITS; |
148 multiplier = DEFAULT_MULTIPLIER; | 155 multiplier = DEFAULT_MULTIPLIER; |
149 negativePrefix = DEFAULT_NEGATIVE_PREFIX; | 156 negativePrefix = DEFAULT_NEGATIVE_PREFIX; |
150 negativePrefixPattern = DEFAULT_NEGATIVE_PREFIX_PATTERN; | 157 negativePrefixPattern = DEFAULT_NEGATIVE_PREFIX_PATTERN; |
151 negativeSuffix = DEFAULT_NEGATIVE_SUFFIX; | 158 negativeSuffix = DEFAULT_NEGATIVE_SUFFIX; |
152 negativeSuffixPattern = DEFAULT_NEGATIVE_SUFFIX_PATTERN; | 159 negativeSuffixPattern = DEFAULT_NEGATIVE_SUFFIX_PATTERN; |
153 paddingLocation = DEFAULT_PADDING_LOCATION; | 160 padPosition = DEFAULT_PAD_POSITION; |
154 paddingString = DEFAULT_PADDING_STRING; | 161 padString = DEFAULT_PAD_STRING; |
155 paddingWidth = DEFAULT_PADDING_WIDTH; | |
156 // parseCurrency = DEFAULT_PARSE_CURRENCY; | |
157 parseCaseSensitive = DEFAULT_PARSE_CASE_SENSITIVE; | 162 parseCaseSensitive = DEFAULT_PARSE_CASE_SENSITIVE; |
158 parseIgnoreExponent = DEFAULT_PARSE_IGNORE_EXPONENT; | |
159 parseIntegerOnly = DEFAULT_PARSE_INTEGER_ONLY; | 163 parseIntegerOnly = DEFAULT_PARSE_INTEGER_ONLY; |
160 parseMode = DEFAULT_PARSE_MODE; | 164 parseMode = DEFAULT_PARSE_MODE; |
| 165 parseNoExponent = DEFAULT_PARSE_NO_EXPONENT; |
161 parseToBigDecimal = DEFAULT_PARSE_TO_BIG_DECIMAL; | 166 parseToBigDecimal = DEFAULT_PARSE_TO_BIG_DECIMAL; |
| 167 plusSignAlwaysShown = DEFAULT_PLUS_SIGN_ALWAYS_SHOWN; |
162 positivePrefix = DEFAULT_POSITIVE_PREFIX; | 168 positivePrefix = DEFAULT_POSITIVE_PREFIX; |
163 positivePrefixPattern = DEFAULT_POSITIVE_PREFIX_PATTERN; | 169 positivePrefixPattern = DEFAULT_POSITIVE_PREFIX_PATTERN; |
164 positiveSuffix = DEFAULT_POSITIVE_SUFFIX; | 170 positiveSuffix = DEFAULT_POSITIVE_SUFFIX; |
165 positiveSuffixPattern = DEFAULT_POSITIVE_SUFFIX_PATTERN; | 171 positiveSuffixPattern = DEFAULT_POSITIVE_SUFFIX_PATTERN; |
166 roundingInterval = DEFAULT_ROUNDING_INTERVAL; | 172 roundingIncrement = DEFAULT_ROUNDING_INCREMENT; |
167 roundingMode = DEFAULT_ROUNDING_MODE; | 173 roundingMode = DEFAULT_ROUNDING_MODE; |
168 secondaryGroupingSize = DEFAULT_SECONDARY_GROUPING_SIZE; | 174 secondaryGroupingSize = DEFAULT_SECONDARY_GROUPING_SIZE; |
169 significantDigitsMode = DEFAULT_SIGNIFICANT_DIGITS_MODE; | 175 significantDigitsMode = DEFAULT_SIGNIFICANT_DIGITS_MODE; |
170 return this; | 176 return this; |
171 } | 177 } |
172 | 178 |
173 private Properties _copyFrom(Properties other) { | 179 private Properties _copyFrom(Properties other) { |
174 alwaysShowDecimal = other.alwaysShowDecimal; | |
175 alwaysShowPlusSign = other.alwaysShowPlusSign; | |
176 compactStyle = other.compactStyle; | 180 compactStyle = other.compactStyle; |
177 currency = other.currency; | 181 currency = other.currency; |
178 currencyPluralInfo = other.currencyPluralInfo; | 182 currencyPluralInfo = other.currencyPluralInfo; |
179 currencyStyle = other.currencyStyle; | 183 currencyStyle = other.currencyStyle; |
180 currencyUsage = other.currencyUsage; | 184 currencyUsage = other.currencyUsage; |
181 decimalPatternMatchRequired = other.decimalPatternMatchRequired; | 185 decimalPatternMatchRequired = other.decimalPatternMatchRequired; |
182 exponentDigits = other.exponentDigits; | 186 decimalSeparatorAlwaysShown = other.decimalSeparatorAlwaysShown; |
183 exponentShowPlusSign = other.exponentShowPlusSign; | 187 exponentSignAlwaysShown = other.exponentSignAlwaysShown; |
| 188 formatWidth = other.formatWidth; |
184 groupingSize = other.groupingSize; | 189 groupingSize = other.groupingSize; |
185 magnitudeMultiplier = other.magnitudeMultiplier; | 190 magnitudeMultiplier = other.magnitudeMultiplier; |
186 mathContext = other.mathContext; | 191 mathContext = other.mathContext; |
187 maximumFractionDigits = other.maximumFractionDigits; | 192 maximumFractionDigits = other.maximumFractionDigits; |
188 maximumIntegerDigits = other.maximumIntegerDigits; | 193 maximumIntegerDigits = other.maximumIntegerDigits; |
189 maximumSignificantDigits = other.maximumSignificantDigits; | 194 maximumSignificantDigits = other.maximumSignificantDigits; |
190 measureFormatWidth = other.measureFormatWidth; | 195 measureFormatWidth = other.measureFormatWidth; |
191 measureUnit = other.measureUnit; | 196 measureUnit = other.measureUnit; |
| 197 minimumExponentDigits = other.minimumExponentDigits; |
192 minimumFractionDigits = other.minimumFractionDigits; | 198 minimumFractionDigits = other.minimumFractionDigits; |
193 minimumGroupingDigits = other.minimumGroupingDigits; | 199 minimumGroupingDigits = other.minimumGroupingDigits; |
194 minimumIntegerDigits = other.minimumIntegerDigits; | 200 minimumIntegerDigits = other.minimumIntegerDigits; |
195 minimumSignificantDigits = other.minimumSignificantDigits; | 201 minimumSignificantDigits = other.minimumSignificantDigits; |
196 multiplier = other.multiplier; | 202 multiplier = other.multiplier; |
197 negativePrefix = other.negativePrefix; | 203 negativePrefix = other.negativePrefix; |
198 negativePrefixPattern = other.negativePrefixPattern; | 204 negativePrefixPattern = other.negativePrefixPattern; |
199 negativeSuffix = other.negativeSuffix; | 205 negativeSuffix = other.negativeSuffix; |
200 negativeSuffixPattern = other.negativeSuffixPattern; | 206 negativeSuffixPattern = other.negativeSuffixPattern; |
201 paddingLocation = other.paddingLocation; | 207 padPosition = other.padPosition; |
202 paddingString = other.paddingString; | 208 padString = other.padString; |
203 paddingWidth = other.paddingWidth; | |
204 parseCaseSensitive = other.parseCaseSensitive; | 209 parseCaseSensitive = other.parseCaseSensitive; |
205 parseIgnoreExponent = other.parseIgnoreExponent; | |
206 parseIntegerOnly = other.parseIntegerOnly; | 210 parseIntegerOnly = other.parseIntegerOnly; |
207 parseMode = other.parseMode; | 211 parseMode = other.parseMode; |
| 212 parseNoExponent = other.parseNoExponent; |
208 parseToBigDecimal = other.parseToBigDecimal; | 213 parseToBigDecimal = other.parseToBigDecimal; |
| 214 plusSignAlwaysShown = other.plusSignAlwaysShown; |
209 positivePrefix = other.positivePrefix; | 215 positivePrefix = other.positivePrefix; |
210 positivePrefixPattern = other.positivePrefixPattern; | 216 positivePrefixPattern = other.positivePrefixPattern; |
211 positiveSuffix = other.positiveSuffix; | 217 positiveSuffix = other.positiveSuffix; |
212 positiveSuffixPattern = other.positiveSuffixPattern; | 218 positiveSuffixPattern = other.positiveSuffixPattern; |
213 roundingInterval = other.roundingInterval; | 219 roundingIncrement = other.roundingIncrement; |
214 roundingMode = other.roundingMode; | 220 roundingMode = other.roundingMode; |
215 secondaryGroupingSize = other.secondaryGroupingSize; | 221 secondaryGroupingSize = other.secondaryGroupingSize; |
216 significantDigitsMode = other.significantDigitsMode; | 222 significantDigitsMode = other.significantDigitsMode; |
217 return this; | 223 return this; |
218 } | 224 } |
219 | 225 |
220 private boolean _equals(Properties other) { | 226 private boolean _equals(Properties other) { |
221 boolean eq = true; | 227 boolean eq = true; |
222 eq = eq && _equalsHelper(alwaysShowDecimal, other.alwaysShowDecimal); | |
223 eq = eq && _equalsHelper(alwaysShowPlusSign, other.alwaysShowPlusSign); | |
224 eq = eq && _equalsHelper(compactStyle, other.compactStyle); | 228 eq = eq && _equalsHelper(compactStyle, other.compactStyle); |
225 eq = eq && _equalsHelper(currency, other.currency); | 229 eq = eq && _equalsHelper(currency, other.currency); |
226 eq = eq && _equalsHelper(currencyPluralInfo, other.currencyPluralInfo); | 230 eq = eq && _equalsHelper(currencyPluralInfo, other.currencyPluralInfo); |
227 eq = eq && _equalsHelper(currencyStyle, other.currencyStyle); | 231 eq = eq && _equalsHelper(currencyStyle, other.currencyStyle); |
228 eq = eq && _equalsHelper(currencyUsage, other.currencyUsage); | 232 eq = eq && _equalsHelper(currencyUsage, other.currencyUsage); |
229 eq = eq && _equalsHelper(decimalPatternMatchRequired, other.decimalPatternMa
tchRequired); | 233 eq = eq && _equalsHelper(decimalPatternMatchRequired, other.decimalPatternMa
tchRequired); |
230 eq = eq && _equalsHelper(exponentDigits, other.exponentDigits); | 234 eq = eq && _equalsHelper(decimalSeparatorAlwaysShown, other.decimalSeparator
AlwaysShown); |
231 eq = eq && _equalsHelper(exponentShowPlusSign, other.exponentShowPlusSign); | 235 eq = eq && _equalsHelper(exponentSignAlwaysShown, other.exponentSignAlwaysSh
own); |
| 236 eq = eq && _equalsHelper(formatWidth, other.formatWidth); |
232 eq = eq && _equalsHelper(groupingSize, other.groupingSize); | 237 eq = eq && _equalsHelper(groupingSize, other.groupingSize); |
233 eq = eq && _equalsHelper(magnitudeMultiplier, other.magnitudeMultiplier); | 238 eq = eq && _equalsHelper(magnitudeMultiplier, other.magnitudeMultiplier); |
234 eq = eq && _equalsHelper(mathContext, other.mathContext); | 239 eq = eq && _equalsHelper(mathContext, other.mathContext); |
235 eq = eq && _equalsHelper(maximumFractionDigits, other.maximumFractionDigits)
; | 240 eq = eq && _equalsHelper(maximumFractionDigits, other.maximumFractionDigits)
; |
236 eq = eq && _equalsHelper(maximumIntegerDigits, other.maximumIntegerDigits); | 241 eq = eq && _equalsHelper(maximumIntegerDigits, other.maximumIntegerDigits); |
237 eq = eq && _equalsHelper(maximumSignificantDigits, other.maximumSignificantD
igits); | 242 eq = eq && _equalsHelper(maximumSignificantDigits, other.maximumSignificantD
igits); |
238 eq = eq && _equalsHelper(measureFormatWidth, other.measureFormatWidth); | 243 eq = eq && _equalsHelper(measureFormatWidth, other.measureFormatWidth); |
239 eq = eq && _equalsHelper(measureUnit, other.measureUnit); | 244 eq = eq && _equalsHelper(measureUnit, other.measureUnit); |
| 245 eq = eq && _equalsHelper(minimumExponentDigits, other.minimumExponentDigits)
; |
240 eq = eq && _equalsHelper(minimumFractionDigits, other.minimumFractionDigits)
; | 246 eq = eq && _equalsHelper(minimumFractionDigits, other.minimumFractionDigits)
; |
241 eq = eq && _equalsHelper(minimumGroupingDigits, other.minimumGroupingDigits)
; | 247 eq = eq && _equalsHelper(minimumGroupingDigits, other.minimumGroupingDigits)
; |
242 eq = eq && _equalsHelper(minimumIntegerDigits, other.minimumIntegerDigits); | 248 eq = eq && _equalsHelper(minimumIntegerDigits, other.minimumIntegerDigits); |
243 eq = eq && _equalsHelper(minimumSignificantDigits, other.minimumSignificantD
igits); | 249 eq = eq && _equalsHelper(minimumSignificantDigits, other.minimumSignificantD
igits); |
244 eq = eq && _equalsHelper(multiplier, other.multiplier); | 250 eq = eq && _equalsHelper(multiplier, other.multiplier); |
245 eq = eq && _equalsHelper(negativePrefix, other.negativePrefix); | 251 eq = eq && _equalsHelper(negativePrefix, other.negativePrefix); |
246 eq = eq && _equalsHelper(negativePrefixPattern, other.negativePrefixPattern)
; | 252 eq = eq && _equalsHelper(negativePrefixPattern, other.negativePrefixPattern)
; |
247 eq = eq && _equalsHelper(negativeSuffix, other.negativeSuffix); | 253 eq = eq && _equalsHelper(negativeSuffix, other.negativeSuffix); |
248 eq = eq && _equalsHelper(negativeSuffixPattern, other.negativeSuffixPattern)
; | 254 eq = eq && _equalsHelper(negativeSuffixPattern, other.negativeSuffixPattern)
; |
249 eq = eq && _equalsHelper(paddingLocation, other.paddingLocation); | 255 eq = eq && _equalsHelper(padPosition, other.padPosition); |
250 eq = eq && _equalsHelper(paddingString, other.paddingString); | 256 eq = eq && _equalsHelper(padString, other.padString); |
251 eq = eq && _equalsHelper(paddingWidth, other.paddingWidth); | |
252 // eq = eq && _equalsHelper(parseCurrency, other.parseCurrency); | |
253 eq = eq && _equalsHelper(parseCaseSensitive, other.parseCaseSensitive); | 257 eq = eq && _equalsHelper(parseCaseSensitive, other.parseCaseSensitive); |
254 eq = eq && _equalsHelper(parseIgnoreExponent, other.parseIgnoreExponent); | |
255 eq = eq && _equalsHelper(parseIntegerOnly, other.parseIntegerOnly); | 258 eq = eq && _equalsHelper(parseIntegerOnly, other.parseIntegerOnly); |
256 eq = eq && _equalsHelper(parseMode, other.parseMode); | 259 eq = eq && _equalsHelper(parseMode, other.parseMode); |
| 260 eq = eq && _equalsHelper(parseNoExponent, other.parseNoExponent); |
257 eq = eq && _equalsHelper(parseToBigDecimal, other.parseToBigDecimal); | 261 eq = eq && _equalsHelper(parseToBigDecimal, other.parseToBigDecimal); |
| 262 eq = eq && _equalsHelper(plusSignAlwaysShown, other.plusSignAlwaysShown); |
258 eq = eq && _equalsHelper(positivePrefix, other.positivePrefix); | 263 eq = eq && _equalsHelper(positivePrefix, other.positivePrefix); |
259 eq = eq && _equalsHelper(positivePrefixPattern, other.positivePrefixPattern)
; | 264 eq = eq && _equalsHelper(positivePrefixPattern, other.positivePrefixPattern)
; |
260 eq = eq && _equalsHelper(positiveSuffix, other.positiveSuffix); | 265 eq = eq && _equalsHelper(positiveSuffix, other.positiveSuffix); |
261 eq = eq && _equalsHelper(positiveSuffixPattern, other.positiveSuffixPattern)
; | 266 eq = eq && _equalsHelper(positiveSuffixPattern, other.positiveSuffixPattern)
; |
262 eq = eq && _equalsHelper(roundingInterval, other.roundingInterval); | 267 eq = eq && _equalsHelper(roundingIncrement, other.roundingIncrement); |
263 eq = eq && _equalsHelper(roundingMode, other.roundingMode); | 268 eq = eq && _equalsHelper(roundingMode, other.roundingMode); |
264 eq = eq && _equalsHelper(secondaryGroupingSize, other.secondaryGroupingSize)
; | 269 eq = eq && _equalsHelper(secondaryGroupingSize, other.secondaryGroupingSize)
; |
265 eq = eq && _equalsHelper(significantDigitsMode, other.significantDigitsMode)
; | 270 eq = eq && _equalsHelper(significantDigitsMode, other.significantDigitsMode)
; |
266 return eq; | 271 return eq; |
267 } | 272 } |
268 | 273 |
269 private boolean _equalsHelper(boolean mine, boolean theirs) { | 274 private boolean _equalsHelper(boolean mine, boolean theirs) { |
270 return mine == theirs; | 275 return mine == theirs; |
271 } | 276 } |
272 | 277 |
273 private boolean _equalsHelper(CharSequence mine, CharSequence theirs) { | |
274 // We have to write this helper separately from Object because the CharSeque
nce interface | |
275 // doesn't require the #equals() method to work as one would expect. | |
276 // This also allows a null CharSequence to equal an empty CharSequence. | |
277 if (mine == theirs) return true; | |
278 if (mine == null && theirs.length() != 0) return false; | |
279 if (theirs == null && mine.length() != 0) return false; | |
280 if (mine.length() != theirs.length()) return false; | |
281 for (int i = 0; i < mine.length(); i++) { | |
282 if (mine.charAt(i) != theirs.charAt(i)) return false; | |
283 } | |
284 return true; | |
285 } | |
286 | |
287 private boolean _equalsHelper(int mine, int theirs) { | 278 private boolean _equalsHelper(int mine, int theirs) { |
288 return mine == theirs; | 279 return mine == theirs; |
289 } | 280 } |
290 | 281 |
291 private boolean _equalsHelper(Object mine, Object theirs) { | 282 private boolean _equalsHelper(Object mine, Object theirs) { |
292 if (mine == theirs) return true; | 283 if (mine == theirs) return true; |
293 if (mine == null) return false; | 284 if (mine == null) return false; |
294 return mine.equals(theirs); | 285 return mine.equals(theirs); |
295 } | 286 } |
296 | 287 |
297 private int _hashCode() { | 288 private int _hashCode() { |
298 int hashCode = 0; | 289 int hashCode = 0; |
299 hashCode ^= _hashCodeHelper(alwaysShowDecimal); | |
300 hashCode ^= _hashCodeHelper(alwaysShowPlusSign); | |
301 hashCode ^= _hashCodeHelper(compactStyle); | 290 hashCode ^= _hashCodeHelper(compactStyle); |
302 hashCode ^= _hashCodeHelper(currency); | 291 hashCode ^= _hashCodeHelper(currency); |
303 hashCode ^= _hashCodeHelper(currencyPluralInfo); | 292 hashCode ^= _hashCodeHelper(currencyPluralInfo); |
304 hashCode ^= _hashCodeHelper(currencyStyle); | 293 hashCode ^= _hashCodeHelper(currencyStyle); |
305 hashCode ^= _hashCodeHelper(currencyUsage); | 294 hashCode ^= _hashCodeHelper(currencyUsage); |
306 hashCode ^= _hashCodeHelper(decimalPatternMatchRequired); | 295 hashCode ^= _hashCodeHelper(decimalPatternMatchRequired); |
307 hashCode ^= _hashCodeHelper(exponentDigits); | 296 hashCode ^= _hashCodeHelper(decimalSeparatorAlwaysShown); |
308 hashCode ^= _hashCodeHelper(exponentShowPlusSign); | 297 hashCode ^= _hashCodeHelper(exponentSignAlwaysShown); |
| 298 hashCode ^= _hashCodeHelper(formatWidth); |
309 hashCode ^= _hashCodeHelper(groupingSize); | 299 hashCode ^= _hashCodeHelper(groupingSize); |
310 hashCode ^= _hashCodeHelper(magnitudeMultiplier); | 300 hashCode ^= _hashCodeHelper(magnitudeMultiplier); |
311 hashCode ^= _hashCodeHelper(mathContext); | 301 hashCode ^= _hashCodeHelper(mathContext); |
312 hashCode ^= _hashCodeHelper(maximumFractionDigits); | 302 hashCode ^= _hashCodeHelper(maximumFractionDigits); |
313 hashCode ^= _hashCodeHelper(maximumIntegerDigits); | 303 hashCode ^= _hashCodeHelper(maximumIntegerDigits); |
314 hashCode ^= _hashCodeHelper(maximumSignificantDigits); | 304 hashCode ^= _hashCodeHelper(maximumSignificantDigits); |
315 hashCode ^= _hashCodeHelper(measureFormatWidth); | 305 hashCode ^= _hashCodeHelper(measureFormatWidth); |
316 hashCode ^= _hashCodeHelper(measureUnit); | 306 hashCode ^= _hashCodeHelper(measureUnit); |
| 307 hashCode ^= _hashCodeHelper(minimumExponentDigits); |
317 hashCode ^= _hashCodeHelper(minimumFractionDigits); | 308 hashCode ^= _hashCodeHelper(minimumFractionDigits); |
318 hashCode ^= _hashCodeHelper(minimumGroupingDigits); | 309 hashCode ^= _hashCodeHelper(minimumGroupingDigits); |
319 hashCode ^= _hashCodeHelper(minimumIntegerDigits); | 310 hashCode ^= _hashCodeHelper(minimumIntegerDigits); |
320 hashCode ^= _hashCodeHelper(minimumSignificantDigits); | 311 hashCode ^= _hashCodeHelper(minimumSignificantDigits); |
321 hashCode ^= _hashCodeHelper(multiplier); | 312 hashCode ^= _hashCodeHelper(multiplier); |
322 hashCode ^= _hashCodeHelper(negativePrefix); | 313 hashCode ^= _hashCodeHelper(negativePrefix); |
323 hashCode ^= _hashCodeHelper(negativePrefixPattern); | 314 hashCode ^= _hashCodeHelper(negativePrefixPattern); |
324 hashCode ^= _hashCodeHelper(negativeSuffix); | 315 hashCode ^= _hashCodeHelper(negativeSuffix); |
325 hashCode ^= _hashCodeHelper(negativeSuffixPattern); | 316 hashCode ^= _hashCodeHelper(negativeSuffixPattern); |
326 hashCode ^= _hashCodeHelper(paddingLocation); | 317 hashCode ^= _hashCodeHelper(padPosition); |
327 hashCode ^= _hashCodeHelper(paddingString); | 318 hashCode ^= _hashCodeHelper(padString); |
328 hashCode ^= _hashCodeHelper(paddingWidth); | |
329 // hashCode ^= _hashCodeHelper(parseCurrency); | |
330 hashCode ^= _hashCodeHelper(parseCaseSensitive); | 319 hashCode ^= _hashCodeHelper(parseCaseSensitive); |
331 hashCode ^= _hashCodeHelper(parseIgnoreExponent); | |
332 hashCode ^= _hashCodeHelper(parseIntegerOnly); | 320 hashCode ^= _hashCodeHelper(parseIntegerOnly); |
333 hashCode ^= _hashCodeHelper(parseMode); | 321 hashCode ^= _hashCodeHelper(parseMode); |
| 322 hashCode ^= _hashCodeHelper(parseNoExponent); |
334 hashCode ^= _hashCodeHelper(parseToBigDecimal); | 323 hashCode ^= _hashCodeHelper(parseToBigDecimal); |
| 324 hashCode ^= _hashCodeHelper(plusSignAlwaysShown); |
335 hashCode ^= _hashCodeHelper(positivePrefix); | 325 hashCode ^= _hashCodeHelper(positivePrefix); |
336 hashCode ^= _hashCodeHelper(positivePrefixPattern); | 326 hashCode ^= _hashCodeHelper(positivePrefixPattern); |
337 hashCode ^= _hashCodeHelper(positiveSuffix); | 327 hashCode ^= _hashCodeHelper(positiveSuffix); |
338 hashCode ^= _hashCodeHelper(positiveSuffixPattern); | 328 hashCode ^= _hashCodeHelper(positiveSuffixPattern); |
339 hashCode ^= _hashCodeHelper(roundingInterval); | 329 hashCode ^= _hashCodeHelper(roundingIncrement); |
340 hashCode ^= _hashCodeHelper(roundingMode); | 330 hashCode ^= _hashCodeHelper(roundingMode); |
341 hashCode ^= _hashCodeHelper(secondaryGroupingSize); | 331 hashCode ^= _hashCodeHelper(secondaryGroupingSize); |
342 hashCode ^= _hashCodeHelper(significantDigitsMode); | 332 hashCode ^= _hashCodeHelper(significantDigitsMode); |
343 return hashCode; | 333 return hashCode; |
344 } | 334 } |
345 | 335 |
346 private int _hashCodeHelper(boolean value) { | 336 private int _hashCodeHelper(boolean value) { |
347 return value ? 1 : 0; | 337 return value ? 1 : 0; |
348 } | 338 } |
349 | 339 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 | 374 |
385 @Override | 375 @Override |
386 public boolean equals(Object other) { | 376 public boolean equals(Object other) { |
387 if (other == null) return false; | 377 if (other == null) return false; |
388 if (this == other) return true; | 378 if (this == other) return true; |
389 if (!(other instanceof Properties)) return false; | 379 if (!(other instanceof Properties)) return false; |
390 return _equals((Properties) other); | 380 return _equals((Properties) other); |
391 } | 381 } |
392 | 382 |
393 @Override | 383 @Override |
394 public boolean getAlwaysShowDecimal() { | |
395 return alwaysShowDecimal; | |
396 } | |
397 | |
398 @Override | |
399 public boolean getAlwaysShowPlusSign() { | |
400 return alwaysShowPlusSign; | |
401 } | |
402 | |
403 @Override | |
404 public CompactStyle getCompactStyle() { | 384 public CompactStyle getCompactStyle() { |
405 return compactStyle; | 385 return compactStyle; |
406 } | 386 } |
407 | 387 |
408 @Override | 388 @Override |
409 public Currency getCurrency() { | 389 public Currency getCurrency() { |
410 return currency; | 390 return currency; |
411 } | 391 } |
| 392 |
| 393 /// BEGIN GETTERS/SETTERS /// |
412 | 394 |
413 @Override | 395 @Override |
414 @Deprecated | 396 @Deprecated |
415 public CurrencyPluralInfo getCurrencyPluralInfo() { | 397 public CurrencyPluralInfo getCurrencyPluralInfo() { |
416 return currencyPluralInfo; | 398 return currencyPluralInfo; |
417 } | 399 } |
418 | 400 |
419 @Override | 401 @Override |
420 public CurrencyStyle getCurrencyStyle() { | 402 public CurrencyStyle getCurrencyStyle() { |
421 return currencyStyle; | 403 return currencyStyle; |
422 } | 404 } |
423 | 405 |
424 @Override | 406 @Override |
425 public CurrencyUsage getCurrencyUsage() { | 407 public CurrencyUsage getCurrencyUsage() { |
426 return currencyUsage; | 408 return currencyUsage; |
427 } | 409 } |
428 | 410 |
429 @Override | 411 @Override |
430 public boolean getDecimalPatternMatchRequired() { | 412 public boolean getDecimalPatternMatchRequired() { |
431 return decimalPatternMatchRequired; | 413 return decimalPatternMatchRequired; |
432 } | 414 } |
433 | 415 |
434 @Override | 416 @Override |
435 public int getExponentDigits() { | 417 public boolean getDecimalSeparatorAlwaysShown() { |
436 return exponentDigits; | 418 return decimalSeparatorAlwaysShown; |
437 } | 419 } |
438 | 420 |
439 @Override | 421 @Override |
440 public boolean getExponentShowPlusSign() { | 422 public boolean getExponentSignAlwaysShown() { |
441 return exponentShowPlusSign; | 423 return exponentSignAlwaysShown; |
| 424 } |
| 425 |
| 426 @Override |
| 427 public int getFormatWidth() { |
| 428 return formatWidth; |
442 } | 429 } |
443 | 430 |
444 @Override | 431 @Override |
445 public int getGroupingSize() { | 432 public int getGroupingSize() { |
446 return groupingSize; | 433 return groupingSize; |
447 } | 434 } |
448 | 435 |
449 @Override | 436 @Override |
450 public int getMagnitudeMultiplier() { | 437 public int getMagnitudeMultiplier() { |
451 return magnitudeMultiplier; | 438 return magnitudeMultiplier; |
(...skipping 23 matching lines...) Expand all Loading... |
475 public FormatWidth getMeasureFormatWidth() { | 462 public FormatWidth getMeasureFormatWidth() { |
476 return measureFormatWidth; | 463 return measureFormatWidth; |
477 } | 464 } |
478 | 465 |
479 @Override | 466 @Override |
480 public MeasureUnit getMeasureUnit() { | 467 public MeasureUnit getMeasureUnit() { |
481 return measureUnit; | 468 return measureUnit; |
482 } | 469 } |
483 | 470 |
484 @Override | 471 @Override |
| 472 public int getMinimumExponentDigits() { |
| 473 return minimumExponentDigits; |
| 474 } |
| 475 |
| 476 @Override |
485 public int getMinimumFractionDigits() { | 477 public int getMinimumFractionDigits() { |
486 return minimumFractionDigits; | 478 return minimumFractionDigits; |
487 } | 479 } |
488 | 480 |
489 @Override | 481 @Override |
490 public int getMinimumGroupingDigits() { | 482 public int getMinimumGroupingDigits() { |
491 return minimumGroupingDigits; | 483 return minimumGroupingDigits; |
492 } | 484 } |
493 | 485 |
494 @Override | 486 @Override |
495 public int getMinimumIntegerDigits() { | 487 public int getMinimumIntegerDigits() { |
496 return minimumIntegerDigits; | 488 return minimumIntegerDigits; |
497 } | 489 } |
498 | 490 |
499 @Override | 491 @Override |
500 public int getMinimumSignificantDigits() { | 492 public int getMinimumSignificantDigits() { |
501 return minimumSignificantDigits; | 493 return minimumSignificantDigits; |
502 } | 494 } |
503 | 495 |
504 @Override | 496 @Override |
505 public BigDecimal getMultiplier() { | 497 public BigDecimal getMultiplier() { |
506 return multiplier; | 498 return multiplier; |
507 } | 499 } |
508 | 500 |
509 @Override | 501 @Override |
510 public CharSequence getNegativePrefix() { | 502 public String getNegativePrefix() { |
511 return negativePrefix; | 503 return negativePrefix; |
512 } | 504 } |
513 | 505 |
514 @Override | 506 @Override |
515 public CharSequence getNegativePrefixPattern() { | 507 public String getNegativePrefixPattern() { |
516 return negativePrefixPattern; | 508 return negativePrefixPattern; |
517 } | 509 } |
518 | 510 |
519 @Override | 511 @Override |
520 public CharSequence getNegativeSuffix() { | 512 public String getNegativeSuffix() { |
521 return negativeSuffix; | 513 return negativeSuffix; |
522 } | 514 } |
523 | 515 |
524 @Override | 516 @Override |
525 public CharSequence getNegativeSuffixPattern() { | 517 public String getNegativeSuffixPattern() { |
526 return negativeSuffixPattern; | 518 return negativeSuffixPattern; |
527 } | 519 } |
528 | 520 |
529 // @Override | 521 @Override |
530 // public boolean getParseCurrency() { | 522 public PadPosition getPadPosition() { |
531 // return parseCurrency; | 523 return padPosition; |
532 // } | 524 } |
533 | 525 |
534 @Override | 526 @Override |
535 public PaddingLocation getPaddingLocation() { | 527 public String getPadString() { |
536 return paddingLocation; | 528 return padString; |
537 } | |
538 | |
539 @Override | |
540 public CharSequence getPaddingString() { | |
541 return paddingString; | |
542 } | |
543 | |
544 @Override | |
545 public int getPaddingWidth() { | |
546 return paddingWidth; | |
547 } | 529 } |
548 | 530 |
549 @Override | 531 @Override |
550 public boolean getParseCaseSensitive() { | 532 public boolean getParseCaseSensitive() { |
551 return parseCaseSensitive; | 533 return parseCaseSensitive; |
552 } | 534 } |
553 | 535 |
554 /* (non-Javadoc) | |
555 * @see com.ibm.icu.impl.number.Parse.IProperties#getParseIgnoreExponent() | |
556 */ | |
557 @Override | |
558 public boolean getParseIgnoreExponent() { | |
559 return parseIgnoreExponent; | |
560 } | |
561 | |
562 /* (non-Javadoc) | |
563 * @see com.ibm.icu.impl.number.Parse.IProperties#getParseIntegerOnly() | |
564 */ | |
565 @Override | 536 @Override |
566 public boolean getParseIntegerOnly() { | 537 public boolean getParseIntegerOnly() { |
567 return parseIntegerOnly; | 538 return parseIntegerOnly; |
568 } | 539 } |
569 | 540 |
570 /* (non-Javadoc) | |
571 * @see com.ibm.icu.impl.number.Parse.IProperties#getParseMode() | |
572 */ | |
573 @Override | 541 @Override |
574 public ParseMode getParseMode() { | 542 public ParseMode getParseMode() { |
575 return parseMode; | 543 return parseMode; |
576 } | 544 } |
577 | 545 |
578 @Override | 546 @Override |
| 547 public boolean getParseNoExponent() { |
| 548 return parseNoExponent; |
| 549 } |
| 550 |
| 551 @Override |
579 public boolean getParseToBigDecimal() { | 552 public boolean getParseToBigDecimal() { |
580 return parseToBigDecimal; | 553 return parseToBigDecimal; |
581 } | 554 } |
582 | 555 |
583 @Override | 556 @Override |
584 public CharSequence getPositivePrefix() { | 557 public boolean getPlusSignAlwaysShown() { |
| 558 return plusSignAlwaysShown; |
| 559 } |
| 560 |
| 561 @Override |
| 562 public String getPositivePrefix() { |
585 return positivePrefix; | 563 return positivePrefix; |
586 } | 564 } |
587 | 565 |
588 @Override | 566 @Override |
589 public CharSequence getPositivePrefixPattern() { | 567 public String getPositivePrefixPattern() { |
590 return positivePrefixPattern; | 568 return positivePrefixPattern; |
591 } | 569 } |
592 | 570 |
593 @Override | 571 @Override |
594 public CharSequence getPositiveSuffix() { | 572 public String getPositiveSuffix() { |
595 return positiveSuffix; | 573 return positiveSuffix; |
596 } | 574 } |
597 | 575 |
598 @Override | 576 @Override |
599 public CharSequence getPositiveSuffixPattern() { | 577 public String getPositiveSuffixPattern() { |
600 return positiveSuffixPattern; | 578 return positiveSuffixPattern; |
601 } | 579 } |
602 | 580 |
603 @Override | 581 @Override |
604 public BigDecimal getRoundingInterval() { | 582 public BigDecimal getRoundingIncrement() { |
605 return roundingInterval; | 583 return roundingIncrement; |
606 } | 584 } |
607 | 585 |
608 @Override | 586 @Override |
609 public RoundingMode getRoundingMode() { | 587 public RoundingMode getRoundingMode() { |
610 return roundingMode; | 588 return roundingMode; |
611 } | 589 } |
612 | 590 |
613 @Override | 591 @Override |
614 public int getSecondaryGroupingSize() { | 592 public int getSecondaryGroupingSize() { |
615 return secondaryGroupingSize; | 593 return secondaryGroupingSize; |
616 } | 594 } |
617 | 595 |
618 @Override | 596 @Override |
619 public SignificantDigitsMode getSignificantDigitsMode() { | 597 public SignificantDigitsMode getSignificantDigitsMode() { |
620 return significantDigitsMode; | 598 return significantDigitsMode; |
621 } | 599 } |
622 | 600 |
623 @Override | 601 @Override |
624 public int hashCode() { | 602 public int hashCode() { |
625 return _hashCode(); | 603 return _hashCode(); |
626 } | 604 } |
627 | 605 |
628 @Override | 606 /** Custom serialization: re-create object from serialized properties. */ |
629 public Properties setAlwaysShowDecimal(boolean alwaysShowDecimal) { | 607 private void readObject(ObjectInputStream ois) throws IOException, ClassNotFou
ndException { |
630 this.alwaysShowDecimal = alwaysShowDecimal; | 608 ois.defaultReadObject(); |
631 return this; | 609 |
632 } | 610 // Initialize to empty |
633 | 611 clear(); |
634 @Override | 612 |
635 public Properties setAlwaysShowPlusSign(boolean alwaysShowPlusSign) { | 613 // Extra int for possible future use |
636 this.alwaysShowPlusSign = alwaysShowPlusSign; | 614 ois.readInt(); |
637 return this; | 615 |
| 616 // 1) How many fields were serialized? |
| 617 int count = ois.readInt(); |
| 618 |
| 619 // 2) Read each field by its name and value |
| 620 for (int i=0; i<count; i++) { |
| 621 String name = (String) ois.readObject(); |
| 622 Object value = ois.readObject(); |
| 623 |
| 624 // Get the field reference |
| 625 Field field = null; |
| 626 try { |
| 627 field = Properties.class.getDeclaredField(name); |
| 628 } catch (NoSuchFieldException e) { |
| 629 // The field name does not exist! Possibly corrupted serialization. Igno
re this entry. |
| 630 continue; |
| 631 } catch (SecurityException e) { |
| 632 // Should not happen |
| 633 throw new AssertionError(e); |
| 634 } |
| 635 |
| 636 // NOTE: If the type of a field were changed in the future, this would be
the place to check: |
| 637 // If the variable `value` is the old type, perform any conversions necess
ary. |
| 638 |
| 639 // Save value into the field |
| 640 try { |
| 641 field.set(this, value); |
| 642 } catch (IllegalArgumentException e) { |
| 643 // Should not happen |
| 644 throw new AssertionError(e); |
| 645 } catch (IllegalAccessException e) { |
| 646 // Should not happen |
| 647 throw new AssertionError(e); |
| 648 } |
| 649 } |
638 } | 650 } |
639 | 651 |
640 @Override | 652 @Override |
641 public Properties setCompactStyle(CompactStyle compactStyle) { | 653 public Properties setCompactStyle(CompactStyle compactStyle) { |
642 this.compactStyle = compactStyle; | 654 this.compactStyle = compactStyle; |
643 return this; | 655 return this; |
644 } | 656 } |
645 | 657 |
646 @Override | 658 @Override |
647 public Properties setCurrency(Currency currency) { | 659 public Properties setCurrency(Currency currency) { |
648 this.currency = currency; | 660 this.currency = currency; |
649 return this; | 661 return this; |
650 } | 662 } |
651 | 663 |
652 @Override | 664 @Override |
653 @Deprecated | 665 @Deprecated |
654 public Properties setCurrencyPluralInfo(CurrencyPluralInfo currencyPluralInfo)
{ | 666 public Properties setCurrencyPluralInfo(CurrencyPluralInfo currencyPluralInfo)
{ |
| 667 // TODO: In order to maintain immutability, we have to perform a clone here. |
| 668 // It would be better to just retire CurrencyPluralInfo entirely. |
| 669 if (currencyPluralInfo != null) { |
| 670 currencyPluralInfo = (CurrencyPluralInfo) currencyPluralInfo.clone(); |
| 671 } |
655 this.currencyPluralInfo = currencyPluralInfo; | 672 this.currencyPluralInfo = currencyPluralInfo; |
656 return this; | 673 return this; |
657 } | 674 } |
658 | 675 |
659 @Override | 676 @Override |
660 public Properties setCurrencyStyle(CurrencyStyle currencyStyle) { | 677 public Properties setCurrencyStyle(CurrencyStyle currencyStyle) { |
661 this.currencyStyle = currencyStyle; | 678 this.currencyStyle = currencyStyle; |
662 return this; | 679 return this; |
663 } | 680 } |
664 | 681 |
665 @Override | 682 @Override |
666 public Properties setCurrencyUsage(CurrencyUsage currencyUsage) { | 683 public Properties setCurrencyUsage(CurrencyUsage currencyUsage) { |
667 this.currencyUsage = currencyUsage; | 684 this.currencyUsage = currencyUsage; |
668 return this; | 685 return this; |
669 } | 686 } |
670 | 687 |
671 @Override | 688 @Override |
672 public Properties setDecimalPatternMatchRequired(boolean decimalPatternMatchRe
quired) { | 689 public Properties setDecimalPatternMatchRequired(boolean decimalPatternMatchRe
quired) { |
673 this.decimalPatternMatchRequired = decimalPatternMatchRequired; | 690 this.decimalPatternMatchRequired = decimalPatternMatchRequired; |
674 return this; | 691 return this; |
675 } | 692 } |
676 | 693 |
677 @Override | 694 @Override |
678 public Properties setExponentDigits(int exponentDigits) { | 695 public Properties setDecimalSeparatorAlwaysShown(boolean alwaysShowDecimal) { |
679 this.exponentDigits = exponentDigits; | 696 this.decimalSeparatorAlwaysShown = alwaysShowDecimal; |
680 return this; | 697 return this; |
681 } | 698 } |
682 | 699 |
683 @Override | 700 @Override |
684 public Properties setExponentShowPlusSign(boolean exponentShowPlusSign) { | 701 public Properties setExponentSignAlwaysShown(boolean exponentSignAlwaysShown)
{ |
685 this.exponentShowPlusSign = exponentShowPlusSign; | 702 this.exponentSignAlwaysShown = exponentSignAlwaysShown; |
| 703 return this; |
| 704 } |
| 705 |
| 706 @Override |
| 707 public Properties setFormatWidth(int paddingWidth) { |
| 708 this.formatWidth = paddingWidth; |
686 return this; | 709 return this; |
687 } | 710 } |
688 | 711 |
689 @Override | 712 @Override |
690 public Properties setGroupingSize(int groupingSize) { | 713 public Properties setGroupingSize(int groupingSize) { |
691 this.groupingSize = groupingSize; | 714 this.groupingSize = groupingSize; |
692 return this; | 715 return this; |
693 } | 716 } |
694 | 717 |
695 @Override | 718 @Override |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 return this; | 751 return this; |
729 } | 752 } |
730 | 753 |
731 @Override | 754 @Override |
732 public Properties setMeasureUnit(MeasureUnit measureUnit) { | 755 public Properties setMeasureUnit(MeasureUnit measureUnit) { |
733 this.measureUnit = measureUnit; | 756 this.measureUnit = measureUnit; |
734 return this; | 757 return this; |
735 } | 758 } |
736 | 759 |
737 @Override | 760 @Override |
| 761 public Properties setMinimumExponentDigits(int exponentDigits) { |
| 762 this.minimumExponentDigits = exponentDigits; |
| 763 return this; |
| 764 } |
| 765 |
| 766 @Override |
738 public Properties setMinimumFractionDigits(int minimumFractionDigits) { | 767 public Properties setMinimumFractionDigits(int minimumFractionDigits) { |
739 this.minimumFractionDigits = minimumFractionDigits; | 768 this.minimumFractionDigits = minimumFractionDigits; |
740 return this; | 769 return this; |
741 } | 770 } |
742 | 771 |
743 @Override | 772 @Override |
744 public Properties setMinimumGroupingDigits(int minimumGroupingDigits) { | 773 public Properties setMinimumGroupingDigits(int minimumGroupingDigits) { |
745 this.minimumGroupingDigits = minimumGroupingDigits; | 774 this.minimumGroupingDigits = minimumGroupingDigits; |
746 return this; | 775 return this; |
747 } | 776 } |
748 | 777 |
749 @Override | 778 @Override |
750 public Properties setMinimumIntegerDigits(int minimumIntegerDigits) { | 779 public Properties setMinimumIntegerDigits(int minimumIntegerDigits) { |
751 this.minimumIntegerDigits = minimumIntegerDigits; | 780 this.minimumIntegerDigits = minimumIntegerDigits; |
752 return this; | 781 return this; |
753 } | 782 } |
754 | 783 |
755 @Override | 784 @Override |
756 public Properties setMinimumSignificantDigits(int minimumSignificantDigits) { | 785 public Properties setMinimumSignificantDigits(int minimumSignificantDigits) { |
757 this.minimumSignificantDigits = minimumSignificantDigits; | 786 this.minimumSignificantDigits = minimumSignificantDigits; |
758 return this; | 787 return this; |
759 } | 788 } |
760 | 789 |
761 @Override | 790 @Override |
762 public Properties setMultiplier(BigDecimal multiplier) { | 791 public Properties setMultiplier(BigDecimal multiplier) { |
763 this.multiplier = multiplier; | 792 this.multiplier = multiplier; |
764 return this; | 793 return this; |
765 } | 794 } |
766 | 795 |
767 // @Override | 796 @Override |
768 // public Properties setParseCurrency(boolean parseCurrency) { | 797 public Properties setNegativePrefix(String negativePrefix) { |
769 // this.parseCurrency = parseCurrency; | |
770 // return this; | |
771 // } | |
772 | |
773 @Override | |
774 public Properties setNegativePrefix(CharSequence negativePrefix) { | |
775 this.negativePrefix = negativePrefix; | 798 this.negativePrefix = negativePrefix; |
776 return this; | 799 return this; |
777 } | 800 } |
778 | 801 |
779 @Override | 802 @Override |
780 public Properties setNegativePrefixPattern(CharSequence negativePrefixPattern)
{ | 803 public Properties setNegativePrefixPattern(String negativePrefixPattern) { |
781 this.negativePrefixPattern = negativePrefixPattern; | 804 this.negativePrefixPattern = negativePrefixPattern; |
782 return this; | 805 return this; |
783 } | 806 } |
784 | 807 |
785 @Override | 808 @Override |
786 public Properties setNegativeSuffix(CharSequence negativeSuffix) { | 809 public Properties setNegativeSuffix(String negativeSuffix) { |
787 this.negativeSuffix = negativeSuffix; | 810 this.negativeSuffix = negativeSuffix; |
788 return this; | 811 return this; |
789 } | 812 } |
790 | 813 |
791 @Override | 814 @Override |
792 public Properties setNegativeSuffixPattern(CharSequence negativeSuffixPattern)
{ | 815 public Properties setNegativeSuffixPattern(String negativeSuffixPattern) { |
793 this.negativeSuffixPattern = negativeSuffixPattern; | 816 this.negativeSuffixPattern = negativeSuffixPattern; |
794 return this; | 817 return this; |
795 } | 818 } |
796 | 819 |
797 @Override | 820 @Override |
798 public Properties setPaddingLocation(PaddingLocation paddingLocation) { | 821 public Properties setPadPosition(PadPosition paddingLocation) { |
799 this.paddingLocation = paddingLocation; | 822 this.padPosition = paddingLocation; |
800 return this; | 823 return this; |
801 } | 824 } |
802 | 825 |
803 @Override | 826 @Override |
804 public Properties setPaddingString(CharSequence paddingString) { | 827 public Properties setPadString(String paddingString) { |
805 this.paddingString = paddingString; | 828 this.padString = paddingString; |
806 return this; | |
807 } | |
808 | |
809 @Override | |
810 public Properties setPaddingWidth(int paddingWidth) { | |
811 this.paddingWidth = paddingWidth; | |
812 return this; | 829 return this; |
813 } | 830 } |
814 | 831 |
815 @Override | 832 @Override |
816 public Properties setParseCaseSensitive(boolean parseCaseSensitive) { | 833 public Properties setParseCaseSensitive(boolean parseCaseSensitive) { |
817 this.parseCaseSensitive = parseCaseSensitive; | 834 this.parseCaseSensitive = parseCaseSensitive; |
818 return this; | 835 return this; |
819 } | 836 } |
820 | 837 |
821 /* (non-Javadoc) | |
822 * @see com.ibm.icu.impl.number.Parse.IProperties#setParseIgnoreExponent(boole
an) | |
823 */ | |
824 @Override | |
825 public Properties setParseIgnoreExponent(boolean parseIgnoreExponent) { | |
826 this.parseIgnoreExponent = parseIgnoreExponent; | |
827 return this; | |
828 } | |
829 | |
830 /* (non-Javadoc) | |
831 * @see com.ibm.icu.impl.number.Parse.IProperties#setParseIntegerOnly(boolean) | |
832 */ | |
833 @Override | 838 @Override |
834 public Properties setParseIntegerOnly(boolean parseIntegerOnly) { | 839 public Properties setParseIntegerOnly(boolean parseIntegerOnly) { |
835 this.parseIntegerOnly = parseIntegerOnly; | 840 this.parseIntegerOnly = parseIntegerOnly; |
836 return this; | 841 return this; |
837 } | 842 } |
838 | 843 |
839 /* (non-Javadoc) | |
840 * @see com.ibm.icu.impl.number.Parse.IProperties#setParseMode(com.ibm.icu.imp
l.number.Parse.ParseMode) | |
841 */ | |
842 @Override | 844 @Override |
843 public Properties setParseMode(ParseMode parseMode) { | 845 public Properties setParseMode(ParseMode parseMode) { |
844 this.parseMode = parseMode; | 846 this.parseMode = parseMode; |
845 return this; | 847 return this; |
846 } | 848 } |
847 | 849 |
848 @Override | 850 @Override |
| 851 public Properties setParseNoExponent(boolean parseNoExponent) { |
| 852 this.parseNoExponent = parseNoExponent; |
| 853 return this; |
| 854 } |
| 855 |
| 856 @Override |
849 public Properties setParseToBigDecimal(boolean parseToBigDecimal) { | 857 public Properties setParseToBigDecimal(boolean parseToBigDecimal) { |
850 this.parseToBigDecimal = parseToBigDecimal; | 858 this.parseToBigDecimal = parseToBigDecimal; |
851 return this; | 859 return this; |
852 } | 860 } |
853 | 861 |
854 @Override | 862 @Override |
855 public Properties setPositivePrefix(CharSequence positivePrefix) { | 863 public Properties setPlusSignAlwaysShown(boolean plusSignAlwaysShown) { |
| 864 this.plusSignAlwaysShown = plusSignAlwaysShown; |
| 865 return this; |
| 866 } |
| 867 |
| 868 @Override |
| 869 public Properties setPositivePrefix(String positivePrefix) { |
856 this.positivePrefix = positivePrefix; | 870 this.positivePrefix = positivePrefix; |
857 return this; | 871 return this; |
858 } | 872 } |
859 | 873 |
860 @Override | 874 @Override |
861 public Properties setPositivePrefixPattern(CharSequence positivePrefixPattern)
{ | 875 public Properties setPositivePrefixPattern(String positivePrefixPattern) { |
862 this.positivePrefixPattern = positivePrefixPattern; | 876 this.positivePrefixPattern = positivePrefixPattern; |
863 return this; | 877 return this; |
864 } | 878 } |
865 | 879 |
866 @Override | 880 @Override |
867 public Properties setPositiveSuffix(CharSequence positiveSuffix) { | 881 public Properties setPositiveSuffix(String positiveSuffix) { |
868 this.positiveSuffix = positiveSuffix; | 882 this.positiveSuffix = positiveSuffix; |
869 return this; | 883 return this; |
870 } | 884 } |
871 | 885 |
872 @Override | 886 @Override |
873 public Properties setPositiveSuffixPattern(CharSequence positiveSuffixPattern)
{ | 887 public Properties setPositiveSuffixPattern(String positiveSuffixPattern) { |
874 this.positiveSuffixPattern = positiveSuffixPattern; | 888 this.positiveSuffixPattern = positiveSuffixPattern; |
875 return this; | 889 return this; |
876 } | 890 } |
877 | 891 |
878 @Override | 892 @Override |
879 public Properties setRoundingInterval(BigDecimal interval) { | 893 public Properties setRoundingIncrement(BigDecimal roundingIncrement) { |
880 this.roundingInterval = interval; | 894 this.roundingIncrement = roundingIncrement; |
881 return this; | 895 return this; |
882 } | 896 } |
883 | 897 |
884 @Override | 898 @Override |
885 public Properties setRoundingMode(RoundingMode roundingMode) { | 899 public Properties setRoundingMode(RoundingMode roundingMode) { |
886 this.roundingMode = roundingMode; | 900 this.roundingMode = roundingMode; |
887 return this; | 901 return this; |
888 } | 902 } |
889 | 903 |
890 @Override | 904 @Override |
(...skipping 29 matching lines...) Expand all Loading... |
920 continue; | 934 continue; |
921 } else if (myValue == null || defaultValue == null) { | 935 } else if (myValue == null || defaultValue == null) { |
922 result.append(" " + field.getName() + ":" + myValue); | 936 result.append(" " + field.getName() + ":" + myValue); |
923 } else if (!myValue.equals(defaultValue)) { | 937 } else if (!myValue.equals(defaultValue)) { |
924 result.append(" " + field.getName() + ":" + myValue); | 938 result.append(" " + field.getName() + ":" + myValue); |
925 } | 939 } |
926 } | 940 } |
927 result.append(">"); | 941 result.append(">"); |
928 return result.toString(); | 942 return result.toString(); |
929 } | 943 } |
| 944 |
| 945 /** |
| 946 * Custom serialization: save fields along with their name, so that fields can
be easily added in |
| 947 * the future in any order. Only save fields that differ from their default va
lue. |
| 948 */ |
| 949 private void writeObject(ObjectOutputStream oos) throws IOException { |
| 950 oos.defaultWriteObject(); |
| 951 |
| 952 // Extra int for possible future use |
| 953 oos.writeInt(0); |
| 954 |
| 955 ArrayList<Field> fieldsToSerialize = new ArrayList<Field>(); |
| 956 ArrayList<Object> valuesToSerialize = new ArrayList<Object>(); |
| 957 Field[] fields = Properties.class.getDeclaredFields(); |
| 958 for (Field field : fields) { |
| 959 if (Modifier.isStatic(field.getModifiers())) { |
| 960 continue; |
| 961 } |
| 962 try { |
| 963 Object myValue = field.get(this); |
| 964 if (myValue == null) { |
| 965 // All *Object* values default to null; no need to serialize. |
| 966 continue; |
| 967 } |
| 968 Object defaultValue = field.get(DEFAULT); |
| 969 if (!myValue.equals(defaultValue)) { |
| 970 fieldsToSerialize.add(field); |
| 971 valuesToSerialize.add(myValue); |
| 972 } |
| 973 } catch (IllegalArgumentException e) { |
| 974 // Should not happen |
| 975 throw new AssertionError(e); |
| 976 } catch (IllegalAccessException e) { |
| 977 // Should not happen |
| 978 throw new AssertionError(e); |
| 979 } |
| 980 } |
| 981 |
| 982 // 1) How many fields are to be serialized? |
| 983 int count = fieldsToSerialize.size(); |
| 984 oos.writeInt(count); |
| 985 |
| 986 // 2) Write each field with its name and value |
| 987 for (int i = 0; i < count; i++) { |
| 988 Field field = fieldsToSerialize.get(i); |
| 989 Object value = valuesToSerialize.get(i); |
| 990 oos.writeObject(field.getName()); |
| 991 oos.writeObject(value); |
| 992 } |
| 993 } |
930 } | 994 } |
LEFT | RIGHT |