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