ICU-6444 Merging C data changes for CLDR time zone reorg into ICU4J.

X-SVN-Rev: 27472
This commit is contained in:
Yoshito Umaoka 2010-02-02 04:56:48 +00:00
parent 547580cd15
commit 7c8ac7848d
3 changed files with 48 additions and 48 deletions

View File

@ -865,19 +865,19 @@ public final class ZoneMeta {
} }
/* /*
* Create olson tzid to metazone mappings from metazoneInfo.res (3.8.1 or later) * Create olson tzid to metazone mappings from metaZones.res
*/ */
private static Map<String, List<OlsonToMetaMappingEntry>> createOlsonToMetaMap() { private static Map<String, List<OlsonToMetaMappingEntry>> createOlsonToMetaMap() {
// Create olson id to metazone mapping table // Create olson id to metazone mapping table
Map<String, List<OlsonToMetaMappingEntry>> olsonToMeta = null; Map<String, List<OlsonToMetaMappingEntry>> olsonToMeta = null;
UResourceBundle metazoneMappingsBundle = null; UResourceBundle metazoneInfoBundle = null;
try { try {
UResourceBundle bundle = UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, "metazoneInfo"); UResourceBundle bundle = UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, "metaZones");
metazoneMappingsBundle = bundle.get("metazoneMappings"); metazoneInfoBundle = bundle.get("metazoneInfo");
} catch (MissingResourceException mre) { } catch (MissingResourceException mre) {
// do nothing // do nothing
} }
if (metazoneMappingsBundle != null) { if (metazoneInfoBundle != null) {
String[] tzids = getAvailableIDs(); String[] tzids = getAvailableIDs();
for (int i = 0; i < tzids.length; i++) { for (int i = 0; i < tzids.length; i++) {
// Skip aliases // Skip aliases
@ -887,28 +887,28 @@ public final class ZoneMeta {
} }
String tzkey = tzids[i].replace('/', ':'); String tzkey = tzids[i].replace('/', ':');
try { try {
UResourceBundle zoneBundle = metazoneMappingsBundle.get(tzkey); UResourceBundle zoneBundle = metazoneInfoBundle.get(tzkey);
LinkedList<OlsonToMetaMappingEntry> mzMappings = new LinkedList<OlsonToMetaMappingEntry>(); LinkedList<OlsonToMetaMappingEntry> mzMappings = new LinkedList<OlsonToMetaMappingEntry>();
for (int idx = 0; ; idx++) { for (int idx = 0; idx < zoneBundle.getSize(); idx++) {
UResourceBundle mz = zoneBundle.get(idx);
String mzid = mz.getString(0);
String from = "1970-01-01 00:00";
String to = "9999-12-31 23:59";
if (mz.getSize() == 3) {
from = mz.getString(1);
to = mz.getString(2);
}
OlsonToMetaMappingEntry mzmap = new OlsonToMetaMappingEntry();
mzmap.mzid = mzid.intern();
try { try {
UResourceBundle mz = zoneBundle.get("mz" + idx); mzmap.from = parseDate(from);
String[] mzstr = mz.getStringArray(); mzmap.to = parseDate(to);
if (mzstr == null || mzstr.length != 3) {
continue;
}
OlsonToMetaMappingEntry mzmap = new OlsonToMetaMappingEntry();
mzmap.mzid = mzstr[0].intern();
mzmap.from = parseDate(mzstr[1]);
mzmap.to = parseDate(mzstr[2]);
// Add this mapping to the list
mzMappings.add(mzmap);
} catch (MissingResourceException nomz) {
// we're done
break;
} catch (IllegalArgumentException baddate) { } catch (IllegalArgumentException baddate) {
// skip this // skip this
continue;
} }
// Add this mapping to the list
mzMappings.add(mzmap);
} }
if (mzMappings.size() != 0) { if (mzMappings.size() != 0) {
// Add to the olson-to-meta map // Add to the olson-to-meta map
@ -959,43 +959,43 @@ public final class ZoneMeta {
} }
if (metaToOlson == null) { if (metaToOlson == null) {
metaToOlson = new HashMap<String, List<MetaToOlsonMappingEntry>>(); metaToOlson = new HashMap<String, List<MetaToOlsonMappingEntry>>();
UResourceBundle metazonesBundle = null; UResourceBundle mapTimezonesBundle = null;
try { try {
UResourceBundle supplementalBundle = UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, UResourceBundle supplementalBundle = UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME,
"metazoneInfo"); "metaZones");
UResourceBundle mapTimezonesBundle = supplementalBundle.get("mapTimezones"); mapTimezonesBundle = supplementalBundle.get("mapTimezones");
metazonesBundle = mapTimezonesBundle.get("metazones");
} catch (MissingResourceException mre) { } catch (MissingResourceException mre) {
// do nothing // do nothing
} }
if (metazonesBundle != null) { if (mapTimezonesBundle != null) {
Enumeration<String> mzenum = metazonesBundle.getKeys(); Enumeration<String> mzenum = mapTimezonesBundle.getKeys();
while (mzenum.hasMoreElements()) { while (mzenum.hasMoreElements()) {
String mzkey = mzenum.nextElement(); String mzkey = mzenum.nextElement();
if (!mzkey.startsWith("meta:")) {
continue;
}
String tzid = null; String tzid = null;
try { try {
tzid = metazonesBundle.getString(mzkey); tzid = mapTimezonesBundle.getString(mzkey);
} catch (MissingResourceException mre) { } catch (MissingResourceException mre) {
// It should not happen.. // It should not happen..
} }
if (tzid != null) { if (tzid != null) {
int territoryIdx = mzkey.lastIndexOf('_'); String mzid = mzkey;
String territory = "001"; // default to "001"
int territoryIdx = mzkey.lastIndexOf(':');
if (territoryIdx > 0) { if (territoryIdx > 0) {
String mzid = mzkey.substring(5 /* "meta:".length() */, territoryIdx); mzid = mzkey.substring(0, territoryIdx);
String territory = mzkey.substring(territoryIdx + 1); territory = mzkey.substring(territoryIdx + 1);
List<MetaToOlsonMappingEntry> mappings = metaToOlson.get(mzid);
if (mappings == null) {
mappings = new LinkedList<MetaToOlsonMappingEntry>();
metaToOlson.put(mzid, mappings);
}
MetaToOlsonMappingEntry olsonmap = new MetaToOlsonMappingEntry();
olsonmap.id = tzid;
olsonmap.territory = territory;
mappings.add(olsonmap);
} }
List<MetaToOlsonMappingEntry> mappings = metaToOlson.get(mzid);
if (mappings == null) {
mappings = new LinkedList<MetaToOlsonMappingEntry>();
metaToOlson.put(mzid, mappings);
}
MetaToOlsonMappingEntry olsonmap = new MetaToOlsonMappingEntry();
olsonmap.id = tzid;
olsonmap.territory = territory;
mappings.add(olsonmap);
} }
} }
} }

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:5672f8f68d999b54d3bddaecf6d7d50f7d15102d3858d04aef78bc08c76d9c31 oid sha256:b9cff44109b84b2c242dd191d08dd5a2f635c85a489c5ee21c04098182efc257
size 6864531 size 6860428

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:07c50edb652f0dd85c0e660cc790995939cbdb8bb8d46645b676ea989788ce14 oid sha256:fc135016749cbefe90c0df5259ff59b0ecbc40580ef3f46f67e77ffd271b13cf
size 720048 size 719423