/**
* 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;
* 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
*/
"ExemplarCharactersPunctuation"
};
+ if (extype == ES_CURRENCY) {
+ // currency symbol exemplar is no longer available
+ return new UnicodeSet();
+ }
+
try{
ICUResourceBundle stringBundle = (ICUResourceBundle) bundle.get(exemplarSetTypes[extype]);
}
}
- 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
/*
*******************************************************************************
- * Copyright (C) 2003-2010, International Business Machines Corporation and *
+ * Copyright (C) 2003-2012, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
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();