⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 locale.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* Locale.java -- i18n locales   Copyright (C) 1998, 1999, 2001, 2002, 2005  Free Software Foundation, Inc.This file is part of GNU Classpath.GNU Classpath is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU Classpath is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Classpath; see the file COPYING.  If not, write to theFree Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA02110-1301 USA.Linking this library statically or dynamically with other modules ismaking a combined work based on this library.  Thus, the terms andconditions of the GNU General Public License cover the wholecombination.As a special exception, the copyright holders of this library give youpermission to link this library with independent modules to produce anexecutable, regardless of the license terms of these independentmodules, and to copy and distribute the resulting executable underterms of your choice, provided that you also meet, for each linkedindependent module, the terms and conditions of the license of thatmodule.  An independent module is a module which is not derived fromor based on this library.  If you modify this library, you may extendthis exception to your version of the library, but you are notobligated to do so.  If you do not wish to do so, delete thisexception statement from your version. */package java.util;import gnu.classpath.SystemProperties;import java.io.IOException;import java.io.ObjectInputStream;import java.io.ObjectOutputStream;import java.io.Serializable;/** * Locales represent a specific country and culture. Classes which can be * passed a Locale object tailor their information for a given locale. For * instance, currency number formatting is handled differently for the USA * and France. * * <p>Locales are made up of a language code, a country code, and an optional * set of variant strings. Language codes are represented by * <a href="http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt"> * ISO 639:1988</a> w/ additions from ISO 639/RA Newsletter No. 1/1989 * and a decision of the Advisory Committee of ISO/TC39 on August 8, 1997. * * <p>Country codes are represented by * <a href="http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html"> * ISO 3166</a>. Variant strings are vendor and browser specific. Standard * variant strings include "POSIX" for POSIX, "WIN" for MS-Windows, and * "MAC" for Macintosh. When there is more than one variant string, they must * be separated by an underscore (U+005F). * * <p>The default locale is determined by the values of the system properties * user.language, user.region, and user.variant, defaulting to "en". Note that * the locale does NOT contain the conversion and formatting capabilities (for * that, use ResourceBundle and java.text). Rather, it is an immutable tag * object for identifying a given locale, which is referenced by these other * classes when they must make locale-dependent decisions. * * @see ResourceBundle * @see java.text.Format * @see java.text.NumberFormat * @see java.text.Collator * @author Jochen Hoenicke * @author Paul Fisher * @author Eric Blake (ebb9@email.byu.edu) * @author Andrew John Hughes (gnu_andrew@member.fsf.org) * @since 1.1 * @status updated to 1.4 */public final class Locale implements Serializable, Cloneable{  /** Locale which represents the English language. */  public static final Locale ENGLISH = getLocale("en");  /** Locale which represents the French language. */  public static final Locale FRENCH = getLocale("fr");  /** Locale which represents the German language. */  public static final Locale GERMAN = getLocale("de");  /** Locale which represents the Italian language. */  public static final Locale ITALIAN = getLocale("it");  /** Locale which represents the Japanese language. */  public static final Locale JAPANESE = getLocale("ja");  /** Locale which represents the Korean language. */  public static final Locale KOREAN = getLocale("ko");  /** Locale which represents the Chinese language. */  public static final Locale CHINESE = getLocale("zh");  /** Locale which represents the Chinese language as used in China. */  public static final Locale SIMPLIFIED_CHINESE = getLocale("zh", "CN");  /**   * Locale which represents the Chinese language as used in Taiwan.   * Same as TAIWAN Locale.   */  public static final Locale TRADITIONAL_CHINESE = getLocale("zh", "TW");  /** Locale which represents France. */  public static final Locale FRANCE = getLocale("fr", "FR");  /** Locale which represents Germany. */  public static final Locale GERMANY = getLocale("de", "DE");  /** Locale which represents Italy. */  public static final Locale ITALY = getLocale("it", "IT");  /** Locale which represents Japan. */  public static final Locale JAPAN = getLocale("ja", "JP");  /** Locale which represents Korea. */  public static final Locale KOREA = getLocale("ko", "KR");  /**   * Locale which represents China.   * Same as SIMPLIFIED_CHINESE Locale.   */  public static final Locale CHINA = SIMPLIFIED_CHINESE;  /**   * Locale which represents the People's Republic of China.   * Same as CHINA Locale.   */  public static final Locale PRC = CHINA;  /**   * Locale which represents Taiwan.   * Same as TRADITIONAL_CHINESE Locale.   */  public static final Locale TAIWAN = TRADITIONAL_CHINESE;  /** Locale which represents the United Kingdom. */  public static final Locale UK = getLocale("en", "GB");  /** Locale which represents the United States. */  public static final Locale US = getLocale("en", "US");  /** Locale which represents the English speaking portion of Canada. */  public static final Locale CANADA = getLocale("en", "CA");  /** Locale which represents the French speaking portion of Canada. */  public static final Locale CANADA_FRENCH = getLocale("fr", "CA");  /**   * Compatible with JDK 1.1+.   */  private static final long serialVersionUID = 9149081749638150636L;  /**   * The language code, as returned by getLanguage().   *   * @serial the languange, possibly ""   */  private String language;  /**   * The country code, as returned by getCountry().   *   * @serial the country, possibly ""   */  private String country;  /**   * The variant code, as returned by getVariant().   *   * @serial the variant, possibly ""   */  private String variant;  /**   * This is the cached hashcode. When writing to stream, we write -1.   *   * @serial should be -1 in serial streams   */  private transient int hashcode;  /**   * The default locale. Except for during bootstrapping, this should never be   * null. Note the logic in the main constructor, to detect when   * bootstrapping has completed.   */  private static Locale defaultLocale =    getLocale(SystemProperties.getProperty("user.language", "en"),              SystemProperties.getProperty("user.region", ""),              SystemProperties.getProperty("user.variant", ""));  /**   * Retrieves the locale with the specified language from the cache.   *   * @param language the language of the locale to retrieve.   * @return the locale.   */   private static Locale getLocale(String language)  {    return getLocale(language, "", "");  }    /**   * Retrieves the locale with the specified language and region   * from the cache.   *   * @param language the language of the locale to retrieve.   * @param region the region of the locale to retrieve.   * @return the locale.   */   private static Locale getLocale(String language, String region)  {    return getLocale(language, region, "");  }    /**   * Retrieves the locale with the specified language, region   * and variant from the cache.   *   * @param language the language of the locale to retrieve.   * @param region the region of the locale to retrieve.   * @param variant the variant of the locale to retrieve.   * @return the locale.   */   private static Locale getLocale(String language, String region, String variant)  {    return new Locale(language, region, variant);  }    /**   * Convert new iso639 codes to the old ones.   *   * @param language the language to check   * @return the appropriate code   */  private String convertLanguage(String language)  {    if (language.equals(""))      return language;    language = language.toLowerCase();    int index = "he,id,yi".indexOf(language);    if (index != -1)      return "iw,in,ji".substring(index, index + 2);    return language;  }  /**   * Creates a new locale for the given language and country.   *   * @param language lowercase two-letter ISO-639 A2 language code   * @param country uppercase two-letter ISO-3166 A2 contry code   * @param variant vendor and browser specific   * @throws NullPointerException if any argument is null   */  public Locale(String language, String country, String variant)  {    // During bootstrap, we already know the strings being passed in are    // the correct capitalization, and not null. We can't call    // String.toUpperCase during this time, since that depends on the    // default locale.    if (defaultLocale != null)      {        language = convertLanguage(language).intern();        country = country.toUpperCase().intern();        variant = variant.intern();      }    this.language = language;    this.country = country;    this.variant = variant;    hashcode = language.hashCode() ^ country.hashCode() ^ variant.hashCode();  }  /**   * Creates a new locale for the given language and country.   *   * @param language lowercase two-letter ISO-639 A2 language code

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -