1 |
771 |
jeremybenn |
/* LocaleNameProvider.java -- Providers of localized locale names
|
2 |
|
|
Copyright (C) 2007 Free Software Foundation, Inc.
|
3 |
|
|
|
4 |
|
|
This file is part of GNU Classpath.
|
5 |
|
|
|
6 |
|
|
GNU Classpath is free software; you can redistribute it and/or modify
|
7 |
|
|
it under the terms of the GNU General Public License as published by
|
8 |
|
|
the Free Software Foundation; either version 2, or (at your option)
|
9 |
|
|
any later version.
|
10 |
|
|
|
11 |
|
|
GNU Classpath is distributed in the hope that it will be useful, but
|
12 |
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
|
|
General Public License for more details.
|
15 |
|
|
|
16 |
|
|
You should have received a copy of the GNU General Public License
|
17 |
|
|
along with GNU Classpath; see the file COPYING. If not, write to the
|
18 |
|
|
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
19 |
|
|
02110-1301 USA.
|
20 |
|
|
|
21 |
|
|
Linking this library statically or dynamically with other modules is
|
22 |
|
|
making a combined work based on this library. Thus, the terms and
|
23 |
|
|
conditions of the GNU General Public License cover the whole
|
24 |
|
|
combination.
|
25 |
|
|
|
26 |
|
|
As a special exception, the copyright holders of this library give you
|
27 |
|
|
permission to link this library with independent modules to produce an
|
28 |
|
|
executable, regardless of the license terms of these independent
|
29 |
|
|
modules, and to copy and distribute the resulting executable under
|
30 |
|
|
terms of your choice, provided that you also meet, for each linked
|
31 |
|
|
independent module, the terms and conditions of the license of that
|
32 |
|
|
module. An independent module is a module which is not derived from
|
33 |
|
|
or based on this library. If you modify this library, you may extend
|
34 |
|
|
this exception to your version of the library, but you are not
|
35 |
|
|
obligated to do so. If you do not wish to do so, delete this
|
36 |
|
|
exception statement from your version. */
|
37 |
|
|
|
38 |
|
|
package java.util.spi;
|
39 |
|
|
|
40 |
|
|
import java.util.Locale;
|
41 |
|
|
|
42 |
|
|
/**
|
43 |
|
|
* A {@link LocaleNameProvider} provides localized
|
44 |
|
|
* versions of the names that represent a particular
|
45 |
|
|
* locale. Note that a <code>null</code> value may
|
46 |
|
|
* be returned, which should be treated as a lack of
|
47 |
|
|
* support for the specified {@link Locale}.
|
48 |
|
|
*
|
49 |
|
|
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
50 |
|
|
* @since 1.6
|
51 |
|
|
*/
|
52 |
|
|
public abstract class LocaleNameProvider
|
53 |
|
|
extends LocaleServiceProvider
|
54 |
|
|
{
|
55 |
|
|
|
56 |
|
|
/**
|
57 |
|
|
* Constructs a new {@link LocaleNameProvider}.
|
58 |
|
|
* Provided for implicit invocation by subclasses.
|
59 |
|
|
*/
|
60 |
|
|
protected LocaleNameProvider()
|
61 |
|
|
{
|
62 |
|
|
}
|
63 |
|
|
|
64 |
|
|
/**
|
65 |
|
|
* Returns the localized name for the specified ISO 3166
|
66 |
|
|
* country in the supplied {@link java.util.Locale}.
|
67 |
|
|
* For example, if the country code is <code>"DE"</code>,
|
68 |
|
|
* this method will return <code>"Germany"</code> for
|
69 |
|
|
* {@link Locale.ENGLISH} but <code>"Deutschland"</code>
|
70 |
|
|
* for {@link Locale.GERMANY}. If the name of the country
|
71 |
|
|
* in the given locale is not supported, <code>null</code>
|
72 |
|
|
* is returned.
|
73 |
|
|
*
|
74 |
|
|
* @param countryCode the ISO 3166 country code, consisting
|
75 |
|
|
* of two uppercase letters from 'A' to 'Z'
|
76 |
|
|
* @param locale the locale to express the country in.
|
77 |
|
|
* @return the country name, or <code>null</code> if one is
|
78 |
|
|
* not available.
|
79 |
|
|
* @throws NullPointerException if the locale is null.
|
80 |
|
|
* @throws IllegalArgumentException if the country code is
|
81 |
|
|
* not in the correct format
|
82 |
|
|
* or the locale is not one
|
83 |
|
|
* returned by
|
84 |
|
|
* {@link getAvailableLocales()}
|
85 |
|
|
* @see java.util.Locale#getDisplayCountry(java.util.Locale)
|
86 |
|
|
*/
|
87 |
|
|
public abstract String getDisplayCountry(String countryCode,
|
88 |
|
|
Locale locale);
|
89 |
|
|
|
90 |
|
|
/**
|
91 |
|
|
* Returns the localized name for the specified ISO 639
|
92 |
|
|
* language in the supplied {@link java.util.Locale}.
|
93 |
|
|
* For example, if the language code is <code>"de"</code>,
|
94 |
|
|
* this method will return <code>"German"</code> for
|
95 |
|
|
* {@link Locale.ENGLISH} but <code>"Deutsch"</code>
|
96 |
|
|
* for {@link Locale.GERMANY}. If the name of the language
|
97 |
|
|
* in the given locale is not supported, <code>null</code>
|
98 |
|
|
* is returned.
|
99 |
|
|
*
|
100 |
|
|
* @param langCode the ISO 639 language code, consisting
|
101 |
|
|
* of two lowercase letters from 'a' to 'z'
|
102 |
|
|
* @param locale the locale to express the language in.
|
103 |
|
|
* @return the country name, or <code>null</code> if one is
|
104 |
|
|
* not available.
|
105 |
|
|
* @throws NullPointerException if the locale is null.
|
106 |
|
|
* @throws IllegalArgumentException if the language code is
|
107 |
|
|
* not in the correct format
|
108 |
|
|
* or the locale is not one
|
109 |
|
|
* returned by
|
110 |
|
|
* {@link getAvailableLocales()}
|
111 |
|
|
* @see java.util.Locale#getDisplayLanguage(java.util.Locale)
|
112 |
|
|
*/
|
113 |
|
|
public abstract String getDisplayLanguage(String langCode,
|
114 |
|
|
Locale locale);
|
115 |
|
|
|
116 |
|
|
/**
|
117 |
|
|
* Returns the localized name for the specified variant
|
118 |
|
|
* in the supplied {@link java.util.Locale}. If the name
|
119 |
|
|
* of the variant in the given locale is not supported,
|
120 |
|
|
* <code>null</code> is returned.
|
121 |
|
|
*
|
122 |
|
|
* @param variant the variant.
|
123 |
|
|
* @param locale the locale to express the variant in.
|
124 |
|
|
* @return the localized variant, or <code>null</code> if one is
|
125 |
|
|
* not available.
|
126 |
|
|
* @throws NullPointerException if the locale is null.
|
127 |
|
|
* @throws IllegalArgumentException if the locale is not one
|
128 |
|
|
* returned by
|
129 |
|
|
* {@link getAvailableLocales()}
|
130 |
|
|
* @see java.util.Locale#getDisplayVariant(java.util.Locale)
|
131 |
|
|
*/
|
132 |
|
|
public abstract String getDisplayVariant(String variant,
|
133 |
|
|
Locale locale);
|
134 |
|
|
|
135 |
|
|
}
|