From: Yoshito Umaoka Date: Thu, 5 Jul 2012 21:18:14 +0000 (+0000) Subject: ICU-9389 Fixed available format data inheritance problem in DateTimePatternGenerator. X-Git-Tag: milestone-59-0-1~3728 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=64e43ff45819a039cfd587f923fe43a0fd5b4e29;p=icu ICU-9389 Fixed available format data inheritance problem in DateTimePatternGenerator. X-SVN-Rev: 32024 --- diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/DateTimePatternGenerator.java b/icu4j/main/classes/core/src/com/ibm/icu/text/DateTimePatternGenerator.java index 4a05f4a299d..d4590d313c9 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/DateTimePatternGenerator.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/DateTimePatternGenerator.java @@ -16,6 +16,7 @@ import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; +import java.util.MissingResourceException; import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; @@ -174,8 +175,6 @@ public class DateTimePatternGenerator implements Freezable 0 && !currentLocaleName.equals("root")) { - ULocale parentLocale = null; - try { - UResourceBundle parentNameBundle = rb.get("%%Parent"); - parentLocale = new ULocale(parentNameBundle.getString()); - } catch (Exception e) { - parentLocale = currentLocale.getFallback(); + availFormatsBundle = calTypeBundle.getWithFallback("availableFormats"); + } catch (MissingResourceException e) { + // fall through + } + + while (availFormatsBundle != null) { + for (int i = 0; i < availFormatsBundle.getSize(); i++) { + String formatKey = availFormatsBundle.get(i).getKey(); + + if (!result.isAvailableFormatSet(formatKey)) { + result.setAvailableFormat(formatKey); + // Add pattern with its associated skeleton. Override any duplicate derived from std patterns, + // but not a previous availableFormats entry: + String formatValue = availFormatsBundle.get(i).getString(); + result.addPatternWithSkeleton(formatValue, formatKey, true, returnInfo); + } } - if (parentLocale == null || parentLocale.getBaseName().equals(currentLocaleName)) { + + ICUResourceBundle pbundle = (ICUResourceBundle)availFormatsBundle.getParent(); + if (pbundle == null) { break; } - rb = (ICUResourceBundle) UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, parentLocale); - currentLocale = rb.getULocale(); - currentLocaleName = currentLocale.getBaseName(); - calBundle = rb.getWithFallback("calendar"); - calTypeBundle = calBundle.getWithFallback(calendarTypeToUse); try { - ICUResourceBundle formatBundle = calTypeBundle.getWithFallback("availableFormats"); - //System.out.println("available format from parent locale:"+parentLocale.getName()); - for (int i=0; i CANONICAL_SET = new HashSet(Arrays.asList(CANONICAL_ITEMS)); + private static final Set CANONICAL_SET = new HashSet(Arrays.asList(CANONICAL_ITEMS)); private Set cldrAvailableFormatKeys = new HashSet(20); - static final private int + private static final int DATE_MASK = (1<