/[classpath]/classpath/java/util/Locale.java
ViewVC logotype

Diff of /classpath/java/util/Locale.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.19.2.2 by gnu_andrew, Sun Jan 16 15:15:12 2005 UTC revision 1.19.2.3 by gnu_andrew, Mon Jan 31 03:10:46 2005 UTC
# Line 39  exception statement from your version. * Line 39  exception statement from your version. *
39  package java.util;  package java.util;
40    
41  import gnu.classpath.SystemProperties;  import gnu.classpath.SystemProperties;
42    import gnu.java.locale.LocaleHelper;
43    
44  import java.io.IOException;  import java.io.IOException;
45  import java.io.ObjectInputStream;  import java.io.ObjectInputStream;
# Line 617  public final class Locale implements Ser Line 618  public final class Locale implements Ser
618     */     */
619    public String getDisplayLanguage(Locale inLocale)    public String getDisplayLanguage(Locale inLocale)
620    {    {
621      return getDisplayString(inLocale, language, "languages");      return LocaleHelper.getLocalizedString(inLocale, language,
622                                               "languages", true, false);
623    }    }
624    
625    /**    /**
# Line 663  public final class Locale implements Ser Line 665  public final class Locale implements Ser
665     */     */
666    public String getDisplayCountry(Locale inLocale)    public String getDisplayCountry(Locale inLocale)
667    {    {
668      return getDisplayString(inLocale, country, "territories");      return LocaleHelper.getLocalizedString(inLocale, country,
669                                                "territories", true, false);
670    }    }
671    
672    /**    /**
# Line 688  public final class Locale implements Ser Line 691  public final class Locale implements Ser
691     * Gets the name of the variant specified by this locale, in a form suitable     * Gets the name of the variant specified by this locale, in a form suitable
692     * for display to the user.  If possible, the display name will be localized     * for display to the user.  If possible, the display name will be localized
693     * to the specified locale.  For example, if the locale instance is a revised     * to the specified locale.  For example, if the locale instance is a revised
694     * variant, and the specified locale is <code>Locale.UK</code>, the result would be     * variant, and the specified locale is <code>Locale.UK</code>, the result
695     * 'REVISED'.  Using the German locale would instead give 'Revidiert'.  If the     * would be 'REVISED'.  Using the German locale would instead give
696     * display name can not be localized to the supplied locale, it will fall back on     * 'Revidiert'.  If the display name can not be localized to the supplied
697     * other output in the following order:     * locale, it will fall back on other output in the following order:
698     * </p>     * </p>
699     * <ul>     * <ul>
700     * <li>the display name in the default locale</li>     * <li>the display name in the default locale</li>
# Line 710  public final class Locale implements Ser Line 713  public final class Locale implements Ser
713     */     */
714    public String getDisplayVariant(Locale inLocale)    public String getDisplayVariant(Locale inLocale)
715    {    {
716      return getDisplayString(inLocale, variant, "variants");      return LocaleHelper.getLocalizedString(inLocale, variant, "variants",
717    }                                             true, false);
   
   /**  
    * This method is used by the display name lookup methods to retrieve  
    * the localized name of a particular piece of locale data.      
    * If the display name can not be localized to the supplied  
    * locale, it will fall back on other output in the following order:  
    * </p>  
    * <ul>  
    * <li>the display name in the default locale</li>  
    * <li>the display name in English</li>  
    * <li>the ISO code</li>  
    * </ul>  
    * <p>  
    * If the language is unspecified by this locale, then the empty string is  
    * returned.  
    * </p>  
    *  
    * @param inLocale the locale to use for formatting the display string.  
    * @param key the locale data used as a key to the localized lookup tables.  
    * @param tableName the name of the hashtable containing the localized data.  
    */  
   private String getDisplayString(Locale inLocale, String key, String tableName)  
   {  
     String displayString;  
     Hashtable table;  
   
     if (key.equals(""))  
       {  
         return "";  
       }  
     /* Display in inLocale */  
     try  
       {  
         table = (Hashtable)  
           ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",  
                                    inLocale).getObject(tableName);  
         displayString = (String) table.get(key);  
       }  
     catch (MissingResourceException exception)  
       {  
         displayString = null;  
       }  
     /* Display in default locale */  
     if (displayString == null)  
       {  
         try  
           {  
             ResourceBundle bundle;  
               
             bundle = ResourceBundle.getBundle("gnu.java.locale.LocaleInformation");  
             table = (Hashtable) bundle.getObject(tableName);  
             displayString = (String) table.get(key);  
           }  
         catch (MissingResourceException exception)  
           {  
             displayString = null;  
           }  
       }  
     /* Display in English */  
     if (displayString == null)  
       {  
         try  
           {  
             table = (Hashtable)  
               ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",  
                                        Locale.ENGLISH).getObject(tableName);  
             displayString= (String) table.get(key);  
           }  
         catch (MissingResourceException exception)  
           {  
             displayString = null;  
           }  
       }  
     /* Display ISO code */  
     if (displayString == null)  
       {  
         displayString = key;  
       }  
     return displayString;  
718    }    }
719    
720    /**    /**

Legend:
Removed from v.1.19.2.2  
changed lines
  Added in v.1.19.2.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26