2306 * </li> 2307 * </ol> 2308 * 2309 * <p>The default implementation uses an {@link ArrayList} that 2310 * overriding implementations may modify before returning it to the 2311 * caller. However, a subclass must not modify it after it has 2312 * been returned by <code>getCandidateLocales</code>. 2313 * 2314 * <p>For example, if the given <code>baseName</code> is "Messages" 2315 * and the given <code>locale</code> is 2316 * <code>Locale("ja", "", "XX")</code>, then a 2317 * <code>List</code> of <code>Locale</code>s: 2318 * <pre> 2319 * Locale("ja", "", "XX") 2320 * Locale("ja") 2321 * Locale.ROOT 2322 * </pre> 2323 * is returned. And if the resource bundles for the "ja" and 2324 * "" <code>Locale</code>s are found, then the runtime resource 2325 * lookup path (parent chain) is: 2326 * <pre> 2327 * Messages_ja -> Messages 2328 * </pre> 2329 * 2330 * @param baseName 2331 * the base name of the resource bundle, a fully 2332 * qualified class name 2333 * @param locale 2334 * the locale for which a resource bundle is desired 2335 * @return a <code>List</code> of candidate 2336 * <code>Locale</code>s for the given <code>locale</code> 2337 * @exception NullPointerException 2338 * if <code>baseName</code> or <code>locale</code> is 2339 * <code>null</code> 2340 */ 2341 public List<Locale> getCandidateLocales(String baseName, Locale locale) { 2342 if (baseName == null) { 2343 throw new NullPointerException(); 2344 } 2345 return new ArrayList<>(CANDIDATES_CACHE.get(locale.getBaseLocale())); 2346 } 2347 2348 private static final CandidateListCache CANDIDATES_CACHE = new CandidateListCache(); | 2306 * </li> 2307 * </ol> 2308 * 2309 * <p>The default implementation uses an {@link ArrayList} that 2310 * overriding implementations may modify before returning it to the 2311 * caller. However, a subclass must not modify it after it has 2312 * been returned by <code>getCandidateLocales</code>. 2313 * 2314 * <p>For example, if the given <code>baseName</code> is "Messages" 2315 * and the given <code>locale</code> is 2316 * <code>Locale("ja", "", "XX")</code>, then a 2317 * <code>List</code> of <code>Locale</code>s: 2318 * <pre> 2319 * Locale("ja", "", "XX") 2320 * Locale("ja") 2321 * Locale.ROOT 2322 * </pre> 2323 * is returned. And if the resource bundles for the "ja" and 2324 * "" <code>Locale</code>s are found, then the runtime resource 2325 * lookup path (parent chain) is: 2326 * <pre>{@code 2327 * Messages_ja -> Messages 2328 * }</pre> 2329 * 2330 * @param baseName 2331 * the base name of the resource bundle, a fully 2332 * qualified class name 2333 * @param locale 2334 * the locale for which a resource bundle is desired 2335 * @return a <code>List</code> of candidate 2336 * <code>Locale</code>s for the given <code>locale</code> 2337 * @exception NullPointerException 2338 * if <code>baseName</code> or <code>locale</code> is 2339 * <code>null</code> 2340 */ 2341 public List<Locale> getCandidateLocales(String baseName, Locale locale) { 2342 if (baseName == null) { 2343 throw new NullPointerException(); 2344 } 2345 return new ArrayList<>(CANDIDATES_CACHE.get(locale.getBaseLocale())); 2346 } 2347 2348 private static final CandidateListCache CANDIDATES_CACHE = new CandidateListCache(); |