/** * Validate the given code. * * @param stringCode * the string code * @return true, if successful */ public static boolean validate(final String stringCode) { return LocaleCode.getByCode(stringCode) != null; }
/** * Get a {@code LocaleCode} instance that corresponds to the given code. * * <p> * This method just calls {@link #getByCode(String, boolean) getByCode}{@code (code, false)}. * </p> * * @param code * A locale code. * * @return * A {@code LocaleCode} instance, or {@code null} if not found. * * @since 1.13 * * @see #getByCode(String, boolean) */ public static LocaleCode getByCodeIgnoreCase(String code) { return getByCode(code, false); }
/** * Get a {@code LocaleCode} instance that corresponds to the given code. * * <p> * This method just calls {@link #getByCode(String, boolean) getByCode}{@code (code, true)}. * Note that the behavior has changed since the version 1.13. In the older versions, * this method was an alias of {@code getByCode(code, false)}. * </p> * * @param code * A locale code. * * @return * A {@code LocaleCode} instance, or {@code null} if not found. * * @see #getByCode(String, boolean) */ public static LocaleCode getByCode(String code) { return getByCode(code, true); }
/** * Get a {@code LocaleCode} instance that corresponds to the given code. * * <p> * This method just calls {@link #getByCode(String, boolean) getByCode}{@code (code, true)}. * Note that the behavior has changed since the version 1.13. In the older versions, * this method was an alias of {@code getByCode(code, false)}. * </p> * * @param code * A locale code. * * @return * A {@code LocaleCode} instance, or {@code null} if not found. * * @see #getByCode(String, boolean) */ public static LocaleCode getByCode(String code) { return getByCode(code, true); }
/** * Get a {@code LocaleCode} instance that corresponds to the given code. * * <p> * This method just calls {@link #getByCode(String, boolean) getByCode}{@code (code, false)}. * </p> * * @param code * A locale code. * * @return * A {@code LocaleCode} instance, or {@code null} if not found. * * @since 1.13 * * @see #getByCode(String, boolean) */ public static LocaleCode getByCodeIgnoreCase(String code) { return getByCode(code, false); }
return getByCode(language, country, false);
return getByCode(language, country, true);
return getByCode(language, country, false);
return getByCode(language, country, true);
return getByCode(language, country, true);
return getByCode(language, country, true);
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); }
case 9: return getByCode(code, null, caseSensitive);
case 9: return getByCode(code, null, caseSensitive);