< prev index next >
src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java
Print this page
rev 49854 : 8181157: CLDR Timezone name fallback implementation
Reviewed-by: sherman
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -43,10 +43,11 @@
import java.util.ServiceConfigurationError;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.concurrent.ConcurrentHashMap;
import java.util.spi.CalendarDataProvider;
+import java.util.spi.TimeZoneNameProvider;
import sun.util.locale.provider.JRELocaleProviderAdapter;
import sun.util.locale.provider.LocaleDataMetaInfo;
import sun.util.locale.provider.LocaleProviderAdapter;
/**
@@ -129,10 +130,28 @@
public CollatorProvider getCollatorProvider() {
return null;
}
@Override
+ public TimeZoneNameProvider getTimeZoneNameProvider() {
+ if (timeZoneNameProvider == null) {
+ TimeZoneNameProvider provider = AccessController.doPrivileged(
+ (PrivilegedAction<TimeZoneNameProvider>) () ->
+ new CLDRTimeZoneNameProviderImpl(
+ getAdapterType(),
+ getLanguageTagSet("TimeZoneNames")));
+
+ synchronized (this) {
+ if (timeZoneNameProvider == null) {
+ timeZoneNameProvider = provider;
+ }
+ }
+ }
+ return timeZoneNameProvider;
+ }
+
+ @Override
public Locale[] getAvailableLocales() {
Set<String> all = createLanguageTagSet("AvailableLocales");
Locale[] locs = new Locale[all.size()];
int index = 0;
for (String tag : all) {
@@ -244,11 +263,11 @@
|| langtags.contains(locale.stripExtensions().toLanguageTag())
|| langtags.contains(getEquivalentLoc(locale).toLanguageTag());
}
/**
- * Returns the time zone ID from an LDML's short ID
+ * Returns the canonical ID for the given ID
*/
- public Optional<String> getTimeZoneID(String shortID) {
- return Optional.ofNullable(baseMetaInfo.tzShortIDs().get(shortID));
+ public Optional<String> canonicalTZID(String id) {
+ return Optional.ofNullable(baseMetaInfo.tzCanonicalIDs().get(id));
}
}
< prev index next >