< prev index next >

src/java.base/share/classes/java/util/spi/LocaleNameProvider.java

Print this page
rev 47733 : 8176841: Additional Unicode Language-Tag Extensions
8189134: New system properties for the default Locale extensions
Reviewed-by:
   1 /*
   2  * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.util.spi;
  27 
  28 import java.util.Locale;

  29 
  30 /**
  31  * An abstract class for service providers that
  32  * provide localized names for the
  33  * {@link java.util.Locale Locale} class.
  34  *
  35  * @since        1.6
  36  */
  37 public abstract class LocaleNameProvider extends LocaleServiceProvider {
  38 
  39     /**
  40      * Sole constructor.  (For invocation by subclass constructors, typically
  41      * implicit.)
  42      */
  43     protected LocaleNameProvider() {
  44     }
  45 
  46     /**
  47      * Returns a localized name for the given <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">
  48      * IETF BCP47</a> language code and the given locale that is appropriate for


 124      */
 125     public abstract String getDisplayCountry(String countryCode, Locale locale);
 126 
 127     /**
 128      * Returns a localized name for the given variant code and the given locale that
 129      * is appropriate for display to the user.
 130      * If the name returned cannot be localized according to <code>locale</code>,
 131      * this method returns null.
 132      * @param variant the variant string
 133      * @param locale the desired locale
 134      * @return the name of the given variant string for the specified locale, or null if it's not
 135      *     available.
 136      * @exception NullPointerException if <code>variant</code> or <code>locale</code> is null
 137      * @exception IllegalArgumentException if <code>locale</code> isn't
 138      *     one of the locales returned from
 139      *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
 140      *     getAvailableLocales()}.
 141      * @see java.util.Locale#getDisplayVariant(java.util.Locale)
 142      */
 143     public abstract String getDisplayVariant(String variant, Locale locale);


















































 144 }
   1 /*
   2  * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.util.spi;
  27 
  28 import java.util.Locale;
  29 import java.util.Objects;
  30 
  31 /**
  32  * An abstract class for service providers that
  33  * provide localized names for the
  34  * {@link java.util.Locale Locale} class.
  35  *
  36  * @since        1.6
  37  */
  38 public abstract class LocaleNameProvider extends LocaleServiceProvider {
  39 
  40     /**
  41      * Sole constructor.  (For invocation by subclass constructors, typically
  42      * implicit.)
  43      */
  44     protected LocaleNameProvider() {
  45     }
  46 
  47     /**
  48      * Returns a localized name for the given <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">
  49      * IETF BCP47</a> language code and the given locale that is appropriate for


 125      */
 126     public abstract String getDisplayCountry(String countryCode, Locale locale);
 127 
 128     /**
 129      * Returns a localized name for the given variant code and the given locale that
 130      * is appropriate for display to the user.
 131      * If the name returned cannot be localized according to <code>locale</code>,
 132      * this method returns null.
 133      * @param variant the variant string
 134      * @param locale the desired locale
 135      * @return the name of the given variant string for the specified locale, or null if it's not
 136      *     available.
 137      * @exception NullPointerException if <code>variant</code> or <code>locale</code> is null
 138      * @exception IllegalArgumentException if <code>locale</code> isn't
 139      *     one of the locales returned from
 140      *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
 141      *     getAvailableLocales()}.
 142      * @see java.util.Locale#getDisplayVariant(java.util.Locale)
 143      */
 144     public abstract String getDisplayVariant(String variant, Locale locale);
 145 
 146     /**
 147      * Returns a localized name for the given
 148      * <a href="../Locale.html#def_locale_extension">Unicode extension</a> key,
 149      * and the given locale that is appropriate for display to the user.
 150      * If the name returned cannot be localized according to <code>locale</code>,
 151      * this method returns null.
 152      * @implSpec the default implementation returns <code>null</code>.
 153      * @param key the Unicode Extension key, not null.
 154      * @param locale the desired locale, not null.
 155      * @return the name of the given key string for the specified locale,
 156      *  or null if it's not available.
 157      * @exception NullPointerException if <code>key</code> or <code>locale</code> is null
 158      * @exception IllegalArgumentException if <code>locale</code> isn't
 159      *     one of the locales returned from
 160      *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
 161      *     getAvailableLocales()}.
 162      * @since 10
 163      */
 164     public String getDisplayUnicodeExtensionKey(String key, Locale locale) {
 165         Objects.requireNonNull(key);
 166         Objects.requireNonNull(locale);
 167         return null;
 168     }
 169 
 170     /**
 171      * Returns a localized name for the given
 172      * <a href="../Locale.html#def_locale_extension">Unicode extension</a> type,
 173      * and the given locale that is appropriate for display to the user.
 174      * If the name returned cannot be localized according to <code>locale</code>,
 175      * this method returns null.
 176      * @implSpec the default implementation returns <code>null</code>.
 177      * @param type the Unicode Extension type, not null. 
 178      * @param key the Unicode Extension key for this <code>type</code>, not null.
 179      * @param locale the desired locale, not null.
 180      * @return the name of the given type string for the specified locale,
 181      *  or null if it's not available.
 182      * @exception NullPointerException if <code>key</code>, <code>type</code> or <code>locale</code> is null
 183      * @exception IllegalArgumentException if <code>locale</code> isn't
 184      *     one of the locales returned from
 185      *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
 186      *     getAvailableLocales()}.
 187      * @since 10
 188      */
 189     public String getDisplayUnicodeExtensionType(String type, String key, Locale locale) {
 190         Objects.requireNonNull(type);
 191         Objects.requireNonNull(key);
 192         Objects.requireNonNull(locale);
 193         return null;
 194     }
 195 }
< prev index next >