ICU-10400 Updated the tool used for updating ICU's ISO 4217 currency numeric code map to support the new ISO 4217 file locations and format.

X-SVN-Rev: 34313
This commit is contained in:
Yoshito Umaoka 2013-09-13 18:45:24 +00:00
parent e46f248a50
commit bac694742e
2 changed files with 29 additions and 14 deletions

View File

@ -11,9 +11,9 @@
<property name="res.dir" value="${out.dir}/res"/>
<property name="xml.dir" value="${out.dir}/xml"/>
<property name="base.url" value="http://www.currency-iso.org/content/dam/isocy/downloads/"/>
<property name="current.xml" value="dl_iso_table_a1.xml"/>
<property name="historic.xml" value="dl_iso_table_a3.xml"/>
<property name="base.url" value="http://www.currency-iso.org/dam/downloads/"/>
<property name="current.xml" value="table_a1.xml"/>
<property name="historic.xml" value="table_a3.xml"/>
<target name="build" depends="check, resource" description="Verify ICU's local data and generate ISO 4217 alpha-numeric code mapping data resource"/>

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2012, International Business Machines Corporation and *
* Copyright (C) 2012-2013, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -47,14 +47,29 @@ public class CurrencyDataParser {
private static class Handler extends DefaultHandler {
private enum ElementType {
ENTITY,
CURRENCY,
ALPHABETIC_CODE,
NUMERIC_CODE,
MINOR_UNIT,
WITHDRAWAL_DATE,
REMARK,
OTHER
ENTITY("CtryNm"),
CURRENCY("CcyNm"),
ALPHABETIC_CODE("Ccy"),
NUMERIC_CODE("CcyNbr"),
MINOR_UNIT("CcyMnrUnts"),
WITHDRAWAL_DATE("WthdrwlDt"),
REMARK("Remark"), // obsolete
OTHER("Other"); // place holder
private String elemName;
ElementType(String elemName) {
this.elemName = elemName;
}
public static ElementType forName(String name) {
for (ElementType type : values()) {
if (type.elemName.equals(name)) {
return type;
}
}
return OTHER;
}
};
Collection<CurrencyDataEntry> isoCurrencies = new LinkedList<CurrencyDataEntry>();
@ -66,7 +81,7 @@ public class CurrencyDataParser {
public Handler(boolean historic) {
this.historic = historic;
currElemName = historic ? "ISO_CURRENCY_HISTORIC" : "ISO_CURRENCY";
currElemName = historic ? "HstrcCcyNtry" : "CcyNtry";
}
public Collection<CurrencyDataEntry> getParsedISOCurrencies() {
@ -79,7 +94,7 @@ public class CurrencyDataParser {
elem = ElementType.OTHER;
} else {
try {
elem = ElementType.valueOf(qName);
elem = ElementType.forName(qName);
} catch (IllegalArgumentException e) {
elem = ElementType.OTHER;
}