From b5aa742648fff98c8adef85f53e2ce0105003920 Mon Sep 17 00:00:00 2001 From: Yoshito Umaoka Date: Fri, 30 May 2014 14:27:29 +0000 Subject: [PATCH] ICU-10918 Moved the code reading an ICU configuration property out of DecimalFormat#subparse to static initializer. The configuration is no longer dynamic, so the corresponding test case was also updated. X-SVN-Rev: 35773 --- .../src/com/ibm/icu/text/DecimalFormat.java | 12 +++---- .../icu/dev/test/format/NumberFormatTest.java | 31 +++++++++---------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormat.java index c81cce54f04..fc1ff98cc13 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormat.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormat.java @@ -2298,7 +2298,12 @@ public class DecimalFormat extends NumberFormat { 0xFB29, 0xFB29, 0xFE62, 0xFE62, 0xFF0B, 0xFF0B).freeze(); - + + // equivalent grouping and decimal support + static final boolean skipExtendedSeparatorParsing = ICUConfig.get( + "com.ibm.icu.text.DecimalFormat.SkipExtendedSeparatorParsing", "false") + .equals("true"); + // When parsing a number with big exponential value, it requires to transform the // value into a string representation to construct BigInteger instance. We want to @@ -2399,11 +2404,6 @@ public class DecimalFormat extends NumberFormat { int digitStart = position; // where did the digit start? int gs2 = groupingSize2 == 0 ? groupingSize : groupingSize2; - // equivalent grouping and decimal support - boolean skipExtendedSeparatorParsing = ICUConfig.get( - "com.ibm.icu.text.DecimalFormat.SkipExtendedSeparatorParsing", "false") - .equals("true"); - UnicodeSet decimalEquiv = skipExtendedSeparatorParsing ? UnicodeSet.EMPTY : getEquivalentDecimals(decimal, strictParse); UnicodeSet groupEquiv = skipExtendedSeparatorParsing ? UnicodeSet.EMPTY : diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatTest.java index 5973afd1b9e..4f9bccc2cac 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatTest.java @@ -23,6 +23,7 @@ import java.util.Locale; import java.util.Set; import com.ibm.icu.dev.test.TestUtil; +import com.ibm.icu.impl.ICUConfig; import com.ibm.icu.impl.LocaleUtility; import com.ibm.icu.impl.data.ResourceReader; import com.ibm.icu.impl.data.TokenIterator; @@ -3024,26 +3025,24 @@ public class NumberFormatTest extends com.ibm.icu.dev.test.TestFmwk { expect(fmt, "2\uFF61345.67", 2345.67); - // Ticket#7218 + // Ticket#7128 // - // Lenient separator parsing is enabled by default. - // A space character below is interpreted as a - // group separator, even ',' is used as grouping - // separator in the symbols. sym.setGroupingSeparator(','); fmt.setDecimalFormatSymbols(sym); - expect(fmt, "12 345", 12345); - - // When the property SkipExtendedSeparatorParsing is true, - // DecimalFormat does not use the extended equivalent separator - // data and only uses the one in DecimalFormatSymbols. - System.setProperty("com.ibm.icu.text.DecimalFormat.SkipExtendedSeparatorParsing", "true"); - - expect(fmt, "23 456", 23); - - // Set the configuration back to the default - System.setProperty("com.ibm.icu.text.DecimalFormat.SkipExtendedSeparatorParsing", "false"); + String skipExtSepParse = ICUConfig.get("com.ibm.icu.text.DecimalFormat.SkipExtendedSeparatorParsing", "false"); + if (skipExtSepParse.equals("true")) { + // When the property SkipExtendedSeparatorParsing is true, + // DecimalFormat does not use the extended equivalent separator + // data and only uses the one in DecimalFormatSymbols. + expect(fmt, "23 456", 23); + } else { + // Lenient separator parsing is enabled by default. + // A space character below is interpreted as a + // group separator, even ',' is used as grouping + // separator in the symbols. + expect(fmt, "12 345", 12345); + } } /* -- 2.40.0