blob: 687e38f9676053ff7b28a2900a99848cf3ee2aa1 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2005 Sun Microsystems, Inc. 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. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26package java.util.spi;
27
28import 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 */
37public 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 ISO 639 language code and the
48 * given locale that is appropriate for display to the user.
49 * For example, if <code>languageCode</code> is "fr" and <code>locale</code>
50 * is en_US, getDisplayLanguage() will return "French"; if <code>languageCode</code>
51 * is "en" and <code>locale</code> is fr_FR, getDisplayLanguage() will return "anglais".
52 * If the name returned cannot be localized according to <code>locale</code>,
53 * (say, the provider does not have a Japanese name for Croatian),
54 * this method returns null.
55 * @param languageCode the ISO 639 language code string in the form of two
56 * lower-case letters between 'a' (U+0061) and 'z' (U+007A)
57 * @param locale the desired locale
58 * @return the name of the given language code for the specified locale, or null if it's not
59 * available.
60 * @exception NullPointerException if <code>languageCode</code> or <code>locale</code> is null
61 * @exception IllegalArgumentException if <code>languageCode</code> is not in the form of
62 * two lower-case letters, or <code>locale</code> isn't
63 * one of the locales returned from
64 * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
65 * getAvailableLocales()}.
66 * @see java.util.Locale#getDisplayLanguage(java.util.Locale)
67 */
68 public abstract String getDisplayLanguage(String languageCode, Locale locale);
69
70 /**
71 * Returns a localized name for the given ISO 3166 country code and the
72 * given locale that is appropriate for display to the user.
73 * For example, if <code>countryCode</code> is "FR" and <code>locale</code>
74 * is en_US, getDisplayCountry() will return "France"; if <code>countryCode</code>
75 * is "US" and <code>locale</code> is fr_FR, getDisplayCountry() will return "Etats-Unis".
76 * If the name returned cannot be localized according to <code>locale</code>,
77 * (say, the provider does not have a Japanese name for Croatia),
78 * this method returns null.
79 * @param countryCode the ISO 3166 country code string in the form of two
80 * upper-case letters between 'A' (U+0041) and 'Z' (U+005A)
81 * @param locale the desired locale
82 * @return the name of the given country code for the specified locale, or null if it's not
83 * available.
84 * @exception NullPointerException if <code>countryCode</code> or <code>locale</code> is null
85 * @exception IllegalArgumentException if <code>countryCode</code> is not in the form of
86 * two upper-case letters, or <code>locale</code> isn't
87 * one of the locales returned from
88 * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
89 * getAvailableLocales()}.
90 * @see java.util.Locale#getDisplayCountry(java.util.Locale)
91 */
92 public abstract String getDisplayCountry(String countryCode, Locale locale);
93
94 /**
95 * Returns a localized name for the given variant code and the given locale that
96 * is appropriate for display to the user.
97 * If the name returned cannot be localized according to <code>locale</code>,
98 * this method returns null.
99 * @param variant the variant string
100 * @param locale the desired locale
101 * @return the name of the given variant string for the specified locale, or null if it's not
102 * available.
103 * @exception NullPointerException if <code>variant</code> or <code>locale</code> is null
104 * @exception IllegalArgumentException if <code>locale</code> isn't
105 * one of the locales returned from
106 * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
107 * getAvailableLocales()}.
108 * @see java.util.Locale#getDisplayVariant(java.util.Locale)
109 */
110 public abstract String getDisplayVariant(String variant, Locale locale);
111}