ICU-6444 Fixed a metazone golden zone mapping problem caused by its cache logic. To fix this problem, I updated the data structure of mapTimezones. This change was done in CLDR svn revision 4748 and ICU4C r27683. Regenerate ICU4J data using ICU4C r27683 and fixed the caching problem described above.

X-SVN-Rev: 27684
This commit is contained in:
Yoshito Umaoka 2010-02-25 22:11:15 +00:00
parent 7852edbfef
commit 4eca0bba1a
3 changed files with 29 additions and 30 deletions
icu4j/main
classes/core/src/com/ibm/icu/impl
shared/data

View file

@ -12,9 +12,12 @@ package com.ibm.icu.impl;
import java.text.ParsePosition;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.Set;
import com.ibm.icu.text.MessageFormat;
import com.ibm.icu.text.NumberFormat;
@ -887,44 +890,40 @@ public final class ZoneMeta {
return date;
}
private static ICUCache<String, String> META_TO_OLSON_CACHE =
new SimpleCache<String, String>();
private static ICUCache<String, Map<String, String>> META_TO_OLSON_CACHE =
new SimpleCache<String, Map<String, String>>();
/**
* Returns an Olson ID for the ginve metazone and region
*/
public static String getZoneIdByMetazone(String metazoneID, String region) {
String tzid = null;
String keyWithRegion = (region == null || region.length() == 0) ? null : metazoneID + ":" + region;
// look up in the cache first
if (keyWithRegion != null) {
tzid = META_TO_OLSON_CACHE.get(metazoneID + ":" + region);
}
if (tzid == null) {
tzid = META_TO_OLSON_CACHE.get(metazoneID);
}
// look up in the resource bundle
if (tzid == null) {
Map<String, String> zoneMap = META_TO_OLSON_CACHE.get(metazoneID);
if (zoneMap == null) {
try {
// Create zone mappings for the metazone
UResourceBundle bundle = UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, "metaZones");
UResourceBundle mapTimezones = bundle.get("mapTimezones");
UResourceBundle territoryMap = mapTimezones.get(metazoneID);
zoneMap = new HashMap<String, String>();
Set<String> territories = territoryMap.keySet();
for (String territory : territories) {
String zone = territoryMap.getString(territory);
zoneMap.put(territory, zone);
}
// cache this
META_TO_OLSON_CACHE.put(metazoneID, zoneMap);
} catch (MissingResourceException e) {
// ignore
}
}
if (keyWithRegion != null) {
try {
tzid = mapTimezones.getString(keyWithRegion);
META_TO_OLSON_CACHE.put(keyWithRegion, tzid);
} catch (MissingResourceException e) {
// fall through
}
}
if (tzid == null) {
tzid = mapTimezones.getString(metazoneID);
META_TO_OLSON_CACHE.put(metazoneID, tzid);
}
} catch (MissingResourceException mre) {
// do nothing
if (zoneMap != null) {
tzid = zoneMap.get(region);
if (tzid == null) {
tzid = zoneMap.get("001"); // use the mapping for world as fallback
}
}

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c91928adc02dbc1c42de92376b32ca1828ea1cebe96ceb055b9f42936d46e799
size 7005679
oid sha256:fbb4f47e1846a07e115a7847d85ee8ccf44469af34ecf1780d60aa5f8eacdf74
size 7006452

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:5fc863cb115c8fe4c2da78ea3539fd04f57ca8f871a48c23ed3b50c55ee0991c
size 720307
oid sha256:23766c7d13e3b01a78b9b0e54bbb7bf71a41bf9fe7cee13fda36ee9f8b34d70a
size 720308