]> granicus.if.org Git - icu/commitdiff
ICU-9785 Imported ICU data including updated Thai punctuation exemplar data. Also...
authorYoshito Umaoka <y.umaoka@gmail.com>
Thu, 13 Dec 2012 19:52:57 +0000 (19:52 +0000)
committerYoshito Umaoka <y.umaoka@gmail.com>
Thu, 13 Dec 2012 19:52:57 +0000 (19:52 +0000)
X-SVN-Rev: 32952

icu4j/main/classes/core/src/com/ibm/icu/util/LocaleData.java
icu4j/main/shared/data/icudata.jar
icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleDataTest.java

index 786cb507b527d0438d101abb215a87b3e205b44d..b083b71ff8dc1bbe6a7b485d7cca856ce6e4f505 100644 (file)
@@ -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
index 556dab405a29bf58f5676376a179ef33075cab7b..f2b60da546d50830d641024a5bae076f590991a3 100755 (executable)
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:63d4a9c78178ab0295f34472d1313c2da18d4fbc8ab33dbe41b3c892258dacd6
-size 9757986
+oid sha256:8664ebd2785120b69a629e2a3bcb65621037f9caa17b2d2bf9130fc616b01410
+size 9758007
index 84c84d002dbc7d6bd67049815976329df1e40cbb..9a6db85d9a560435dcd61c1a53b1f5b360dd5616 100644 (file)
@@ -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();