sun.util.locale.LocaleSyntaxException Java Examples

The following examples show how to use sun.util.locale.LocaleSyntaxException. 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 jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Deserializes this <code>Locale</code>.
 * @param in the <code>ObjectInputStream</code> to read
 * @throws IOException
 * @throws ClassNotFoundException
 * @throws IllformedLocaleException
 * @since 1.7
 */
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    ObjectInputStream.GetField fields = in.readFields();
    String language = (String)fields.get("language", "");
    String script = (String)fields.get("script", "");
    String country = (String)fields.get("country", "");
    String variant = (String)fields.get("variant", "");
    String extStr = (String)fields.get("extensions", "");
    baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), script, country, variant);
    if (extStr.length() > 0) {
        try {
            InternalLocaleBuilder bldr = new InternalLocaleBuilder();
            bldr.setExtensions(extStr);
            localeExtensions = bldr.getLocaleExtensions();
        } catch (LocaleSyntaxException e) {
            throw new IllformedLocaleException(e.getMessage());
        }
    } else {
        localeExtensions = null;
    }
}
 
Example #2
Source File: Locale.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Deserializes this <code>Locale</code>.
 * @param in the <code>ObjectInputStream</code> to read
 * @throws IOException
 * @throws ClassNotFoundException
 * @throws IllformedLocaleException
 * @since 1.7
 */
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    ObjectInputStream.GetField fields = in.readFields();
    String language = (String)fields.get("language", "");
    String script = (String)fields.get("script", "");
    String country = (String)fields.get("country", "");
    String variant = (String)fields.get("variant", "");
    String extStr = (String)fields.get("extensions", "");
    baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), script, country, variant);
    if (extStr.length() > 0) {
        try {
            InternalLocaleBuilder bldr = new InternalLocaleBuilder();
            bldr.setExtensions(extStr);
            localeExtensions = bldr.getLocaleExtensions();
        } catch (LocaleSyntaxException e) {
            throw new IllformedLocaleException(e.getMessage());
        }
    } else {
        localeExtensions = null;
    }
}
 
Example #3
Source File: Locale.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Deserializes this <code>Locale</code>.
 * @param in the <code>ObjectInputStream</code> to read
 * @throws IOException
 * @throws ClassNotFoundException
 * @throws IllformedLocaleException
 * @since 1.7
 */
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    ObjectInputStream.GetField fields = in.readFields();
    String language = (String)fields.get("language", "");
    String script = (String)fields.get("script", "");
    String country = (String)fields.get("country", "");
    String variant = (String)fields.get("variant", "");
    String extStr = (String)fields.get("extensions", "");
    baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), script, country, variant);
    if (extStr.length() > 0) {
        try {
            InternalLocaleBuilder bldr = new InternalLocaleBuilder();
            bldr.setExtensions(extStr);
            localeExtensions = bldr.getLocaleExtensions();
        } catch (LocaleSyntaxException e) {
            throw new IllformedLocaleException(e.getMessage());
        }
    } else {
        localeExtensions = null;
    }
}
 
Example #4
Source File: Locale.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Deserializes this <code>Locale</code>.
 * @param in the <code>ObjectInputStream</code> to read
 * @throws IOException
 * @throws ClassNotFoundException
 * @throws IllformedLocaleException
 * @since 1.7
 */
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    ObjectInputStream.GetField fields = in.readFields();
    String language = (String)fields.get("language", "");
    String script = (String)fields.get("script", "");
    String country = (String)fields.get("country", "");
    String variant = (String)fields.get("variant", "");
    String extStr = (String)fields.get("extensions", "");
    baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), script, country, variant);
    if (extStr.length() > 0) {
        try {
            InternalLocaleBuilder bldr = new InternalLocaleBuilder();
            bldr.setExtensions(extStr);
            localeExtensions = bldr.getLocaleExtensions();
        } catch (LocaleSyntaxException e) {
            throw new IllformedLocaleException(e.getMessage());
        }
    } else {
        localeExtensions = null;
    }
}
 
Example #5
Source File: Locale.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Deserializes this <code>Locale</code>.
 * @param in the <code>ObjectInputStream</code> to read
 * @throws IOException
 * @throws ClassNotFoundException
 * @throws IllformedLocaleException
 * @since 1.7
 */
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    ObjectInputStream.GetField fields = in.readFields();
    String language = (String)fields.get("language", "");
    String script = (String)fields.get("script", "");
    String country = (String)fields.get("country", "");
    String variant = (String)fields.get("variant", "");
    String extStr = (String)fields.get("extensions", "");
    baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), script, country, variant);
    if (extStr.length() > 0) {
        try {
            InternalLocaleBuilder bldr = new InternalLocaleBuilder();
            bldr.setExtensions(extStr);
            localeExtensions = bldr.getLocaleExtensions();
        } catch (LocaleSyntaxException e) {
            throw new IllformedLocaleException(e.getMessage());
        }
    } else {
        localeExtensions = null;
    }
}
 
Example #6
Source File: Locale.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Deserializes this <code>Locale</code>.
 * @param in the <code>ObjectInputStream</code> to read
 * @throws IOException
 * @throws ClassNotFoundException
 * @throws IllformedLocaleException
 * @since 1.7
 */
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    ObjectInputStream.GetField fields = in.readFields();
    String language = (String)fields.get("language", "");
    String script = (String)fields.get("script", "");
    String country = (String)fields.get("country", "");
    String variant = (String)fields.get("variant", "");
    String extStr = (String)fields.get("extensions", "");
    baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), script, country, variant);
    if (extStr.length() > 0) {
        try {
            InternalLocaleBuilder bldr = new InternalLocaleBuilder();
            bldr.setExtensions(extStr);
            localeExtensions = bldr.getLocaleExtensions();
        } catch (LocaleSyntaxException e) {
            throw new IllformedLocaleException(e.getMessage());
        }
    } else {
        localeExtensions = null;
    }
}
 
Example #7
Source File: Locale.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Deserializes this <code>Locale</code>.
 * @param in the <code>ObjectInputStream</code> to read
 * @throws IOException
 * @throws ClassNotFoundException
 * @throws IllformedLocaleException
 * @since 1.7
 */
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    ObjectInputStream.GetField fields = in.readFields();
    String language = (String)fields.get("language", "");
    String script = (String)fields.get("script", "");
    String country = (String)fields.get("country", "");
    String variant = (String)fields.get("variant", "");
    String extStr = (String)fields.get("extensions", "");
    baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), script, country, variant);
    if (extStr.length() > 0) {
        try {
            InternalLocaleBuilder bldr = new InternalLocaleBuilder();
            bldr.setExtensions(extStr);
            localeExtensions = bldr.getLocaleExtensions();
        } catch (LocaleSyntaxException e) {
            throw new IllformedLocaleException(e.getMessage());
        }
    } else {
        localeExtensions = null;
    }
}
 
Example #8
Source File: Locale.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Deserializes this {@code Locale}.
 * @param in the {@code ObjectInputStream} to read
 * @throws IOException
 * @throws ClassNotFoundException
 * @throws IllformedLocaleException
 * @since 1.7
 */
@java.io.Serial
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    ObjectInputStream.GetField fields = in.readFields();
    String language = (String)fields.get("language", "");
    String script = (String)fields.get("script", "");
    String country = (String)fields.get("country", "");
    String variant = (String)fields.get("variant", "");
    String extStr = (String)fields.get("extensions", "");

    baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), script, country, variant);
    if (!extStr.isEmpty()) {
        try {
            InternalLocaleBuilder bldr = new InternalLocaleBuilder();
            bldr.setExtensions(extStr);
            localeExtensions = bldr.getLocaleExtensions();
        } catch (LocaleSyntaxException e) {
            throw new IllformedLocaleException(e.getMessage());
        }
    } else {
        localeExtensions = null;
    }
}
 
Example #9
Source File: Locale.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Deserializes this <code>Locale</code>.
 * @param in the <code>ObjectInputStream</code> to read
 * @throws IOException
 * @throws ClassNotFoundException
 * @throws IllformedLocaleException
 * @since 1.7
 */
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    ObjectInputStream.GetField fields = in.readFields();
    String language = (String)fields.get("language", "");
    String script = (String)fields.get("script", "");
    String country = (String)fields.get("country", "");
    String variant = (String)fields.get("variant", "");
    String extStr = (String)fields.get("extensions", "");
    baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), script, country, variant);
    if (extStr.length() > 0) {
        try {
            InternalLocaleBuilder bldr = new InternalLocaleBuilder();
            bldr.setExtensions(extStr);
            localeExtensions = bldr.getLocaleExtensions();
        } catch (LocaleSyntaxException e) {
            throw new IllformedLocaleException(e.getMessage());
        }
    } else {
        localeExtensions = null;
    }
}
 
Example #10
Source File: Locale.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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 #11
Source File: Locale.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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
 */
public Builder setLanguage(String language) {
    try {
        localeBuilder.setLanguage(language);
    } catch (LocaleSyntaxException e) {
        throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex());
    }
    return this;
}
 
Example #12
Source File: Locale.java    From Bytecoder with Apache License 2.0 3 votes vote down vote up
/**
 * 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;
}
 
Example #13
Source File: Locale.java    From Bytecoder with Apache License 2.0 3 votes vote down vote up
/**
 * Sets the language.  If {@code language} is the empty string or
 * null, the language in this {@code Builder} 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} is ill-formed
 */
public Builder setLanguage(String language) {
    try {
        localeBuilder.setLanguage(language);
    } catch (LocaleSyntaxException e) {
        throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex());
    }
    return this;
}
 
Example #14
Source File: Locale.java    From Bytecoder with Apache License 2.0 3 votes vote down vote up
/**
 * Sets the script. If {@code script} is null or the empty string,
 * the script in this {@code Builder} 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} 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 #15
Source File: Locale.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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 #16
Source File: Locale.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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 #17
Source File: Locale.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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 #18
Source File: Locale.java    From JDKSourceCode1.8 with MIT License 3 votes vote down vote up
/**
 * 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
 */
public Builder setLanguage(String language) {
    try {
        localeBuilder.setLanguage(language);
    } catch (LocaleSyntaxException e) {
        throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex());
    }
    return this;
}
 
Example #19
Source File: Locale.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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
 */
public Builder setLanguage(String language) {
    try {
        localeBuilder.setLanguage(language);
    } 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 vote down vote up
/**
 * 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 #21
Source File: Locale.java    From JDKSourceCode1.8 with MIT License 3 votes vote down vote up
/**
 * 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 #22
Source File: Locale.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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 #23
Source File: Locale.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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
 */
public Builder setLanguage(String language) {
    try {
        localeBuilder.setLanguage(language);
    } catch (LocaleSyntaxException e) {
        throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex());
    }
    return this;
}
 
Example #24
Source File: Locale.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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 #25
Source File: Locale.java    From JDKSourceCode1.8 with MIT License 3 votes vote down vote up
/**
 * 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 #26
Source File: Locale.java    From JDKSourceCode1.8 with MIT License 3 votes vote down vote up
/**
 * 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 #27
Source File: Locale.java    From JDKSourceCode1.8 with MIT License 3 votes vote down vote up
/**
 * 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 #28
Source File: Locale.java    From JDKSourceCode1.8 with MIT License 3 votes vote down vote up
/**
 * 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 #29
Source File: Locale.java    From JDKSourceCode1.8 with MIT License 3 votes vote down vote up
/**
 * 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 #30
Source File: Locale.java    From JDKSourceCode1.8 with MIT License 3 votes vote down vote up
/**
 * 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;
}