2 *******************************************************************************
\r
3 * Copyright (C) 2009-2010, International Business Machines Corporation and *
\r
4 * others. All Rights Reserved. *
\r
5 *******************************************************************************
\r
7 package com.ibm.icu.text;
\r
9 import java.util.Locale;
\r
11 import com.ibm.icu.impl.LocaleDisplayNamesImpl;
\r
12 import com.ibm.icu.util.ULocale;
\r
15 * Returns display names of ULocales and components of ULocales. For
\r
16 * more information on language, script, region, variant, key, and
\r
17 * values, see {@link com.ibm.icu.util.ULocale}.
\r
19 * @provisional This API might change or be removed in a future release.
\r
21 public abstract class LocaleDisplayNames {
\r
23 * Enum used in {@link #getInstance(ULocale, DialectHandling)}.
\r
25 * @provisional This API might change or be removed in a future release.
\r
27 public enum DialectHandling {
\r
29 * Use standard names when generating a locale name,
\r
30 * e.g. en_GB displays as 'English (United Kingdom)'.
\r
32 * @provisional This API might change or be removed in a future release.
\r
36 * Use dialect names when generating a locale name,
\r
37 * e.g. en_GB displays as 'British English'.
\r
39 * @provisional This API might change or be removed in a future release.
\r
46 * Convenience overload of {@link #getInstance(ULocale, DialectHandling)} that specifies
\r
47 * STANDARD dialect handling.
\r
48 * @param locale the display locale
\r
49 * @return a LocaleDisplayNames instance
\r
51 * @provisional This API might change or be removed in a future release.
\r
53 public static LocaleDisplayNames getInstance(ULocale locale) {
\r
54 return getInstance(locale, DialectHandling.STANDARD_NAMES);
\r
58 * Returns an instance of LocaleDisplayNames that returns names formatted for the provided locale,
\r
59 * using the provided dialectHandling.
\r
60 * @param locale the display locale
\r
61 * @param dialectHandling how to select names for locales
\r
62 * @return a LocaleDisplayNames instance
\r
64 * @provisional This API might change or be removed in a future release.
\r
66 public static LocaleDisplayNames getInstance(ULocale locale, DialectHandling dialectHandling) {
\r
67 return LocaleDisplayNamesImpl.getInstance(locale, dialectHandling);
\r
70 // getters for state
\r
72 * Returns the locale used to determine the display names. This is not necessarily the same
\r
73 * locale passed to {@link #getInstance}.
\r
74 * @return the display locale
\r
76 * @provisional This API might change or be removed in a future release.
\r
78 public abstract ULocale getLocale();
\r
81 * Returns the dialect handling used in the display names.
\r
82 * @return the dialect handling enum
\r
84 * @provisional This API might change or be removed in a future release.
\r
86 public abstract DialectHandling getDialectHandling();
\r
88 // names for entire locales
\r
90 * Returns the display name of the provided ulocale.
\r
91 * @param locale the locale whose display name to return
\r
92 * @return the display name of the provided locale
\r
94 * @provisional This API might change or be removed in a future release.
\r
96 public abstract String localeDisplayName(ULocale locale);
\r
99 * Returns the display name of the provided locale.
\r
100 * @param locale the locale whose display name to return
\r
101 * @return the display name of the provided locale
\r
103 * @provisional This API might change or be removed in a future release.
\r
105 public abstract String localeDisplayName(Locale locale);
\r
108 * Returns the display name of the provided locale id.
\r
109 * @param localeId the id of the locale whose display name to return
\r
110 * @return the display name of the provided locale
\r
112 * @provisional This API might change or be removed in a future release.
\r
114 public abstract String localeDisplayName(String localeId);
\r
116 // names for components of a locale id
\r
118 * Returns the display name of the provided language code.
\r
119 * @param lang the language code
\r
120 * @return the display name of the provided language code
\r
122 * @provisional This API might change or be removed in a future release.
\r
124 public abstract String languageDisplayName(String lang);
\r
127 * Returns the display name of the provided script code.
\r
128 * @param script the script code
\r
129 * @return the display name of the provided script code
\r
131 * @provisional This API might change or be removed in a future release.
\r
133 public abstract String scriptDisplayName(String script);
\r
136 * Returns the display name of the provided script code. See
\r
137 * {@link com.ibm.icu.lang.UScript} for recognized script codes.
\r
138 * @param scriptCode the script code number
\r
139 * @return the display name of the provided script code
\r
141 * @provisional This API might change or be removed in a future release.
\r
143 public abstract String scriptDisplayName(int scriptCode);
\r
146 * Returns the display name of the provided region code.
\r
147 * @param region the region code
\r
148 * @return the display name of the provided region code
\r
150 * @provisional This API might change or be removed in a future release.
\r
152 public abstract String regionDisplayName(String region);
\r
155 * Returns the display name of the provided variant.
\r
156 * @param variant the variant string
\r
157 * @return the display name of the provided variant
\r
159 * @provisional This API might change or be removed in a future release.
\r
161 public abstract String variantDisplayName(String variant);
\r
164 * Returns the display name of the provided locale key.
\r
165 * @param key the locale key name
\r
166 * @return the display name of the provided locale key
\r
168 * @provisional This API might change or be removed in a future release.
\r
170 public abstract String keyDisplayName(String key);
\r
173 * Returns the display name of the provided value (used with the provided key).
\r
174 * @param key the locale key name
\r
175 * @param value the locale key's value
\r
176 * @return the display name of the provided value
\r
178 * @provisional This API might change or be removed in a future release.
\r
180 public abstract String keyValueDisplayName(String key, String value);
\r
183 * Sole constructor. (For invocation by subclass constructors,
\r
184 * typically implicit.)
\r
186 * @deprecated This API is ICU internal only.
\r
188 protected LocaleDisplayNames() {
\r