jdk/src/share/classes/java/util/spi/LocaleNameProvider.java
author naoto
Wed, 21 Jan 2009 13:58:46 -0800
changeset 1848 6ecbe9158c6e
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
6627549: ISO 3166 code addition: Saint Barthelemy and Saint Martin 6786276: Locale.getISOCountries() still contains country code "CS" Reviewed-by: okutsu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.util.spi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.Locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * An abstract class for service providers that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * provide localized names for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * {@link java.util.Locale Locale} class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * @since        1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
public abstract class LocaleNameProvider extends LocaleServiceProvider {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
     * Sole constructor.  (For invocation by subclass constructors, typically
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
     * implicit.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    protected LocaleNameProvider() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     * Returns a localized name for the given ISO 639 language code and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     * given locale that is appropriate for display to the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     * For example, if <code>languageCode</code> is "fr" and <code>locale</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     * is en_US, getDisplayLanguage() will return "French"; if <code>languageCode</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * is "en" and <code>locale</code> is fr_FR, getDisplayLanguage() will return "anglais".
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * If the name returned cannot be localized according to <code>locale</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * (say, the provider does not have a Japanese name for Croatian),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * this method returns null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * @param languageCode the ISO 639 language code string in the form of two
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     *     lower-case letters between 'a' (U+0061) and 'z' (U+007A)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * @param locale the desired locale
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * @return the name of the given language code for the specified locale, or null if it's not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     *     available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * @exception NullPointerException if <code>languageCode</code> or <code>locale</code> is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * @exception IllegalArgumentException if <code>languageCode</code> is not in the form of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     *     two lower-case letters, or <code>locale</code> isn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     *     one of the locales returned from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     *     getAvailableLocales()}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * @see java.util.Locale#getDisplayLanguage(java.util.Locale)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    public abstract String getDisplayLanguage(String languageCode, Locale locale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * Returns a localized name for the given ISO 3166 country code and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * given locale that is appropriate for display to the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * For example, if <code>countryCode</code> is "FR" and <code>locale</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * is en_US, getDisplayCountry() will return "France"; if <code>countryCode</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * is "US" and <code>locale</code> is fr_FR, getDisplayCountry() will return "Etats-Unis".
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * If the name returned cannot be localized according to <code>locale</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * (say, the provider does not have a Japanese name for Croatia),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * this method returns null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * @param countryCode the ISO 3166 country code string in the form of two
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     *     upper-case letters between 'A' (U+0041) and 'Z' (U+005A)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * @param locale the desired locale
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * @return the name of the given country code for the specified locale, or null if it's not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     *     available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * @exception NullPointerException if <code>countryCode</code> or <code>locale</code> is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * @exception IllegalArgumentException if <code>countryCode</code> is not in the form of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     *     two upper-case letters, or <code>locale</code> isn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     *     one of the locales returned from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     *     getAvailableLocales()}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * @see java.util.Locale#getDisplayCountry(java.util.Locale)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    public abstract String getDisplayCountry(String countryCode, Locale locale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * Returns a localized name for the given variant code and the given locale that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * is appropriate for display to the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * If the name returned cannot be localized according to <code>locale</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * this method returns null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * @param variant the variant string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @param locale the desired locale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * @return the name of the given variant string for the specified locale, or null if it's not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     *     available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * @exception NullPointerException if <code>variant</code> or <code>locale</code> is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * @exception IllegalArgumentException if <code>locale</code> isn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     *     one of the locales returned from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     *     getAvailableLocales()}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * @see java.util.Locale#getDisplayVariant(java.util.Locale)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public abstract String getDisplayVariant(String variant, Locale locale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
}