if (matcher.matches())
{
String language = matcher.group(1);
if (Arrays.binarySearch(SORTED_ISO_LANGUAGES, language) < 0)
{
throw new FormatConversionException("Invalid ISO language code: " + language);
}
String country = matcher.group(3);
if (country == null)
{
return new Locale(language);
}
else if (Arrays.binarySearch(SORTED_ISO_COUNTRIES, country) < 0)
{
throw new FormatConversionException("Invalid ISO country code: " + country);
}
return new Locale(language, country);
}
throw new FormatConversionException(value + " is not a valid compound language : accepted " +
"format is xx-YY where xx is a valid ISO language code and YY is a valid country code. See " +
"java.util.Locale javadoc for more info.");
}