return noSubstitute;
}
+ private static final String [] DELIMITER_TYPES = {
+ "quotationStart",
+ "quotationEnd",
+ "alternateQuotationStart",
+ "alternateQuotationEnd"
+ };
+
/**
* Retrieves a delimiter string from the locale data.
*
* @stable ICU 3.4
*/
public String getDelimiter(int type) {
- String [] delimiterTypes = { "quotationStart",
- "quotationEnd",
- "alternateQuotationStart",
- "alternateQuotationEnd" };
-
- ICUResourceBundle stringBundle = (ICUResourceBundle) bundle.get("delimiters").get(delimiterTypes[type]);
+ ICUResourceBundle delimitersBundle = (ICUResourceBundle) bundle.get("delimiters");
+ // Only some of the quotation marks may be here. So we make sure that we do a multilevel fallback.
+ ICUResourceBundle stringBundle = delimitersBundle.getWithFallback(DELIMITER_TYPES[type]);
if ( noSubstitute && (stringBundle.getLoadingStatus() == ICUResourceBundle.FROM_ROOT) )
return null;
logln(ld.getDelimiter(LocaleData.ALT_QUOTATION_END));
}
+ public void TestFallback(){
+ LocaleData fr_FR = LocaleData.getInstance(ULocale.FRANCE);
+ LocaleData fr_CA = LocaleData.getInstance(ULocale.CANADA_FRENCH);
+
+ // This better not crash when only some values are overridden
+ assertEquals("Start quotes are not equal", fr_FR.getDelimiter(LocaleData.QUOTATION_START), fr_CA.getDelimiter(LocaleData.QUOTATION_START));
+ assertEquals("End quotes are not equals", fr_FR.getDelimiter(LocaleData.QUOTATION_END), fr_CA.getDelimiter(LocaleData.QUOTATION_END));
+ assertNotEquals("Alt start quotes are equal", fr_FR.getDelimiter(LocaleData.ALT_QUOTATION_START), fr_CA.getDelimiter(LocaleData.ALT_QUOTATION_START));
+ assertNotEquals("Alt end quotes are equals", fr_FR.getDelimiter(LocaleData.ALT_QUOTATION_END), fr_CA.getDelimiter(LocaleData.ALT_QUOTATION_END));
+ }
+
public void TestLocaleDisplayPattern(){
LocaleData ld = LocaleData.getInstance();
logln("Default locale "+ " LocaleDisplayPattern:" + ld.getLocaleDisplayPattern());