LocaleInfo implements Cloneable, Externalizable { public static LocaleInfo parse(String name) { name = assertNotNull(StringUtil.trimToNull(name), "no locale name"); int index = name.indexOf(":"); String localePart = name; String charsetPart = null; if (index >= 0) { localePart = name.substring(0, index); charsetPart = name.substring(index + 1); } Locale locale = LocaleUtil.parseLocale(localePart); String charset = StringUtil.trimToNull(charsetPart); return new LocaleInfo(locale, charset); } LocaleInfo();  LocaleInfo(Locale locale);  LocaleInfo(Locale locale, String charset);   LocaleInfo(Locale locale, String charset, LocaleInfo fallbackLocaleInfo); static LocaleInfo parse(String name); Locale getLocale(); Charset getCharset(); boolean isCharsetSupported(); LocaleInfo assertCharsetSupported(); @Override boolean equals(Object o); @Override int hashCode(); @Override Object clone(); void writeExternal(ObjectOutput out); void readExternal(ObjectInput in); @Override String toString();  }
@Test public void parse() { try { localeInfo = LocaleInfo.parse(null); fail(); } catch (IllegalArgumentException e) { assertThat(e, TestUtil.exception("no locale name")); } try { localeInfo = LocaleInfo.parse(" "); fail(); } catch (IllegalArgumentException e) { assertThat(e, TestUtil.exception("no locale name")); } assertEquals("en_US:UTF-8", LocaleInfo.parse(" en_US ").toString()); assertEquals("en_US:UTF-8", LocaleInfo.parse(" en_US : ").toString()); assertEquals("en_US:ISO-8859-1", LocaleInfo.parse(" en_US : 8859_1").toString()); }