Java Code Examples for sun.util.locale.BaseLocale#getInstance()

The following examples show how to use sun.util.locale.BaseLocale#getInstance() . 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-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 2
Source File: Locale.java    From j2objc 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 != null && 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 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 4
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 5
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 6
Source File: Locale.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
static Locale getInstance(String language, String script, String country,
                                  String variant, LocaleExtensions extensions) {
    if (language== null || script == null || country == null || variant == null) {
        throw new NullPointerException();
    }

    if (extensions == null) {
        extensions = getCompatibilityExtensions(language, script, country, variant);
    }

    BaseLocale baseloc = BaseLocale.getInstance(language, script, country, variant);
    return getInstance(baseloc, extensions);
}
 
Example 7
Source File: Locale.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static Locale getInstance(String language, String script, String country,
                                  String variant, LocaleExtensions extensions) {
    if (language== null || script == null || country == null || variant == null) {
        throw new NullPointerException();
    }

    if (extensions == null) {
        extensions = getCompatibilityExtensions(language, script, country, variant);
    }

    BaseLocale baseloc = BaseLocale.getInstance(language, script, country, variant);
    return getInstance(baseloc, extensions);
}
 
Example 8
Source File: Locale.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static Locale getInstance(String language, String script, String country,
                                  String variant, LocaleExtensions extensions) {
    if (language== null || script == null || country == null || variant == null) {
        throw new NullPointerException();
    }

    if (extensions == null) {
        extensions = getCompatibilityExtensions(language, script, country, variant);
    }

    BaseLocale baseloc = BaseLocale.getInstance(language, script, country, variant);
    return getInstance(baseloc, extensions);
}
 
Example 9
Source File: Locale.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static Locale getInstance(String language, String script, String country,
                                  String variant, LocaleExtensions extensions) {
    if (language== null || script == null || country == null || variant == null) {
        throw new NullPointerException();
    }

    if (extensions == null) {
        extensions = getCompatibilityExtensions(language, script, country, variant);
    }

    BaseLocale baseloc = BaseLocale.getInstance(language, script, country, variant);
    return getInstance(baseloc, extensions);
}
 
Example 10
Source File: Locale.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
static Locale getInstance(String language, String script, String country,
                                  String variant, LocaleExtensions extensions) {
    if (language== null || script == null || country == null || variant == null) {
        throw new NullPointerException();
    }

    if (extensions == null) {
        extensions = getCompatibilityExtensions(language, script, country, variant);
    }

    BaseLocale baseloc = BaseLocale.getInstance(language, script, country, variant);
    return getInstance(baseloc, extensions);
}
 
Example 11
Source File: Locale.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
static Locale getInstance(String language, String script, String country,
                                  String variant, LocaleExtensions extensions) {
    if (language== null || script == null || country == null || variant == null) {
        throw new NullPointerException();
    }

    if (extensions == null) {
        extensions = getCompatibilityExtensions(language, script, country, variant);
    }

    BaseLocale baseloc = BaseLocale.getInstance(language, script, country, variant);
    return getInstance(baseloc, extensions);
}
 
Example 12
Source File: Locale.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
static Locale getInstance(String language, String script, String country,
                                  String variant, LocaleExtensions extensions) {
    if (language== null || script == null || country == null || variant == null) {
        throw new NullPointerException();
    }

    if (extensions == null) {
        extensions = getCompatibilityExtensions(language, script, country, variant);
    }

    BaseLocale baseloc = BaseLocale.getInstance(language, script, country, variant);
    return getInstance(baseloc, extensions);
}
 
Example 13
Source File: Locale.java    From jdk8u_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Construct a locale from language, country and variant.
 * This constructor normalizes the language value to lowercase and
 * the country value to uppercase.
 * <p>
 * <b>Note:</b>
 * <ul>
 * <li>ISO 639 is not a stable standard; some of the language codes it defines
 * (specifically "iw", "ji", and "in") have changed.  This constructor accepts both the
 * old codes ("iw", "ji", and "in") and the new codes ("he", "yi", and "id"), but all other
 * API on Locale will return only the OLD codes.
 * <li>For backward compatibility reasons, this constructor does not make
 * any syntactic checks on the input.
 * <li>The two cases ("ja", "JP", "JP") and ("th", "TH", "TH") are handled specially,
 * see <a href="#special_cases_constructor">Special Cases</a> for more information.
 * </ul>
 *
 * @param language An ISO 639 alpha-2 or alpha-3 language code, or a language subtag
 * up to 8 characters in length.  See the <code>Locale</code> class description about
 * valid language values.
 * @param country An ISO 3166 alpha-2 country code or a UN M.49 numeric-3 area code.
 * See the <code>Locale</code> class description about valid country values.
 * @param variant Any arbitrary value used to indicate a variation of a <code>Locale</code>.
 * See the <code>Locale</code> class description for the details.
 * @exception NullPointerException thrown if any argument is null.
 */
public Locale(String language, String country, String variant) {
    if (language== null || country == null || variant == null) {
        throw new NullPointerException();
    }
    baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), "", country, variant);
    localeExtensions = getCompatibilityExtensions(language, "", country, variant);
}
 
Example 14
Source File: Locale.java    From Bytecoder with Apache License 2.0 3 votes vote down vote up
/**
 * Construct a locale from language, country and variant.
 * This constructor normalizes the language value to lowercase and
 * the country value to uppercase.
 * <p>
 * <b>Note:</b>
 * <ul>
 * <li>ISO 639 is not a stable standard; some of the language codes it defines
 * (specifically "iw", "ji", and "in") have changed.  This constructor accepts both the
 * old codes ("iw", "ji", and "in") and the new codes ("he", "yi", and "id"), but all other
 * API on Locale will return only the OLD codes.
 * <li>For backward compatibility reasons, this constructor does not make
 * any syntactic checks on the input.
 * <li>The two cases ("ja", "JP", "JP") and ("th", "TH", "TH") are handled specially,
 * see <a href="#special_cases_constructor">Special Cases</a> for more information.
 * </ul>
 *
 * @param language An ISO 639 alpha-2 or alpha-3 language code, or a language subtag
 * up to 8 characters in length.  See the {@code Locale} class description about
 * valid language values.
 * @param country An ISO 3166 alpha-2 country code or a UN M.49 numeric-3 area code.
 * See the {@code Locale} class description about valid country values.
 * @param variant Any arbitrary value used to indicate a variation of a {@code Locale}.
 * See the {@code Locale} class description for the details.
 * @throws    NullPointerException thrown if any argument is null.
 */
public Locale(String language, String country, String variant) {
    if (language == null || country == null || variant == null) {
        throw new NullPointerException();
    }
    baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), "", country, variant);
    localeExtensions = getCompatibilityExtensions(language, "", country, variant);
}
 
Example 15
Source File: Locale.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Construct a locale from language, country and variant.
 * This constructor normalizes the language value to lowercase and
 * the country value to uppercase.
 * <p>
 * <b>Note:</b>
 * <ul>
 * <li>ISO 639 is not a stable standard; some of the language codes it defines
 * (specifically "iw", "ji", and "in") have changed.  This constructor accepts both the
 * old codes ("iw", "ji", and "in") and the new codes ("he", "yi", and "id"), but all other
 * API on Locale will return only the OLD codes.
 * <li>For backward compatibility reasons, this constructor does not make
 * any syntactic checks on the input.
 * <li>The two cases ("ja", "JP", "JP") and ("th", "TH", "TH") are handled specially,
 * see <a href="#special_cases_constructor">Special Cases</a> for more information.
 * </ul>
 *
 * @param language An ISO 639 alpha-2 or alpha-3 language code, or a language subtag
 * up to 8 characters in length.  See the <code>Locale</code> class description about
 * valid language values.
 * @param country An ISO 3166 alpha-2 country code or a UN M.49 numeric-3 area code.
 * See the <code>Locale</code> class description about valid country values.
 * @param variant Any arbitrary value used to indicate a variation of a <code>Locale</code>.
 * See the <code>Locale</code> class description for the details.
 * @exception NullPointerException thrown if any argument is null.
 */
public Locale(String language, String country, String variant) {
    if (language== null || country == null || variant == null) {
        throw new NullPointerException();
    }
    baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), "", country, variant);
    localeExtensions = getCompatibilityExtensions(language, "", country, variant);
}
 
Example 16
Source File: Locale.java    From hottub with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Construct a locale from language, country and variant.
 * This constructor normalizes the language value to lowercase and
 * the country value to uppercase.
 * <p>
 * <b>Note:</b>
 * <ul>
 * <li>ISO 639 is not a stable standard; some of the language codes it defines
 * (specifically "iw", "ji", and "in") have changed.  This constructor accepts both the
 * old codes ("iw", "ji", and "in") and the new codes ("he", "yi", and "id"), but all other
 * API on Locale will return only the OLD codes.
 * <li>For backward compatibility reasons, this constructor does not make
 * any syntactic checks on the input.
 * <li>The two cases ("ja", "JP", "JP") and ("th", "TH", "TH") are handled specially,
 * see <a href="#special_cases_constructor">Special Cases</a> for more information.
 * </ul>
 *
 * @param language An ISO 639 alpha-2 or alpha-3 language code, or a language subtag
 * up to 8 characters in length.  See the <code>Locale</code> class description about
 * valid language values.
 * @param country An ISO 3166 alpha-2 country code or a UN M.49 numeric-3 area code.
 * See the <code>Locale</code> class description about valid country values.
 * @param variant Any arbitrary value used to indicate a variation of a <code>Locale</code>.
 * See the <code>Locale</code> class description for the details.
 * @exception NullPointerException thrown if any argument is null.
 */
public Locale(String language, String country, String variant) {
    if (language== null || country == null || variant == null) {
        throw new NullPointerException();
    }
    baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), "", country, variant);
    localeExtensions = getCompatibilityExtensions(language, "", country, variant);
}
 
Example 17
Source File: Locale.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Construct a locale from language, country and variant.
 * This constructor normalizes the language value to lowercase and
 * the country value to uppercase.
 * <p>
 * <b>Note:</b>
 * <ul>
 * <li>ISO 639 is not a stable standard; some of the language codes it defines
 * (specifically "iw", "ji", and "in") have changed.  This constructor accepts both the
 * old codes ("iw", "ji", and "in") and the new codes ("he", "yi", and "id"), but all other
 * API on Locale will return only the OLD codes.
 * <li>For backward compatibility reasons, this constructor does not make
 * any syntactic checks on the input.
 * <li>The two cases ("ja", "JP", "JP") and ("th", "TH", "TH") are handled specially,
 * see <a href="#special_cases_constructor">Special Cases</a> for more information.
 * </ul>
 *
 * @param language An ISO 639 alpha-2 or alpha-3 language code, or a language subtag
 * up to 8 characters in length.  See the <code>Locale</code> class description about
 * valid language values.
 * @param country An ISO 3166 alpha-2 country code or a UN M.49 numeric-3 area code.
 * See the <code>Locale</code> class description about valid country values.
 * @param variant Any arbitrary value used to indicate a variation of a <code>Locale</code>.
 * See the <code>Locale</code> class description for the details.
 * @exception NullPointerException thrown if any argument is null.
 */
public Locale(String language, String country, String variant) {
    if (language== null || country == null || variant == null) {
        throw new NullPointerException();
    }
    baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), "", country, variant);
    localeExtensions = getCompatibilityExtensions(language, "", country, variant);
}
 
Example 18
Source File: Locale.java    From jdk-1.7-annotated with Apache License 2.0 3 votes vote down vote up
/**
 * Construct a locale from language, country and variant.
 * This constructor normalizes the language value to lowercase and
 * the country value to uppercase.
 * <p>
 * <b>Note:</b>
 * <ul>
 * <li>ISO 639 is not a stable standard; some of the language codes it defines
 * (specifically "iw", "ji", and "in") have changed.  This constructor accepts both the
 * old codes ("iw", "ji", and "in") and the new codes ("he", "yi", and "id"), but all other
 * API on Locale will return only the OLD codes.
 * <li>For backward compatibility reasons, this constructor does not make
 * any syntactic checks on the input.
 * <li>The two cases ("ja", "JP", "JP") and ("th", "TH", "TH") are handled specially,
 * see <a href="#special_cases_constructor">Special Cases</a> for more information.
 * </ul>
 *
 * @param language An ISO 639 alpha-2 or alpha-3 language code, or a language subtag
 * up to 8 characters in length.  See the <code>Locale</code> class description about
 * valid language values.
 * @param country An ISO 3166 alpha-2 country code or a UN M.49 numeric-3 area code.
 * See the <code>Locale</code> class description about valid country values.
 * @param variant Any arbitrary value used to indicate a variation of a <code>Locale</code>.
 * See the <code>Locale</code> class description for the details.
 * @exception NullPointerException thrown if any argument is null.
 */
public Locale(String language, String country, String variant) {
    if (language== null || country == null || variant == null) {
        throw new NullPointerException();
    }
    baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), "", country, variant);
    localeExtensions = getCompatibilityExtensions(language, "", country, variant);
}
 
Example 19
Source File: Locale.java    From jdk1.8-source-analysis with Apache License 2.0 3 votes vote down vote up
/**
 * Construct a locale from language, country and variant.
 * This constructor normalizes the language value to lowercase and
 * the country value to uppercase.
 * <p>
 * <b>Note:</b>
 * <ul>
 * <li>ISO 639 is not a stable standard; some of the language codes it defines
 * (specifically "iw", "ji", and "in") have changed.  This constructor accepts both the
 * old codes ("iw", "ji", and "in") and the new codes ("he", "yi", and "id"), but all other
 * API on Locale will return only the OLD codes.
 * <li>For backward compatibility reasons, this constructor does not make
 * any syntactic checks on the input.
 * <li>The two cases ("ja", "JP", "JP") and ("th", "TH", "TH") are handled specially,
 * see <a href="#special_cases_constructor">Special Cases</a> for more information.
 * </ul>
 *
 * @param language An ISO 639 alpha-2 or alpha-3 language code, or a language subtag
 * up to 8 characters in length.  See the <code>Locale</code> class description about
 * valid language values.
 * @param country An ISO 3166 alpha-2 country code or a UN M.49 numeric-3 area code.
 * See the <code>Locale</code> class description about valid country values.
 * @param variant Any arbitrary value used to indicate a variation of a <code>Locale</code>.
 * See the <code>Locale</code> class description for the details.
 * @exception NullPointerException thrown if any argument is null.
 */
public Locale(String language, String country, String variant) {
    if (language== null || country == null || variant == null) {
        throw new NullPointerException();
    }
    baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), "", country, variant);
    localeExtensions = getCompatibilityExtensions(language, "", country, variant);
}
 
Example 20
Source File: Locale.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Construct a locale from language, country and variant.
 * This constructor normalizes the language value to lowercase and
 * the country value to uppercase.
 * <p>
 * <b>Note:</b>
 * <ul>
 * <li>ISO 639 is not a stable standard; some of the language codes it defines
 * (specifically "iw", "ji", and "in") have changed.  This constructor accepts both the
 * old codes ("iw", "ji", and "in") and the new codes ("he", "yi", and "id"), but all other
 * API on Locale will return only the OLD codes.
 * <li>For backward compatibility reasons, this constructor does not make
 * any syntactic checks on the input.
 * <li>The two cases ("ja", "JP", "JP") and ("th", "TH", "TH") are handled specially,
 * see <a href="#special_cases_constructor">Special Cases</a> for more information.
 * </ul>
 *
 * @param language An ISO 639 alpha-2 or alpha-3 language code, or a language subtag
 * up to 8 characters in length.  See the <code>Locale</code> class description about
 * valid language values.
 * @param country An ISO 3166 alpha-2 country code or a UN M.49 numeric-3 area code.
 * See the <code>Locale</code> class description about valid country values.
 * @param variant Any arbitrary value used to indicate a variation of a <code>Locale</code>.
 * See the <code>Locale</code> class description for the details.
 * @exception NullPointerException thrown if any argument is null.
 */
public Locale(String language, String country, String variant) {
    if (language== null || country == null || variant == null) {
        throw new NullPointerException();
    }
    baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), "", country, variant);
    localeExtensions = getCompatibilityExtensions(language, "", country, variant);
}