From 612181f2f5d0a21dfd685a7616a1e5e55a496265 Mon Sep 17 00:00:00 2001 From: Yoshito Umaoka Date: Thu, 13 Dec 2012 19:52:57 +0000 Subject: [PATCH] ICU-9785 Imported ICU data including updated Thai punctuation exemplar data. Also fixed ES_CURRENCY and some documentation / API version tag issues. X-SVN-Rev: 32952 --- .../core/src/com/ibm/icu/util/LocaleData.java | 14 ++++-- icu4j/main/shared/data/icudata.jar | 4 +- .../ibm/icu/dev/test/util/LocaleDataTest.java | 48 ++++++++++++++++++- 3 files changed, 59 insertions(+), 7 deletions(-) diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/LocaleData.java b/icu4j/main/classes/core/src/com/ibm/icu/util/LocaleData.java index 786cb507b5..b083b71ff8 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/LocaleData.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/LocaleData.java @@ -45,13 +45,14 @@ public final class LocaleData { /** * EXType for {@link #getExemplarSet(int, int)}. - * @stable ICU 3.4 + * @stable ICU 4.4 */ public static final int ES_INDEX = 2; /** * EXType for {@link #getExemplarSet(int, int)}. - * @stable ICU 3.4 + * Note: This type is no longer supported. + * @stable ICU 4.4 */ public static final int ES_CURRENCY = 3; @@ -156,7 +157,7 @@ public final class LocaleData { * IGNORE_SPACE bit is always set, regardless of the * value of 'options'. * @param extype The type of exemplar set to be retrieved, - * ES_STANDARD, ES_INDEX, ES_CURRENCY, or ES_AUXILIARY + * ES_STANDARD, ES_INDEX, ES_AUXILIARY, or ES_PUNCTUATION * @return The set of exemplar characters for the given locale. * @stable ICU 3.4 */ @@ -167,6 +168,11 @@ public final class LocaleData { "ExemplarCharactersPunctuation" }; + if (extype == ES_CURRENCY) { + // currency symbol exemplar is no longer available + return new UnicodeSet(); + } + try{ ICUResourceBundle stringBundle = (ICUResourceBundle) bundle.get(exemplarSetTypes[extype]); @@ -195,7 +201,7 @@ public final class LocaleData { } } - static final Pattern US_SYNTAX = Pattern.compile(" ([\\-\\&\\{\\}\\[\\]])"); + static final Pattern US_SYNTAX = Pattern.compile(" ([\\-\\&\\{\\}\\[\\]\\\\])"); /** * Gets the LocaleData object associated with the ULocale specified in locale diff --git a/icu4j/main/shared/data/icudata.jar b/icu4j/main/shared/data/icudata.jar index 556dab405a..f2b60da546 100755 --- a/icu4j/main/shared/data/icudata.jar +++ b/icu4j/main/shared/data/icudata.jar @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:63d4a9c78178ab0295f34472d1313c2da18d4fbc8ab33dbe41b3c892258dacd6 -size 9757986 +oid sha256:8664ebd2785120b69a629e2a3bcb65621037f9caa17b2d2bf9130fc616b01410 +size 9758007 diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleDataTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleDataTest.java index 84c84d002d..9a6db85d9a 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleDataTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleDataTest.java @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (C) 2003-2010, International Business Machines Corporation and * + * Copyright (C) 2003-2012, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ @@ -275,6 +275,52 @@ public class LocaleDataTest extends TestFmwk{ assertTrue("case-folded is sometimes a strict superset, and sometimes equal", equalCount > 0 && equalCount < availableLocales.length * 2); } + + // Test case created for checking type coverage of static getExemplarSet method. + // See #9785, #9794 and #9795 + public void TestExemplarSetTypes() { + final String[] testLocales = { + "am", // No auxiliary / index exemplars as of ICU 50 + "en", + "th", // #9785 + "foo", // Bogus locale + }; + + final int[] testTypes = { + LocaleData.ES_STANDARD, + LocaleData.ES_AUXILIARY, + LocaleData.ES_INDEX, + LocaleData.ES_CURRENCY, + LocaleData.ES_PUNCTUATION, + }; + + final String[] testTypeNames = { + "ES_STANDARD", + "ES_AUXILIARY", + "ES_INDEX", + "ES_CURRENCY", + "ES_PUNCTUATION", + }; + + for (String locstr : testLocales) { + ULocale loc = new ULocale(locstr); + for (int i = 0; i < testTypes.length; i++) { + try { + UnicodeSet set = LocaleData.getExemplarSet(loc, 0, testTypes[i]); + if (set == null) { + // Not sure null is really OK (#9795) + logln(loc + "(" + testTypeNames[i] + ") returned null"); + } else if (set.isEmpty()) { + // This is probably reasonable when data is absent + logln(loc + "(" + testTypeNames[i] + ") returned an empty set"); + } + } catch (Exception e) { + errln(loc + "(" + testTypeNames[i] + ") Exception:" + e.getMessage()); + } + } + } + } + public void TestCoverage(){ LocaleData ld = LocaleData.getInstance(); boolean t = ld.getNoSubstitute();