2
|
1 |
/*
|
6501
|
2 |
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
2
|
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
|
5506
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
2
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
5506
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
2
|
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 |
*
|
5506
|
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.
|
2
|
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 |
/**
|
6501
|
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
|
|
49 |
* display to the user.
|
2
|
50 |
* For example, if <code>languageCode</code> is "fr" and <code>locale</code>
|
|
51 |
* is en_US, getDisplayLanguage() will return "French"; if <code>languageCode</code>
|
|
52 |
* is "en" and <code>locale</code> is fr_FR, getDisplayLanguage() will return "anglais".
|
|
53 |
* If the name returned cannot be localized according to <code>locale</code>,
|
|
54 |
* (say, the provider does not have a Japanese name for Croatian),
|
|
55 |
* this method returns null.
|
6501
|
56 |
* @param languageCode the language code string in the form of two to eight
|
2
|
57 |
* lower-case letters between 'a' (U+0061) and 'z' (U+007A)
|
|
58 |
* @param locale the desired locale
|
|
59 |
* @return the name of the given language code for the specified locale, or null if it's not
|
|
60 |
* available.
|
|
61 |
* @exception NullPointerException if <code>languageCode</code> or <code>locale</code> is null
|
|
62 |
* @exception IllegalArgumentException if <code>languageCode</code> is not in the form of
|
6501
|
63 |
* two or three lower-case letters, or <code>locale</code> isn't
|
2
|
64 |
* one of the locales returned from
|
|
65 |
* {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
|
|
66 |
* getAvailableLocales()}.
|
|
67 |
* @see java.util.Locale#getDisplayLanguage(java.util.Locale)
|
|
68 |
*/
|
|
69 |
public abstract String getDisplayLanguage(String languageCode, Locale locale);
|
|
70 |
|
|
71 |
/**
|
6501
|
72 |
* Returns a localized name for the given <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">
|
|
73 |
* IETF BCP47</a> script code and the given locale that is appropriate for
|
|
74 |
* display to the user.
|
|
75 |
* For example, if <code>scriptCode</code> is "Latn" and <code>locale</code>
|
|
76 |
* is en_US, getDisplayScript() will return "Latin"; if <code>scriptCode</code>
|
|
77 |
* is "Cyrl" and <code>locale</code> is fr_FR, getDisplayScript() will return "cyrillique".
|
|
78 |
* If the name returned cannot be localized according to <code>locale</code>,
|
|
79 |
* (say, the provider does not have a Japanese name for Cyrillic),
|
|
80 |
* this method returns null.
|
|
81 |
* @param scriptCode the four letter script code string in the form of title-case
|
|
82 |
* letters (the first letter is upper-case character between 'A' (U+0041) and
|
|
83 |
* 'Z' (U+005A) followed by three lower-case character between 'a' (U+0061)
|
|
84 |
* and 'z' (U+007A)).
|
|
85 |
* @param locale the desired locale
|
|
86 |
* @return the name of the given script code for the specified locale, or null if it's not
|
|
87 |
* available.
|
|
88 |
* @exception NullPointerException if <code>scriptCode</code> or <code>locale</code> is null
|
|
89 |
* @exception IllegalArgumentException if <code>scriptCode</code> is not in the form of
|
|
90 |
* four title case letters, or <code>locale</code> isn't
|
|
91 |
* one of the locales returned from
|
|
92 |
* {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
|
|
93 |
* getAvailableLocales()}.
|
|
94 |
* @see java.util.Locale#getDisplayScript(java.util.Locale)
|
|
95 |
* @since 1.7
|
|
96 |
*/
|
|
97 |
public abstract String getDisplayScript(String scriptCode, Locale locale);
|
|
98 |
|
|
99 |
/**
|
|
100 |
* Returns a localized name for the given <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">
|
|
101 |
* IETF BCP47</a> region code (either ISO 3166 country code or UN M.49 area
|
|
102 |
* codes) and the given locale that is appropriate for display to the user.
|
2
|
103 |
* For example, if <code>countryCode</code> is "FR" and <code>locale</code>
|
|
104 |
* is en_US, getDisplayCountry() will return "France"; if <code>countryCode</code>
|
|
105 |
* is "US" and <code>locale</code> is fr_FR, getDisplayCountry() will return "Etats-Unis".
|
|
106 |
* If the name returned cannot be localized according to <code>locale</code>,
|
|
107 |
* (say, the provider does not have a Japanese name for Croatia),
|
|
108 |
* this method returns null.
|
6501
|
109 |
* @param countryCode the country(region) code string in the form of two
|
|
110 |
* upper-case letters between 'A' (U+0041) and 'Z' (U+005A) or the UN M.49 area code
|
|
111 |
* in the form of three digit letters between '0' (U+0030) and '9' (U+0039).
|
2
|
112 |
* @param locale the desired locale
|
|
113 |
* @return the name of the given country code for the specified locale, or null if it's not
|
|
114 |
* available.
|
|
115 |
* @exception NullPointerException if <code>countryCode</code> or <code>locale</code> is null
|
|
116 |
* @exception IllegalArgumentException if <code>countryCode</code> is not in the form of
|
6501
|
117 |
* two upper-case letters or three digit letters, or <code>locale</code> isn't
|
2
|
118 |
* one of the locales returned from
|
|
119 |
* {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
|
|
120 |
* getAvailableLocales()}.
|
|
121 |
* @see java.util.Locale#getDisplayCountry(java.util.Locale)
|
|
122 |
*/
|
|
123 |
public abstract String getDisplayCountry(String countryCode, Locale locale);
|
|
124 |
|
|
125 |
/**
|
|
126 |
* Returns a localized name for the given variant code and the given locale that
|
|
127 |
* is appropriate for display to the user.
|
|
128 |
* If the name returned cannot be localized according to <code>locale</code>,
|
|
129 |
* this method returns null.
|
|
130 |
* @param variant the variant string
|
|
131 |
* @param locale the desired locale
|
|
132 |
* @return the name of the given variant string for the specified locale, or null if it's not
|
|
133 |
* available.
|
|
134 |
* @exception NullPointerException if <code>variant</code> or <code>locale</code> is null
|
|
135 |
* @exception IllegalArgumentException if <code>locale</code> isn't
|
|
136 |
* one of the locales returned from
|
|
137 |
* {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
|
|
138 |
* getAvailableLocales()}.
|
|
139 |
* @see java.util.Locale#getDisplayVariant(java.util.Locale)
|
|
140 |
*/
|
|
141 |
public abstract String getDisplayVariant(String variant, Locale locale);
|
|
142 |
}
|