src/windows/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java

Print this page
rev 6809 : imported patch 7091601


 286                 SoftReference<DecimalFormatSymbols> ref =
 287                     decimalFormatSymbolsCache.get(locale);
 288 
 289                 if (ref == null || (dfs = ref.get()) == null) {
 290                     dfs = new DecimalFormatSymbols(getNumberLocale(locale));
 291                     String langTag = removeExtensions(locale).toLanguageTag();
 292 
 293                     // DecimalFormatSymbols.setInternationalCurrencySymbol() has
 294                     // a side effect of setting the currency symbol as well. So
 295                     // the calling order is relevant here.
 296                     dfs.setInternationalCurrencySymbol(getInternationalCurrencySymbol(langTag, dfs.getInternationalCurrencySymbol()));
 297                     dfs.setCurrencySymbol(getCurrencySymbol(langTag, dfs.getCurrencySymbol()));
 298                     dfs.setDecimalSeparator(getDecimalSeparator(langTag, dfs.getDecimalSeparator()));
 299                     dfs.setGroupingSeparator(getGroupingSeparator(langTag, dfs.getGroupingSeparator()));
 300                     dfs.setInfinity(getInfinity(langTag, dfs.getInfinity()));
 301                     dfs.setMinusSign(getMinusSign(langTag, dfs.getMinusSign()));
 302                     dfs.setMonetaryDecimalSeparator(getMonetaryDecimalSeparator(langTag, dfs.getMonetaryDecimalSeparator()));
 303                     dfs.setNaN(getNaN(langTag, dfs.getNaN()));
 304                     dfs.setPercent(getPercent(langTag, dfs.getPercent()));
 305                     dfs.setPerMill(getPerMill(langTag, dfs.getPerMill()));
 306                     if (isNativeDigit(langTag)) {
 307                         dfs.setZeroDigit(getZeroDigit(langTag, dfs.getZeroDigit()));
 308                     }
 309                     ref = new SoftReference<>(dfs);
 310                     decimalFormatSymbolsCache.put(locale, ref);
 311                 }
 312                 return (DecimalFormatSymbols)dfs.clone();
 313             }
 314         };
 315     }
 316 
 317     public static CalendarDataProvider getCalendarDataProvider() {
 318         return new CalendarDataProvider() {
 319             @Override
 320             public Locale[] getAvailableLocales() {
 321                 return getSupportedCalendarLocales();
 322             }
 323 
 324             @Override
 325             public boolean isSupportedLocale(Locale locale) {
 326                 return isSupportedCalendarLocale(locale);
 327             }
 328 


 403     }
 404 
 405     private static Locale[] getSupportedCalendarLocales() {
 406         if (supportedLocale.length != 0 &&
 407             supportedLocaleSet.contains(Locale.JAPAN) &&
 408             isJapaneseCalendar()) {
 409             Locale[] sup = new Locale[supportedLocale.length+1];
 410             sup[0] = JRELocaleConstants.JA_JP_JP;
 411             System.arraycopy(supportedLocale, 0, sup, 1, supportedLocale.length);
 412             return sup;
 413         }
 414         return supportedLocale;
 415     }
 416 
 417     private static boolean isSupportedCalendarLocale(Locale locale) {
 418         Locale base = locale.stripExtensions();
 419         if (!supportedLocaleSet.contains(base)) {
 420             return false;
 421         }
 422 





 423         String requestedCalType = locale.getUnicodeLocaleType("ca");
 424         String nativeCalType =
 425                 calIDToLDML[getCalendarID(locale.toLanguageTag())]
 426                 .replaceFirst("_.*", ""); // remove locale part.
 427 
 428         if (requestedCalType == null) {
 429             return Calendar.getAvailableCalendarTypes().contains(nativeCalType);
 430         } else {
 431             return requestedCalType.equals(nativeCalType);
 432         }
 433     }
 434 
 435     private static Locale[] getSupportedNativeDigitLocales() {
 436         if (supportedLocale.length != 0 &&
 437             supportedLocaleSet.contains(JRELocaleConstants.TH_TH) &&
 438             isNativeDigit("th-TH")) {
 439             Locale[] sup = new Locale[supportedLocale.length+1];
 440             sup[0] = JRELocaleConstants.TH_TH_TH;
 441             System.arraycopy(supportedLocale, 0, sup, 1, supportedLocale.length);
 442             return sup;
 443         }
 444         return supportedLocale;
 445     }




 286                 SoftReference<DecimalFormatSymbols> ref =
 287                     decimalFormatSymbolsCache.get(locale);
 288 
 289                 if (ref == null || (dfs = ref.get()) == null) {
 290                     dfs = new DecimalFormatSymbols(getNumberLocale(locale));
 291                     String langTag = removeExtensions(locale).toLanguageTag();
 292 
 293                     // DecimalFormatSymbols.setInternationalCurrencySymbol() has
 294                     // a side effect of setting the currency symbol as well. So
 295                     // the calling order is relevant here.
 296                     dfs.setInternationalCurrencySymbol(getInternationalCurrencySymbol(langTag, dfs.getInternationalCurrencySymbol()));
 297                     dfs.setCurrencySymbol(getCurrencySymbol(langTag, dfs.getCurrencySymbol()));
 298                     dfs.setDecimalSeparator(getDecimalSeparator(langTag, dfs.getDecimalSeparator()));
 299                     dfs.setGroupingSeparator(getGroupingSeparator(langTag, dfs.getGroupingSeparator()));
 300                     dfs.setInfinity(getInfinity(langTag, dfs.getInfinity()));
 301                     dfs.setMinusSign(getMinusSign(langTag, dfs.getMinusSign()));
 302                     dfs.setMonetaryDecimalSeparator(getMonetaryDecimalSeparator(langTag, dfs.getMonetaryDecimalSeparator()));
 303                     dfs.setNaN(getNaN(langTag, dfs.getNaN()));
 304                     dfs.setPercent(getPercent(langTag, dfs.getPercent()));
 305                     dfs.setPerMill(getPerMill(langTag, dfs.getPerMill()));

 306                     dfs.setZeroDigit(getZeroDigit(langTag, dfs.getZeroDigit()));

 307                     ref = new SoftReference<>(dfs);
 308                     decimalFormatSymbolsCache.put(locale, ref);
 309                 }
 310                 return (DecimalFormatSymbols)dfs.clone();
 311             }
 312         };
 313     }
 314 
 315     public static CalendarDataProvider getCalendarDataProvider() {
 316         return new CalendarDataProvider() {
 317             @Override
 318             public Locale[] getAvailableLocales() {
 319                 return getSupportedCalendarLocales();
 320             }
 321 
 322             @Override
 323             public boolean isSupportedLocale(Locale locale) {
 324                 return isSupportedCalendarLocale(locale);
 325             }
 326 


 401     }
 402 
 403     private static Locale[] getSupportedCalendarLocales() {
 404         if (supportedLocale.length != 0 &&
 405             supportedLocaleSet.contains(Locale.JAPAN) &&
 406             isJapaneseCalendar()) {
 407             Locale[] sup = new Locale[supportedLocale.length+1];
 408             sup[0] = JRELocaleConstants.JA_JP_JP;
 409             System.arraycopy(supportedLocale, 0, sup, 1, supportedLocale.length);
 410             return sup;
 411         }
 412         return supportedLocale;
 413     }
 414 
 415     private static boolean isSupportedCalendarLocale(Locale locale) {
 416         Locale base = locale.stripExtensions();
 417         if (!supportedLocaleSet.contains(base)) {
 418             return false;
 419         }
 420 
 421         int calid = getCalendarID(locale.toLanguageTag());
 422         if (calid <= 0 || calid >= calIDToLDML.length) {
 423             return false;
 424         }
 425 
 426         String requestedCalType = locale.getUnicodeLocaleType("ca");
 427         String nativeCalType = calIDToLDML[calid]

 428                 .replaceFirst("_.*", ""); // remove locale part.
 429 
 430         if (requestedCalType == null) {
 431             return Calendar.getAvailableCalendarTypes().contains(nativeCalType);
 432         } else {
 433             return requestedCalType.equals(nativeCalType);
 434         }
 435     }
 436 
 437     private static Locale[] getSupportedNativeDigitLocales() {
 438         if (supportedLocale.length != 0 &&
 439             supportedLocaleSet.contains(JRELocaleConstants.TH_TH) &&
 440             isNativeDigit("th-TH")) {
 441             Locale[] sup = new Locale[supportedLocale.length+1];
 442             sup[0] = JRELocaleConstants.TH_TH_TH;
 443             System.arraycopy(supportedLocale, 0, sup, 1, supportedLocale.length);
 444             return sup;
 445         }
 446         return supportedLocale;
 447     }