本文整理汇总了Java中java.util.spi.TimeZoneNameProvider类的典型用法代码示例。如果您正苦于以下问题:Java TimeZoneNameProvider类的具体用法?Java TimeZoneNameProvider怎么用?Java TimeZoneNameProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TimeZoneNameProvider类属于java.util.spi包,在下文中一共展示了TimeZoneNameProvider类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadZoneStrings
import java.util.spi.TimeZoneNameProvider; //导入依赖的package包/类
private static String[][] loadZoneStrings(Locale locale) {
// If the provider is a TimeZoneNameProviderImpl, call its getZoneStrings
// in order to avoid per-ID retrieval.
LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(TimeZoneNameProvider.class, locale);
TimeZoneNameProvider provider = adapter.getTimeZoneNameProvider();
if (provider instanceof TimeZoneNameProviderImpl) {
return ((TimeZoneNameProviderImpl)provider).getZoneStrings(locale);
}
// Performs per-ID retrieval.
Set<String> zoneIDs = LocaleProviderAdapter.forJRE().getLocaleResources(locale).getZoneIDs();
List<String[]> zones = new LinkedList<>();
for (String key : zoneIDs) {
String[] names = retrieveDisplayNamesImpl(key, locale);
if (names != null) {
zones.add(names);
}
}
String[][] zonesArray = new String[zones.size()][];
return zones.toArray(zonesArray);
}
示例2: examineAliases
import java.util.spi.TimeZoneNameProvider; //导入依赖的package包/类
private static String[] examineAliases(TimeZoneNameProvider tznp, Locale locale,
String id,
Map<String, String> aliases) {
if (aliases.containsValue(id)) {
for (Map.Entry<String, String> entry : aliases.entrySet()) {
if (entry.getValue().equals(id)) {
String alias = entry.getKey();
String[] names = buildZoneStrings(tznp, locale, alias);
if (names != null) {
return names;
}
names = examineAliases(tznp, locale, alias, aliases);
if (names != null) {
return names;
}
}
}
}
return null;
}
示例3: getObject
import java.util.spi.TimeZoneNameProvider; //导入依赖的package包/类
@Override
public String getObject(TimeZoneNameProvider timeZoneNameProvider,
Locale locale,
String requestID,
Object... params) {
assert params.length == 2;
int style = (int) params[0];
String tzid = (String) params[1];
String value = getName(timeZoneNameProvider, locale, requestID, style, tzid);
if (value == null) {
Map<String, String> aliases = ZoneInfo.getAliasTable();
if (aliases != null) {
String canonicalID = aliases.get(tzid);
if (canonicalID != null) {
value = getName(timeZoneNameProvider, locale, requestID, style, canonicalID);
}
if (value == null) {
value = examineAliases(timeZoneNameProvider, locale, requestID,
canonicalID != null ? canonicalID : tzid, style, aliases);
}
}
}
return value;
}
示例4: getName
import java.util.spi.TimeZoneNameProvider; //导入依赖的package包/类
private static String getName(TimeZoneNameProvider timeZoneNameProvider,
Locale locale, String requestID, int style, String tzid) {
String value = null;
switch (requestID) {
case "std":
value = timeZoneNameProvider.getDisplayName(tzid, false, style, locale);
break;
case "dst":
value = timeZoneNameProvider.getDisplayName(tzid, true, style, locale);
break;
case "generic":
value = timeZoneNameProvider.getGenericDisplayName(tzid, style, locale);
break;
}
return value;
}
示例5: examineAliases
import java.util.spi.TimeZoneNameProvider; //导入依赖的package包/类
private static String examineAliases(TimeZoneNameProvider tznp, Locale locale,
String requestID, String tzid, int style,
Map<String, String> aliases) {
for (Map.Entry<String, String> entry : aliases.entrySet()) {
if (entry.getValue().equals(tzid)) {
String alias = entry.getKey();
String name = getName(tznp, locale, requestID, style, alias);
if (name != null) {
return name;
}
name = examineAliases(tznp, locale, requestID, alias, style, aliases);
if (name != null) {
return name;
}
}
}
return null;
}
示例6: getTimeZoneNameProvider
import java.util.spi.TimeZoneNameProvider; //导入依赖的package包/类
@Override
public TimeZoneNameProvider getTimeZoneNameProvider() {
if (timeZoneNameProvider == null) {
TimeZoneNameProvider provider = AccessController.doPrivileged(
(PrivilegedAction<TimeZoneNameProvider>) () ->
new TimeZoneNameProviderImpl(
getAdapterType(),
getLanguageTagSet("TimeZoneNames")));
synchronized (this) {
if (timeZoneNameProvider == null) {
timeZoneNameProvider = provider;
}
}
}
return timeZoneNameProvider;
}
示例7: retrieveDisplayNames
import java.util.spi.TimeZoneNameProvider; //导入依赖的package包/类
private static final String[] retrieveDisplayNames(OpenListResourceBundle rb,
String id, Locale locale) {
LocaleServiceProviderPool pool =
LocaleServiceProviderPool.getPool(TimeZoneNameProvider.class);
String[] names = null;
// Check whether a provider can provide an implementation that's closer
// to the requested locale than what the Java runtime itself can provide.
if (pool.hasProviders()) {
names = pool.getLocalizedObject(
TimeZoneNameGetter.INSTANCE,
locale, rb, id);
}
if (names == null) {
try {
names = rb.getStringArray(id);
} catch (MissingResourceException mre) {
// fall through
}
}
return names;
}
示例8: examineAliases
import java.util.spi.TimeZoneNameProvider; //导入依赖的package包/类
private static String[] examineAliases(TimeZoneNameProvider tznp, Locale locale,
String id,
Map<String, String> aliases,
Set<Map.Entry<String, String>> aliasesSet) {
if (aliases.containsValue(id)) {
for (Map.Entry<String, String> entry : aliasesSet) {
if (entry.getValue().equals(id)) {
String alias = entry.getKey();
String[] names = buildZoneStrings(tznp, locale, alias);
if (names != null) {
return names;
} else {
names = examineAliases(tznp, locale, alias, aliases, aliasesSet);
if (names != null) {
return names;
}
}
}
}
}
return null;
}
示例9: buildZoneStrings
import java.util.spi.TimeZoneNameProvider; //导入依赖的package包/类
private static String[] buildZoneStrings(TimeZoneNameProvider tznp,
Locale locale, String id) {
String[] names = new String[5];
for (int i = 1; i <= 4; i ++) {
names[i] = tznp.getDisplayName(id, i>=3, i%2, locale);
if (i >= 3 && names[i] == null) {
names[i] = names[i-2];
}
}
if (names[1] == null) {
// this id seems not localized by this provider
names = null;
}
return names;
}