private static LocaleCode getByCombinedCode(String code, boolean caseSensitive, int splitPosition) { // Get the character that separates the language code from the country code. char separator = code.charAt(splitPosition); if (separator == '_') { if (caseSensitive && splitPosition == 2) { // The given code can be handled as enum name. return getByEnumName(code); } } else if (separator != '-') { // Bad format. return null; } // Extract the language part and the country part from the given code. String language = code.substring(0, splitPosition); String country = code.substring(splitPosition + 1); return getByCode(language, country, caseSensitive); }
private static LocaleCode getByCombinedCode(String code, boolean caseSensitive, int splitPosition) { // Get the character that separates the language code from the country code. char separator = code.charAt(splitPosition); if (separator == '_') { if (caseSensitive && splitPosition == 2) { // The given code can be handled as enum name. return getByEnumName(code); } } else if (separator != '-') { // Bad format. return null; } // Extract the language part and the country part from the given code. String language = code.substring(0, splitPosition); String country = code.substring(splitPosition + 1); return getByCode(language, country, caseSensitive); }
return getByEnumName(language); return getByEnumName(language + "_" + country);
return getByEnumName(language); return getByEnumName(language + "_" + country);