src/java.base/share/classes/java/util/Locale.java
changeset 58242 94bb65cb37d3
parent 57956 e0b8b019d2f5
child 58288 48e480e56aad
equal deleted inserted replaced
58241:33de7752835c 58242:94bb65cb37d3
   738      * valid language values.
   738      * valid language values.
   739      * @param country An ISO 3166 alpha-2 country code or a UN M.49 numeric-3 area code.
   739      * @param country An ISO 3166 alpha-2 country code or a UN M.49 numeric-3 area code.
   740      * See the <code>Locale</code> class description about valid country values.
   740      * See the <code>Locale</code> class description about valid country values.
   741      * @param variant Any arbitrary value used to indicate a variation of a <code>Locale</code>.
   741      * @param variant Any arbitrary value used to indicate a variation of a <code>Locale</code>.
   742      * See the <code>Locale</code> class description for the details.
   742      * See the <code>Locale</code> class description for the details.
   743      * @exception NullPointerException thrown if any argument is null.
   743      * @throws    NullPointerException thrown if any argument is null.
   744      */
   744      */
   745     public Locale(String language, String country, String variant) {
   745     public Locale(String language, String country, String variant) {
   746         if (language == null || country == null || variant == null) {
   746         if (language == null || country == null || variant == null) {
   747             throw new NullPointerException();
   747             throw new NullPointerException();
   748         }
   748         }
   768      * @param language An ISO 639 alpha-2 or alpha-3 language code, or a language subtag
   768      * @param language An ISO 639 alpha-2 or alpha-3 language code, or a language subtag
   769      * up to 8 characters in length.  See the <code>Locale</code> class description about
   769      * up to 8 characters in length.  See the <code>Locale</code> class description about
   770      * valid language values.
   770      * valid language values.
   771      * @param country An ISO 3166 alpha-2 country code or a UN M.49 numeric-3 area code.
   771      * @param country An ISO 3166 alpha-2 country code or a UN M.49 numeric-3 area code.
   772      * See the <code>Locale</code> class description about valid country values.
   772      * See the <code>Locale</code> class description about valid country values.
   773      * @exception NullPointerException thrown if either argument is null.
   773      * @throws    NullPointerException thrown if either argument is null.
   774      */
   774      */
   775     public Locale(String language, String country) {
   775     public Locale(String language, String country) {
   776         this(language, country, "");
   776         this(language, country, "");
   777     }
   777     }
   778 
   778 
   791      * </ul>
   791      * </ul>
   792      *
   792      *
   793      * @param language An ISO 639 alpha-2 or alpha-3 language code, or a language subtag
   793      * @param language An ISO 639 alpha-2 or alpha-3 language code, or a language subtag
   794      * up to 8 characters in length.  See the <code>Locale</code> class description about
   794      * up to 8 characters in length.  See the <code>Locale</code> class description about
   795      * valid language values.
   795      * valid language values.
   796      * @exception NullPointerException thrown if argument is null.
   796      * @throws    NullPointerException thrown if argument is null.
   797      * @since 1.4
   797      * @since 1.4
   798      */
   798      */
   799     public Locale(String language) {
   799     public Locale(String language) {
   800         this(language, "", "");
   800         this(language, "", "");
   801     }
   801     }
   810      *
   810      *
   811      * @param language lowercase 2 to 8 language code.
   811      * @param language lowercase 2 to 8 language code.
   812      * @param country uppercase two-letter ISO-3166 code and numeric-3 UN M.49 area code.
   812      * @param country uppercase two-letter ISO-3166 code and numeric-3 UN M.49 area code.
   813      * @param variant vendor and browser specific code. See class description.
   813      * @param variant vendor and browser specific code. See class description.
   814      * @return the <code>Locale</code> instance requested
   814      * @return the <code>Locale</code> instance requested
   815      * @exception NullPointerException if any argument is null.
   815      * @throws    NullPointerException if any argument is null.
   816      */
   816      */
   817     static Locale getInstance(String language, String country, String variant) {
   817     static Locale getInstance(String language, String country, String variant) {
   818         return getInstance(language, "", country, variant, null);
   818         return getInstance(language, "", country, variant, null);
   819     }
   819     }
   820 
   820 
  1735      * Alpha-3 Code".  If the locale specifies a three-letter
  1735      * Alpha-3 Code".  If the locale specifies a three-letter
  1736      * language, the language is returned as is.  If the locale does
  1736      * language, the language is returned as is.  If the locale does
  1737      * not specify a language the empty string is returned.
  1737      * not specify a language the empty string is returned.
  1738      *
  1738      *
  1739      * @return A three-letter abbreviation of this locale's language.
  1739      * @return A three-letter abbreviation of this locale's language.
  1740      * @exception MissingResourceException Throws MissingResourceException if
  1740      * @throws    MissingResourceException Throws MissingResourceException if
  1741      * three-letter language abbreviation is not available for this locale.
  1741      * three-letter language abbreviation is not available for this locale.
  1742      */
  1742      */
  1743     public String getISO3Language() throws MissingResourceException {
  1743     public String getISO3Language() throws MissingResourceException {
  1744         String lang = baseLocale.getLanguage();
  1744         String lang = baseLocale.getLanguage();
  1745         if (lang.length() == 3) {
  1745         if (lang.length() == 3) {
  1762      * string.
  1762      * string.
  1763      *
  1763      *
  1764      * <p>The ISO 3166-1 codes can be found on-line.
  1764      * <p>The ISO 3166-1 codes can be found on-line.
  1765      *
  1765      *
  1766      * @return A three-letter abbreviation of this locale's country.
  1766      * @return A three-letter abbreviation of this locale's country.
  1767      * @exception MissingResourceException Throws MissingResourceException if the
  1767      * @throws    MissingResourceException Throws MissingResourceException if the
  1768      * three-letter country abbreviation is not available for this locale.
  1768      * three-letter country abbreviation is not available for this locale.
  1769      */
  1769      */
  1770     public String getISO3Country() throws MissingResourceException {
  1770     public String getISO3Country() throws MissingResourceException {
  1771         String country3 = getISO3Code(baseLocale.getRegion(), LocaleISOData.isoCountryTable);
  1771         String country3 = getISO3Code(baseLocale.getRegion(), LocaleISOData.isoCountryTable);
  1772         if (country3 == null) {
  1772         if (country3 == null) {
  1832      * on the ISO code as a last-resort value.  If the locale doesn't specify a language,
  1832      * on the ISO code as a last-resort value.  If the locale doesn't specify a language,
  1833      * this function returns the empty string.
  1833      * this function returns the empty string.
  1834      *
  1834      *
  1835      * @param inLocale The locale for which to retrieve the display language.
  1835      * @param inLocale The locale for which to retrieve the display language.
  1836      * @return The name of the display language appropriate to the given locale.
  1836      * @return The name of the display language appropriate to the given locale.
  1837      * @exception NullPointerException if <code>inLocale</code> is <code>null</code>
  1837      * @throws    NullPointerException if <code>inLocale</code> is <code>null</code>
  1838      */
  1838      */
  1839     public String getDisplayLanguage(Locale inLocale) {
  1839     public String getDisplayLanguage(Locale inLocale) {
  1840         return getDisplayString(baseLocale.getLanguage(), null, inLocale, DISPLAY_LANGUAGE);
  1840         return getDisplayString(baseLocale.getLanguage(), null, inLocale, DISPLAY_LANGUAGE);
  1841     }
  1841     }
  1842 
  1842 
  1905      * on the ISO code as a last-resort value.  If the locale doesn't specify a country,
  1905      * on the ISO code as a last-resort value.  If the locale doesn't specify a country,
  1906      * this function returns the empty string.
  1906      * this function returns the empty string.
  1907      *
  1907      *
  1908      * @param inLocale The locale for which to retrieve the display country.
  1908      * @param inLocale The locale for which to retrieve the display country.
  1909      * @return The name of the country appropriate to the given locale.
  1909      * @return The name of the country appropriate to the given locale.
  1910      * @exception NullPointerException if <code>inLocale</code> is <code>null</code>
  1910      * @throws    NullPointerException if <code>inLocale</code> is <code>null</code>
  1911      */
  1911      */
  1912     public String getDisplayCountry(Locale inLocale) {
  1912     public String getDisplayCountry(Locale inLocale) {
  1913         return getDisplayString(baseLocale.getRegion(), null, inLocale, DISPLAY_COUNTRY);
  1913         return getDisplayString(baseLocale.getRegion(), null, inLocale, DISPLAY_COUNTRY);
  1914     }
  1914     }
  1915 
  1915 
  1947      * user.  If possible, the name will be localized for inLocale.  If the locale
  1947      * user.  If possible, the name will be localized for inLocale.  If the locale
  1948      * doesn't specify a variant code, this function returns the empty string.
  1948      * doesn't specify a variant code, this function returns the empty string.
  1949      *
  1949      *
  1950      * @param inLocale The locale for which to retrieve the display variant code.
  1950      * @param inLocale The locale for which to retrieve the display variant code.
  1951      * @return The name of the display variant code appropriate to the given locale.
  1951      * @return The name of the display variant code appropriate to the given locale.
  1952      * @exception NullPointerException if <code>inLocale</code> is <code>null</code>
  1952      * @throws    NullPointerException if <code>inLocale</code> is <code>null</code>
  1953      */
  1953      */
  1954     public String getDisplayVariant(Locale inLocale) {
  1954     public String getDisplayVariant(Locale inLocale) {
  1955         if (baseLocale.getVariant().isEmpty())
  1955         if (baseLocale.getVariant().isEmpty())
  1956             return "";
  1956             return "";
  1957 
  1957