author | ohair |
Wed, 06 Apr 2011 22:06:11 -0700 | |
changeset 9035 | 1255eb81cc2f |
parent 8146 | f1b64e82649f |
permissions | -rw-r--r-- |
2 | 1 |
/* |
9035
1255eb81cc2f
7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents:
8146
diff
changeset
|
2 |
* Copyright (c) 2005, 2011, 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), |
|
8146
f1b64e82649f
7013282: No appropriate CCC request for listed JDK 7 changes in java.util.spi package (b121)
naoto
parents:
7252
diff
changeset
|
80 |
* this method returns null. The default implementation returns null. |
6501 | 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 |
*/ |
|
7252
2316b2e837d8
7000136: Backward compatibility problem in LocaleNameProvider
naoto
parents:
6501
diff
changeset
|
97 |
public String getDisplayScript(String scriptCode, Locale locale) { |
2316b2e837d8
7000136: Backward compatibility problem in LocaleNameProvider
naoto
parents:
6501
diff
changeset
|
98 |
return null; |
2316b2e837d8
7000136: Backward compatibility problem in LocaleNameProvider
naoto
parents:
6501
diff
changeset
|
99 |
} |
6501 | 100 |
|
101 |
/** |
|
102 |
* Returns a localized name for the given <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt"> |
|
103 |
* IETF BCP47</a> region code (either ISO 3166 country code or UN M.49 area |
|
104 |
* codes) and the given locale that is appropriate for display to the user. |
|
2 | 105 |
* For example, if <code>countryCode</code> is "FR" and <code>locale</code> |
106 |
* is en_US, getDisplayCountry() will return "France"; if <code>countryCode</code> |
|
107 |
* is "US" and <code>locale</code> is fr_FR, getDisplayCountry() will return "Etats-Unis". |
|
108 |
* If the name returned cannot be localized according to <code>locale</code>, |
|
109 |
* (say, the provider does not have a Japanese name for Croatia), |
|
110 |
* this method returns null. |
|
6501 | 111 |
* @param countryCode the country(region) code string in the form of two |
112 |
* upper-case letters between 'A' (U+0041) and 'Z' (U+005A) or the UN M.49 area code |
|
113 |
* in the form of three digit letters between '0' (U+0030) and '9' (U+0039). |
|
2 | 114 |
* @param locale the desired locale |
115 |
* @return the name of the given country code for the specified locale, or null if it's not |
|
116 |
* available. |
|
117 |
* @exception NullPointerException if <code>countryCode</code> or <code>locale</code> is null |
|
118 |
* @exception IllegalArgumentException if <code>countryCode</code> is not in the form of |
|
6501 | 119 |
* two upper-case letters or three digit letters, or <code>locale</code> isn't |
2 | 120 |
* one of the locales returned from |
121 |
* {@link java.util.spi.LocaleServiceProvider#getAvailableLocales() |
|
122 |
* getAvailableLocales()}. |
|
123 |
* @see java.util.Locale#getDisplayCountry(java.util.Locale) |
|
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 |
} |