< prev index next >

src/java.base/share/classes/java/util/ResourceBundle.java

Print this page
rev 52979 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: TBD

*** 769,780 **** } @Override public String toString() { String l = locale.toString(); ! if (l.length() == 0) { ! if (locale.getVariant().length() != 0) { l = "__" + locale.getVariant(); } else { l = "\"\""; } } --- 769,780 ---- } @Override public String toString() { String l = locale.toString(); ! if (l.isEmpty()) { ! if (!locale.getVariant().isEmpty()) { l = "__" + locale.getVariant(); } else { l = "\"\""; } }
*** 2901,2911 **** List<Locale> tmpList = getDefaultList("nb", script, region, variant); // Insert a locale replacing "nb" with "no" for every list entry List<Locale> bokmalList = new LinkedList<>(); for (Locale l : tmpList) { bokmalList.add(l); ! if (l.getLanguage().length() == 0) { break; } bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(), l.getVariant(), null)); } --- 2901,2911 ---- List<Locale> tmpList = getDefaultList("nb", script, region, variant); // Insert a locale replacing "nb" with "no" for every list entry List<Locale> bokmalList = new LinkedList<>(); for (Locale l : tmpList) { bokmalList.add(l); ! if (l.getLanguage().isEmpty()) { break; } bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(), l.getVariant(), null)); }
*** 2919,2929 **** nynorskList.add(idx++, Locale.getInstance("no", "", "")); return nynorskList; } // Special handling for Chinese else if (language.equals("zh")) { ! if (script.length() == 0 && region.length() > 0) { // Supply script for users who want to use zh_Hans/zh_Hant // as bundle names (recommended for Java7+) switch (region) { case "TW": case "HK": --- 2919,2929 ---- nynorskList.add(idx++, Locale.getInstance("no", "", "")); return nynorskList; } // Special handling for Chinese else if (language.equals("zh")) { ! if (script.isEmpty() && !region.isEmpty()) { // Supply script for users who want to use zh_Hans/zh_Hant // as bundle names (recommended for Java7+) switch (region) { case "TW": case "HK":
*** 2942,2952 **** } private static List<Locale> getDefaultList(String language, String script, String region, String variant) { List<String> variants = null; ! if (variant.length() > 0) { variants = new LinkedList<>(); int idx = variant.length(); while (idx != -1) { variants.add(variant.substring(0, idx)); idx = variant.lastIndexOf('_', --idx); --- 2942,2952 ---- } private static List<Locale> getDefaultList(String language, String script, String region, String variant) { List<String> variants = null; ! if (!variant.isEmpty()) { variants = new LinkedList<>(); int idx = variant.length(); while (idx != -1) { variants.add(variant.substring(0, idx)); idx = variant.lastIndexOf('_', --idx);
*** 2958,2975 **** if (variants != null) { for (String v : variants) { list.add(Locale.getInstance(language, script, region, v, null)); } } ! if (region.length() > 0) { list.add(Locale.getInstance(language, script, region, "", null)); } ! if (script.length() > 0) { list.add(Locale.getInstance(language, script, "", "", null)); // Special handling for Chinese if (language.equals("zh")) { ! if (region.length() == 0) { // Supply region(country) for users who still package Chinese // bundles using old convension. switch (script) { case "Hans": region = "CN"; --- 2958,2975 ---- if (variants != null) { for (String v : variants) { list.add(Locale.getInstance(language, script, region, v, null)); } } ! if (!region.isEmpty()) { list.add(Locale.getInstance(language, script, region, "", null)); } ! if (!script.isEmpty()) { list.add(Locale.getInstance(language, script, "", "", null)); // Special handling for Chinese if (language.equals("zh")) { ! if (region.isEmpty()) { // Supply region(country) for users who still package Chinese // bundles using old convension. switch (script) { case "Hans": region = "CN";
*** 2986,3000 **** if (variants != null) { for (String v : variants) { list.add(Locale.getInstance(language, "", region, v, null)); } } ! if (region.length() > 0) { list.add(Locale.getInstance(language, "", region, "", null)); } } ! if (language.length() > 0) { list.add(Locale.getInstance(language, "", "", "", null)); } // Add root locale at the end list.add(Locale.ROOT); --- 2986,3000 ---- if (variants != null) { for (String v : variants) { list.add(Locale.getInstance(language, "", region, v, null)); } } ! if (!region.isEmpty()) { list.add(Locale.getInstance(language, "", region, "", null)); } } ! if (!language.isEmpty()) { list.add(Locale.getInstance(language, "", "", "", null)); } // Add root locale at the end list.add(Locale.ROOT);
< prev index next >