208 category = "AvailableLocales";
209
210 // Directly call Base tags, as we know it's in the base module.
211 String supportedLocaleString = baseMetaInfo.availableLanguageTags(category);
212 String nonBaseTags = null;
213
214 if (nonBaseMetaInfo != null) {
215 nonBaseTags = nonBaseMetaInfo.availableLanguageTags(category);
216 }
217 if (nonBaseTags != null) {
218 if (supportedLocaleString != null) {
219 supportedLocaleString += " " + nonBaseTags;
220 } else {
221 supportedLocaleString = nonBaseTags;
222 }
223 }
224 if (supportedLocaleString == null) {
225 return Collections.emptySet();
226 }
227 StringTokenizer tokens = new StringTokenizer(supportedLocaleString);
228 Set<String> tagset = new HashSet<>(Math.max((int)(tokens.countTokens() / 0.75f) + 1, 16));
229 while (tokens.hasMoreTokens()) {
230 tagset.add(tokens.nextToken());
231 }
232 return tagset;
233 }
234
235 // Implementation of ResourceBundleBasedAdapter
236 @Override
237 public List<Locale> getCandidateLocales(String baseName, Locale locale) {
238 List<Locale> candidates = super.getCandidateLocales(baseName, applyAliases(locale));
239 return applyParentLocales(baseName, candidates);
240 }
241
242 private List<Locale> applyParentLocales(String baseName, List<Locale> candidates) {
243 // check irregular parents
244 for (int i = 0; i < candidates.size(); i++) {
245 Locale l = candidates.get(i);
246 if (!l.equals(Locale.ROOT)) {
247 Locale p = getParentLocale(l);
248 if (p != null &&
|
208 category = "AvailableLocales";
209
210 // Directly call Base tags, as we know it's in the base module.
211 String supportedLocaleString = baseMetaInfo.availableLanguageTags(category);
212 String nonBaseTags = null;
213
214 if (nonBaseMetaInfo != null) {
215 nonBaseTags = nonBaseMetaInfo.availableLanguageTags(category);
216 }
217 if (nonBaseTags != null) {
218 if (supportedLocaleString != null) {
219 supportedLocaleString += " " + nonBaseTags;
220 } else {
221 supportedLocaleString = nonBaseTags;
222 }
223 }
224 if (supportedLocaleString == null) {
225 return Collections.emptySet();
226 }
227 StringTokenizer tokens = new StringTokenizer(supportedLocaleString);
228 Set<String> tagset = new HashSet<>((tokens.countTokens() * 4 + 2) / 3);
229 while (tokens.hasMoreTokens()) {
230 tagset.add(tokens.nextToken());
231 }
232 return tagset;
233 }
234
235 // Implementation of ResourceBundleBasedAdapter
236 @Override
237 public List<Locale> getCandidateLocales(String baseName, Locale locale) {
238 List<Locale> candidates = super.getCandidateLocales(baseName, applyAliases(locale));
239 return applyParentLocales(baseName, candidates);
240 }
241
242 private List<Locale> applyParentLocales(String baseName, List<Locale> candidates) {
243 // check irregular parents
244 for (int i = 0; i < candidates.size(); i++) {
245 Locale l = candidates.get(i);
246 if (!l.equals(Locale.ROOT)) {
247 Locale p = getParentLocale(l);
248 if (p != null &&
|