src/java.base/share/classes/sun/util/locale/provider/LocaleNameProviderImpl.java

Print this page




  43 
  44     public LocaleNameProviderImpl(LocaleProviderAdapter.Type type, Set<String> langtags) {
  45         this.type = type;
  46         this.langtags = langtags;
  47     }
  48 
  49     /**
  50      * Returns an array of all locales for which this locale service provider
  51      * can provide localized objects or names.
  52      *
  53      * @return An array of all locales for which this locale service provider
  54      * can provide localized objects or names.
  55      */
  56     @Override
  57     public Locale[] getAvailableLocales() {
  58         return LocaleProviderAdapter.toLocaleArray(langtags);
  59     }
  60 
  61     @Override
  62     public boolean isSupportedLocale(Locale locale) {
  63         return LocaleProviderAdapter.isSupportedLocale(locale, type, langtags);
  64     }
  65 
  66     /**
  67      * Returns a localized name for the given ISO 639 language code and the
  68      * given locale that is appropriate for display to the user.
  69      * For example, if <code>languageCode</code> is "fr" and <code>locale</code>
  70      * is en_US, getDisplayLanguage() will return "French"; if <code>languageCode</code>
  71      * is "en" and <code>locale</code> is fr_FR, getDisplayLanguage() will return "anglais".
  72      * If the name returned cannot be localized according to <code>locale</code>,
  73      * (say, the provider does not have a Japanese name for Croatian),
  74      * this method returns null.
  75      * @param lang the ISO 639 language code string in the form of two
  76      *     lower-case letters between 'a' (U+0061) and 'z' (U+007A)
  77      * @param locale the desired locale
  78      * @return the name of the given language code for the specified locale, or null if it's not
  79      *     available.
  80      * @exception NullPointerException if <code>languageCode</code> or <code>locale</code> is null
  81      * @exception IllegalArgumentException if <code>languageCode</code> is not in the form of
  82      *     two lower-case letters, or <code>locale</code> isn't
  83      *     one of the locales returned from




  43 
  44     public LocaleNameProviderImpl(LocaleProviderAdapter.Type type, Set<String> langtags) {
  45         this.type = type;
  46         this.langtags = langtags;
  47     }
  48 
  49     /**
  50      * Returns an array of all locales for which this locale service provider
  51      * can provide localized objects or names.
  52      *
  53      * @return An array of all locales for which this locale service provider
  54      * can provide localized objects or names.
  55      */
  56     @Override
  57     public Locale[] getAvailableLocales() {
  58         return LocaleProviderAdapter.toLocaleArray(langtags);
  59     }
  60 
  61     @Override
  62     public boolean isSupportedLocale(Locale locale) {
  63         return LocaleProviderAdapter.forType(type).isSupportedProviderLocale(locale, langtags);
  64     }
  65 
  66     /**
  67      * Returns a localized name for the given ISO 639 language code and the
  68      * given locale that is appropriate for display to the user.
  69      * For example, if <code>languageCode</code> is "fr" and <code>locale</code>
  70      * is en_US, getDisplayLanguage() will return "French"; if <code>languageCode</code>
  71      * is "en" and <code>locale</code> is fr_FR, getDisplayLanguage() will return "anglais".
  72      * If the name returned cannot be localized according to <code>locale</code>,
  73      * (say, the provider does not have a Japanese name for Croatian),
  74      * this method returns null.
  75      * @param lang the ISO 639 language code string in the form of two
  76      *     lower-case letters between 'a' (U+0061) and 'z' (U+007A)
  77      * @param locale the desired locale
  78      * @return the name of the given language code for the specified locale, or null if it's not
  79      *     available.
  80      * @exception NullPointerException if <code>languageCode</code> or <code>locale</code> is null
  81      * @exception IllegalArgumentException if <code>languageCode</code> is not in the form of
  82      *     two lower-case letters, or <code>locale</code> isn't
  83      *     one of the locales returned from