Java Code Examples for sun.util.locale.LocaleSyntaxException#getErrorIndex()
The following examples show how to use
sun.util.locale.LocaleSyntaxException#getErrorIndex() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Locale.java From openjdk-jdk8u with GNU General Public License v2.0 | 3 votes |
/** * 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, except for the * following three cases which are accepted for compatibility * reasons:<ul> * <li>Locale("ja", "JP", "JP") is treated as "ja-JP-u-ca-japanese" * <li>Locale("th", "TH", "TH") is treated as "th-TH-u-nu-thai" * <li>Locale("no", "NO", "NY") is treated as "nn-NO"</ul> * * @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. */ public Builder setLocale(Locale locale) { try { localeBuilder.setLocale(locale.baseLocale, locale.localeExtensions); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
Example 2
Source File: Locale.java From jdk8u-jdk with GNU General Public License v2.0 | 3 votes |
/** * 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, except for the * following three cases which are accepted for compatibility * reasons:<ul> * <li>Locale("ja", "JP", "JP") is treated as "ja-JP-u-ca-japanese" * <li>Locale("th", "TH", "TH") is treated as "th-TH-u-nu-thai" * <li>Locale("no", "NO", "NY") is treated as "nn-NO"</ul> * * @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. */ public Builder setLocale(Locale locale) { try { localeBuilder.setLocale(locale.baseLocale, locale.localeExtensions); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
Example 3
Source File: Locale.java From Bytecoder with Apache License 2.0 | 3 votes |
/** * Removes a unicode locale attribute, if present, otherwise has no * effect. The attribute must not be null and must be <a * href="./Locale.html#def_locale_extension">well-formed</a> or an exception * is thrown. * * <p>Attribute comparison for removal is case-insensitive. * * @param attribute the attribute * @return This builder. * @throws NullPointerException if {@code attribute} is null * @throws IllformedLocaleException if {@code attribute} is ill-formed * @see #setExtension(char, String) */ public Builder removeUnicodeLocaleAttribute(String attribute) { Objects.requireNonNull(attribute); try { localeBuilder.removeUnicodeLocaleAttribute(attribute); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
Example 4
Source File: Locale.java From JDKSourceCode1.8 with MIT License | 3 votes |
/** * 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 <a href="./Locale.html#def_script">well-formed</a> 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 */ public Builder setScript(String script) { try { localeBuilder.setScript(script); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
Example 5
Source File: Locale.java From dragonwell8_jdk with GNU General Public License v2.0 | 3 votes |
/** * Adds a unicode locale attribute, if not already present, otherwise * has no effect. The attribute must not be null and must be <a * href="./Locale.html#def_locale_extension">well-formed</a> 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) */ public Builder addUnicodeLocaleAttribute(String attribute) { try { localeBuilder.addUnicodeLocaleAttribute(attribute); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
Example 6
Source File: Locale.java From jdk8u60 with GNU General Public License v2.0 | 3 votes |
/** * Removes a unicode locale attribute, if present, otherwise has no * effect. The attribute must not be null and must be <a * href="./Locale.html#def_locale_extension">well-formed</a> 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) */ public Builder removeUnicodeLocaleAttribute(String attribute) { try { localeBuilder.removeUnicodeLocaleAttribute(attribute); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
Example 7
Source File: Locale.java From dragonwell8_jdk with GNU General Public License v2.0 | 3 votes |
/** * Sets the extension for the given key. If the value is null or the * empty string, the extension is removed. Otherwise, the extension * must be <a href="./Locale.html#def_extensions">well-formed</a> or an exception * is thrown. * * <p><b>Note:</b> The key {@link Locale#UNICODE_LOCALE_EXTENSION * UNICODE_LOCALE_EXTENSION} ('u') is used for the Unicode locale extension. * Setting a value for this key replaces any existing Unicode locale key/type * pairs with those defined in the extension. * * <p><b>Note:</b> The key {@link Locale#PRIVATE_USE_EXTENSION * PRIVATE_USE_EXTENSION} ('x') is used for the private use code. To be * well-formed, the value for this key needs only to have subtags of one to * eight alphanumeric characters, not two to eight as in the general case. * * @param key the extension key * @param value the extension value * @return This builder. * @throws IllformedLocaleException if <code>key</code> is illegal * or <code>value</code> is ill-formed * @see #setUnicodeLocaleKeyword(String, String) */ public Builder setExtension(char key, String value) { try { localeBuilder.setExtension(key, value); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
Example 8
Source File: Locale.java From openjdk-jdk8u with GNU General Public License v2.0 | 3 votes |
/** * Removes a unicode locale attribute, if present, otherwise has no * effect. The attribute must not be null and must be <a * href="./Locale.html#def_locale_extension">well-formed</a> 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) */ public Builder removeUnicodeLocaleAttribute(String attribute) { try { localeBuilder.removeUnicodeLocaleAttribute(attribute); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
Example 9
Source File: Locale.java From Bytecoder with Apache License 2.0 | 3 votes |
/** * Adds a unicode locale attribute, if not already present, otherwise * has no effect. The attribute must not be null and must be <a * href="./Locale.html#def_locale_extension">well-formed</a> or an exception * is thrown. * * @param attribute the attribute * @return This builder. * @throws NullPointerException if {@code attribute} is null * @throws IllformedLocaleException if {@code attribute} is ill-formed * @see #setExtension(char, String) */ public Builder addUnicodeLocaleAttribute(String attribute) { try { localeBuilder.addUnicodeLocaleAttribute(attribute); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
Example 10
Source File: Locale.java From Bytecoder with Apache License 2.0 | 3 votes |
/** * Sets the variant. If variant is null or the empty string, the * variant in this {@code Builder} is removed. Otherwise, it * must consist of one or more <a href="./Locale.html#def_variant">well-formed</a> * subtags, or an exception is thrown. * * <p><b>Note:</b> This method checks if {@code variant} * satisfies the IETF BCP 47 variant subtag's syntax requirements, * and normalizes the value to lowercase letters. However, * the {@code Locale} class does not impose any syntactic * restriction on variant, and the variant value in * {@code Locale} is case sensitive. To set such a variant, * use a Locale constructor. * * @param variant the variant * @return This builder. * @throws IllformedLocaleException if {@code variant} is ill-formed */ public Builder setVariant(String variant) { try { localeBuilder.setVariant(variant); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
Example 11
Source File: Locale.java From jdk8u-jdk with GNU General Public License v2.0 | 3 votes |
/** * 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 <a href="./Locale.html#def_region">well-formed</a> 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 */ public Builder setRegion(String region) { try { localeBuilder.setRegion(region); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
Example 12
Source File: Locale.java From jdk8u60 with GNU General Public License v2.0 | 3 votes |
/** * Sets the Unicode locale keyword type for the given key. If the type * is null, the Unicode keyword is removed. Otherwise, the key must be * non-null and both key and type must be <a * href="./Locale.html#def_locale_extension">well-formed</a> or an exception * is thrown. * * <p>Keys and types are converted to lower case. * * <p><b>Note</b>:Setting the 'u' extension via {@link #setExtension} * replaces all Unicode locale keywords with those defined in the * extension. * * @param key the Unicode locale key * @param type the Unicode locale type * @return This builder. * @throws IllformedLocaleException if <code>key</code> or <code>type</code> * is ill-formed * @throws NullPointerException if <code>key</code> is null * @see #setExtension(char, String) */ public Builder setUnicodeLocaleKeyword(String key, String type) { try { localeBuilder.setUnicodeLocaleKeyword(key, type); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
Example 13
Source File: Locale.java From openjdk-jdk9 with GNU General Public License v2.0 | 3 votes |
/** * 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 <a href="./Locale.html#def_region">well-formed</a> 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 */ public Builder setRegion(String region) { try { localeBuilder.setRegion(region); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
Example 14
Source File: Locale.java From JDKSourceCode1.8 with MIT License | 3 votes |
/** * 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 <a href="./Locale.html#def_variant">well-formed</a> * 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>Locale</code> class does not impose any syntactic * restriction on variant, and the variant value in * <code>Locale</code> is case sensitive. To set such a variant, * use a Locale constructor. * * @param variant the variant * @return This builder. * @throws IllformedLocaleException if <code>variant</code> is ill-formed */ public Builder setVariant(String variant) { try { localeBuilder.setVariant(variant); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
Example 15
Source File: Locale.java From jdk1.8-source-analysis with Apache License 2.0 | 3 votes |
/** * Sets the Unicode locale keyword type for the given key. If the type * is null, the Unicode keyword is removed. Otherwise, the key must be * non-null and both key and type must be <a * href="./Locale.html#def_locale_extension">well-formed</a> or an exception * is thrown. * * <p>Keys and types are converted to lower case. * * <p><b>Note</b>:Setting the 'u' extension via {@link #setExtension} * replaces all Unicode locale keywords with those defined in the * extension. * * @param key the Unicode locale key * @param type the Unicode locale type * @return This builder. * @throws IllformedLocaleException if <code>key</code> or <code>type</code> * is ill-formed * @throws NullPointerException if <code>key</code> is null * @see #setExtension(char, String) */ public Builder setUnicodeLocaleKeyword(String key, String type) { try { localeBuilder.setUnicodeLocaleKeyword(key, type); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
Example 16
Source File: Locale.java From Bytecoder with Apache License 2.0 | 3 votes |
/** * Sets the Unicode locale keyword type for the given key. If the type * is null, the Unicode keyword is removed. Otherwise, the key must be * non-null and both key and type must be <a * href="./Locale.html#def_locale_extension">well-formed</a> or an exception * is thrown. * * <p>Keys and types are converted to lower case. * * <p><b>Note</b>:Setting the 'u' extension via {@link #setExtension} * replaces all Unicode locale keywords with those defined in the * extension. * * @param key the Unicode locale key * @param type the Unicode locale type * @return This builder. * @throws IllformedLocaleException if {@code key} or {@code type} * is ill-formed * @throws NullPointerException if {@code key} is null * @see #setExtension(char, String) */ public Builder setUnicodeLocaleKeyword(String key, String type) { try { localeBuilder.setUnicodeLocaleKeyword(key, type); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
Example 17
Source File: Locale.java From jdk8u-jdk with GNU General Public License v2.0 | 3 votes |
/** * 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 <a href="./Locale.html#def_script">well-formed</a> 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 */ public Builder setScript(String script) { try { localeBuilder.setScript(script); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
Example 18
Source File: Locale.java From jdk1.8-source-analysis with Apache License 2.0 | 3 votes |
/** * 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 <a href="./Locale.html#def_region">well-formed</a> 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 */ public Builder setRegion(String region) { try { localeBuilder.setRegion(region); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
Example 19
Source File: Locale.java From JDKSourceCode1.8 with MIT License | 3 votes |
/** * 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 <a href="./Locale.html#def_region">well-formed</a> 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 */ public Builder setRegion(String region) { try { localeBuilder.setRegion(region); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }
Example 20
Source File: Locale.java From Bytecoder with Apache License 2.0 | 3 votes |
/** * Sets the region. If region is null or the empty string, the region * in this {@code Builder} is removed. Otherwise, * the region must be <a href="./Locale.html#def_region">well-formed</a> 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} created by the * {@code Builder} is always normalized to upper case. * * @param region the region * @return This builder. * @throws IllformedLocaleException if {@code region} is ill-formed */ public Builder setRegion(String region) { try { localeBuilder.setRegion(region); } catch (LocaleSyntaxException e) { throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex()); } return this; }