184 return rb;
185 }
186 });
187 }
188
189 private static class LocaleDataResourceBundleControl extends ResourceBundle.Control {
190 /* Singlton instance of ResourceBundle.Control. */
191 private static final LocaleDataResourceBundleControl INSTANCE =
192 new LocaleDataResourceBundleControl();
193
194 private LocaleDataResourceBundleControl() {
195 }
196
197 /*
198 * This method overrides the default implementation to search
199 * from a prebaked locale string list to determin the candidate
200 * locale list.
201 *
202 * @param baseName the resource bundle base name.
203 * locale the requested locale for the resource bundle.
204 * @returns a list of candidate locales to search from.
205 * @exception NullPointerException if baseName or locale is null.
206 */
207 @Override
208 public List<Locale> getCandidateLocales(String baseName, Locale locale) {
209 LocaleProviderAdapter.Type type = baseName.contains(DOTCLDR) ? CLDR : JRE;
210 LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type);
211 List<Locale> candidates = adapter instanceof ResourceBundleBasedAdapter ?
212 ((ResourceBundleBasedAdapter)adapter).getCandidateLocales(baseName, locale) :
213 super.getCandidateLocales(baseName, locale);
214
215 // Weed out Locales which are known to have no resource bundles
216 int lastDot = baseName.lastIndexOf('.');
217 String category = (lastDot >= 0) ? baseName.substring(lastDot + 1) : baseName;
218 Set<String> langtags = ((JRELocaleProviderAdapter)adapter).getLanguageTagSet(category);
219 if (!langtags.isEmpty()) {
220 for (Iterator<Locale> itr = candidates.iterator(); itr.hasNext();) {
221 if (!adapter.isSupportedProviderLocale(itr.next(), langtags)) {
222 itr.remove();
223 }
224 }
|
184 return rb;
185 }
186 });
187 }
188
189 private static class LocaleDataResourceBundleControl extends ResourceBundle.Control {
190 /* Singlton instance of ResourceBundle.Control. */
191 private static final LocaleDataResourceBundleControl INSTANCE =
192 new LocaleDataResourceBundleControl();
193
194 private LocaleDataResourceBundleControl() {
195 }
196
197 /*
198 * This method overrides the default implementation to search
199 * from a prebaked locale string list to determin the candidate
200 * locale list.
201 *
202 * @param baseName the resource bundle base name.
203 * locale the requested locale for the resource bundle.
204 * @return a list of candidate locales to search from.
205 * @exception NullPointerException if baseName or locale is null.
206 */
207 @Override
208 public List<Locale> getCandidateLocales(String baseName, Locale locale) {
209 LocaleProviderAdapter.Type type = baseName.contains(DOTCLDR) ? CLDR : JRE;
210 LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type);
211 List<Locale> candidates = adapter instanceof ResourceBundleBasedAdapter ?
212 ((ResourceBundleBasedAdapter)adapter).getCandidateLocales(baseName, locale) :
213 super.getCandidateLocales(baseName, locale);
214
215 // Weed out Locales which are known to have no resource bundles
216 int lastDot = baseName.lastIndexOf('.');
217 String category = (lastDot >= 0) ? baseName.substring(lastDot + 1) : baseName;
218 Set<String> langtags = ((JRELocaleProviderAdapter)adapter).getLanguageTagSet(category);
219 if (!langtags.isEmpty()) {
220 for (Iterator<Locale> itr = candidates.iterator(); itr.hasNext();) {
221 if (!adapter.isSupportedProviderLocale(itr.next(), langtags)) {
222 itr.remove();
223 }
224 }
|