/** * Adds a unicode locale attribute, if not already present, otherwise * has no effect. The attribute must not be null and must be well-formed * or an exception is thrown. * * @param attribute the attribute * @return This builder. * @throws NullPointerException if <code>attribute</code> is null * @throws IllformedLocaleException if <code>attribute</code> is ill-formed * @see #setExtension(char, String) * * @stable ICU 4.6 */ public Builder addUnicodeLocaleAttribute(String attribute) { try { _locbld.addUnicodeLocaleAttribute(attribute); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
/** * @param extensionString * @param where * @return */ private boolean isValidLocale(String extensionString, Where where) { try { ULocale locale = new ULocale.Builder().setLanguageTag(extensionString).build(); return isValid(locale, where); } catch (IllformedLocaleException e) { int startIndex = e.getErrorIndex(); String[] list = SEPARATOR.split(extensionString.substring(startIndex)); return where.set(Datatype.t, list[0]); } catch (Exception e) { return where.set(Datatype.t, e.getMessage()); } }
ulocale = new ULocale.Builder().setLanguageTag(langtag).build(); } catch (com.ibm.icu.util.IllformedLocaleException e) { throw new IllegalArgumentException(e.getMessage());
/** * Sets the script. If <code>script</code> is null or the empty string, * the script in this <code>Builder</code> is removed. * Otherwise, the script must be well-formed or an exception is thrown. * * <p>The typical script value is a four-letter script code as defined by ISO 15924. * * @param script the script * @return This builder. * @throws IllformedLocaleException if <code>script</code> is ill-formed * * @stable ICU 4.2 */ public Builder setScript(String script) { try { _locbld.setScript(script); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
/** * Adds a unicode locale attribute, if not already present, otherwise * has no effect. The attribute must not be null and must be well-formed * or an exception is thrown. * * @param attribute the attribute * @return This builder. * @throws NullPointerException if <code>attribute</code> is null * @throws IllformedLocaleException if <code>attribute</code> is ill-formed * @see #setExtension(char, String) * * @draft ICU 4.6 * @provisional This API might change or be removed in a future release. */ public Builder addUnicodeLocaleAttribute(String attribute) { try { _locbld.addUnicodeLocaleAttribute(attribute); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
/** * Sets the language. If <code>language</code> is the empty string or * null, the language in this <code>Builder</code> is removed. Otherwise, * the language must be <a href="./Locale.html#def_language">well-formed</a> * or an exception is thrown. * * <p>The typical language value is a two or three-letter language * code as defined in ISO639. * * @param language the language * @return This builder. * @throws IllformedLocaleException if <code>language</code> is ill-formed * * @draft ICU 4.2 * @provisional This API might change or be removed in a future release. */ public Builder setLanguage(String language) { try { _locbld.setLanguage(language); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
/** * Sets the script. If <code>script</code> is null or the empty string, * the script in this <code>Builder</code> is removed. * Otherwise, the script must be well-formed or an exception is thrown. * * <p>The typical script value is a four-letter script code as defined by ISO 15924. * * @param script the script * @return This builder. * @throws IllformedLocaleException if <code>script</code> is ill-formed * * @draft ICU 4.2 * @provisional This API might change or be removed in a future release. */ public Builder setScript(String script) { try { _locbld.setScript(script); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
/** * Sets the language. If <code>language</code> is the empty string or * null, the language in this <code>Builder</code> is removed. Otherwise, * the language must be <a href="./Locale.html#def_language">well-formed</a> * or an exception is thrown. * * <p>The typical language value is a two or three-letter language * code as defined in ISO639. * * @param language the language * @return This builder. * @throws IllformedLocaleException if <code>language</code> is ill-formed * * @stable ICU 4.2 */ public Builder setLanguage(String language) { try { _locbld.setLanguage(language); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
/** * Removes a unicode locale attribute, if present, otherwise has no * effect. The attribute must not be null and must be well-formed * or an exception is thrown. * * <p>Attribute comparision for removal is case-insensitive. * * @param attribute the attribute * @return This builder. * @throws NullPointerException if <code>attribute</code> is null * @throws IllformedLocaleException if <code>attribute</code> is ill-formed * @see #setExtension(char, String) * * @stable ICU 4.6 */ public Builder removeUnicodeLocaleAttribute(String attribute) { try { _locbld.removeUnicodeLocaleAttribute(attribute); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
/** * Sets the region. If region is null or the empty string, the region * in this <code>Builder</code> is removed. Otherwise, * the region must be well-formed or an exception is thrown. * * <p>The typical region value is a two-letter ISO 3166 code or a * three-digit UN M.49 area code. * * <p>The country value in the <code>Locale</code> created by the * <code>Builder</code> is always normalized to upper case. * * @param region the region * @return This builder. * @throws IllformedLocaleException if <code>region</code> is ill-formed * * @draft ICU 4.2 * @provisional This API might change or be removed in a future release. */ public Builder setRegion(String region) { try { _locbld.setRegion(region); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
/** * Removes a unicode locale attribute, if present, otherwise has no * effect. The attribute must not be null and must be well-formed * or an exception is thrown. * * <p>Attribute comparision for removal is case-insensitive. * * @param attribute the attribute * @return This builder. * @throws NullPointerException if <code>attribute</code> is null * @throws IllformedLocaleException if <code>attribute</code> is ill-formed * @see #setExtension(char, String) * * @draft ICU 4.6 * @provisional This API might change or be removed in a future release. */ public Builder removeUnicodeLocaleAttribute(String attribute) { try { _locbld.removeUnicodeLocaleAttribute(attribute); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
/** * Sets the script. If <code>script</code> is null or the empty string, * the script in this <code>Builder</code> is removed. * Otherwise, the script must be well-formed or an exception is thrown. * * <p>The typical script value is a four-letter script code as defined by ISO 15924. * * @param script the script * @return This builder. * @throws IllformedLocaleException if <code>script</code> is ill-formed * * @draft ICU 4.2 * @provisional This API might change or be removed in a future release. */ public Builder setScript(String script) { try { _locbld.setScript(script); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
/** * Adds a unicode locale attribute, if not already present, otherwise * has no effect. The attribute must not be null and must be well-formed * or an exception is thrown. * * @param attribute the attribute * @return This builder. * @throws NullPointerException if <code>attribute</code> is null * @throws IllformedLocaleException if <code>attribute</code> is ill-formed * @see #setExtension(char, String) * * @draft ICU 4.6 * @provisional This API might change or be removed in a future release. */ public Builder addUnicodeLocaleAttribute(String attribute) { try { _locbld.addUnicodeLocaleAttribute(attribute); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
/** * Resets the <code>Builder</code> to match the provided * <code>locale</code>. Existing state is discarded. * * <p>All fields of the locale must be well-formed, see {@link Locale}. * * <p>Locales with any ill-formed fields cause * <code>IllformedLocaleException</code> to be thrown. * * @param locale the locale * @return This builder. * @throws IllformedLocaleException if <code>locale</code> has * any ill-formed fields. * @throws NullPointerException if <code>locale</code> is null. * * @draft ICU 4.2 * @provisional This API might change or be removed in a future release. */ public Builder setLocale(ULocale locale) { try { _locbld.setLocale(locale.base(), locale.extensions()); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
/** * Sets the region. If region is null or the empty string, the region * in this <code>Builder</code> is removed. Otherwise, * the region must be well-formed or an exception is thrown. * * <p>The typical region value is a two-letter ISO 3166 code or a * three-digit UN M.49 area code. * * <p>The country value in the <code>Locale</code> created by the * <code>Builder</code> is always normalized to upper case. * * @param region the region * @return This builder. * @throws IllformedLocaleException if <code>region</code> is ill-formed * * @draft ICU 4.2 * @provisional This API might change or be removed in a future release. */ public Builder setRegion(String region) { try { _locbld.setRegion(region); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
/** * Sets the region. If region is null or the empty string, the region * in this <code>Builder</code> is removed. Otherwise, * the region must be well-formed or an exception is thrown. * * <p>The typical region value is a two-letter ISO 3166 code or a * three-digit UN M.49 area code. * * <p>The country value in the <code>Locale</code> created by the * <code>Builder</code> is always normalized to upper case. * * @param region the region * @return This builder. * @throws IllformedLocaleException if <code>region</code> is ill-formed * * @stable ICU 4.2 */ public Builder setRegion(String region) { try { _locbld.setRegion(region); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
/** * Sets the variant. If variant is null or the empty string, the * variant in this <code>Builder</code> is removed. Otherwise, it * must consist of one or more well-formed subtags, or an exception is thrown. * * <p><b>Note:</b> This method checks if <code>variant</code> * satisfies the IETF BCP 47 variant subtag's syntax requirements, * and normalizes the value to lowercase letters. However, * the <code>ULocale</code> class does not impose any syntactic * restriction on variant. To set such a variant, * use a ULocale constructor. * * @param variant the variant * @return This builder. * @throws IllformedLocaleException if <code>variant</code> is ill-formed * * @stable ICU 4.2 */ public Builder setVariant(String variant) { try { _locbld.setVariant(variant); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
/** * Resets the <code>Builder</code> to match the provided * <code>locale</code>. Existing state is discarded. * * <p>All fields of the locale must be well-formed, see {@link Locale}. * * <p>Locales with any ill-formed fields cause * <code>IllformedLocaleException</code> to be thrown. * * @param locale the locale * @return This builder. * @throws IllformedLocaleException if <code>locale</code> has * any ill-formed fields. * @throws NullPointerException if <code>locale</code> is null. * * @draft ICU 4.2 * @provisional This API might change or be removed in a future release. */ public Builder setLocale(ULocale locale) { try { _locbld.setLocale(locale.base(), locale.extensions()); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
/** * Sets the language. If <code>language</code> is the empty string or * null, the language in this <code>Builder</code> is removed. Otherwise, * the language must be <a href="./Locale.html#def_language">well-formed</a> * or an exception is thrown. * * <p>The typical language value is a two or three-letter language * code as defined in ISO639. * * @param language the language * @return This builder. * @throws IllformedLocaleException if <code>language</code> is ill-formed * * @draft ICU 4.2 * @provisional This API might change or be removed in a future release. */ public Builder setLanguage(String language) { try { _locbld.setLanguage(language); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
/** * Removes a unicode locale attribute, if present, otherwise has no * effect. The attribute must not be null and must be well-formed * or an exception is thrown. * * <p>Attribute comparision for removal is case-insensitive. * * @param attribute the attribute * @return This builder. * @throws NullPointerException if <code>attribute</code> is null * @throws IllformedLocaleException if <code>attribute</code> is ill-formed * @see #setExtension(char, String) * * @draft ICU 4.6 * @provisional This API might change or be removed in a future release. */ public Builder removeUnicodeLocaleAttribute(String attribute) { try { _locbld.removeUnicodeLocaleAttribute(attribute); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }