@Test public void testIsoStandardCurrencies() { Map<String, String> c = new HashMap<String, String>(); Map<String, Integer> cD = new HashMap<String, Integer>(); c.put("971", "AFN"); cD.put("971", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("008", "ALL"); cD.put("008", 2); c.put("012", "DZD"); cD.put("012", 2); c.put("840", "USD"); cD.put("840", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("973", "AOA"); cD.put("973", 2); c.put("951", "XCD"); cD.put("951", 2); c.put("951", "XCD"); cD.put("951", 2); c.put("032", "ARS"); cD.put("032", 2); c.put("051", "AMD"); cD.put("051", 2); c.put("533", "AWG"); cD.put("533", 2); c.put("036", "AUD"); cD.put("036", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("944", "AZN"); cD.put("944", 2); c.put("044", "BSD"); cD.put("044", 2); c.put("048", "BHD"); cD.put("048", 3); c.put("050", "BDT"); cD.put("050", 2); c.put("052", "BBD"); cD.put("052", 2); c.put("933", "BYN"); cD.put("933", 2); c.put("974", "BYR"); cD.put("974", 0); c.put("978", "EUR"); cD.put("978", 2); c.put("084", "BZD"); cD.put("084", 2); c.put("952", "XOF"); cD.put("952", 0); c.put("060", "BMD"); cD.put("060", 2); c.put("356", "INR"); cD.put("356", 2); c.put("064", "BTN"); cD.put("064", 2); c.put("068", "BOB"); cD.put("068", 2); c.put("984", "BOV"); cD.put("984", 2); c.put("840", "USD"); cD.put("840", 2); c.put("977", "BAM"); cD.put("977", 2); c.put("072", "BWP"); cD.put("072", 2); c.put("578", "NOK"); cD.put("578", 2); c.put("986", "BRL"); cD.put("986", 2); c.put("840", "USD"); cD.put("840", 2); c.put("096", "BND"); cD.put("096", 2); c.put("975", "BGN"); cD.put("975", 2); c.put("952", "XOF"); cD.put("952", 0); c.put("108", "BIF"); cD.put("108", 0); c.put("132", "CVE"); cD.put("132", 2); c.put("116", "KHR"); cD.put("116", 2); c.put("950", "XAF"); cD.put("950", 0); c.put("124", "CAD"); cD.put("124", 2); c.put("136", "KYD"); cD.put("136", 2); c.put("950", "XAF"); cD.put("950", 0); c.put("950", "XAF"); cD.put("950", 0); c.put("152", "CLP"); cD.put("152", 0); c.put("990", "CLF"); cD.put("990", 4); c.put("156", "CNY"); cD.put("156", 2); c.put("036", "AUD"); cD.put("036", 2); c.put("036", "AUD"); cD.put("036", 2); c.put("170", "COP"); cD.put("170", 2); c.put("970", "COU"); cD.put("970", 2); c.put("174", "KMF"); cD.put("174", 0); c.put("976", "CDF"); cD.put("976", 2); c.put("950", "XAF"); cD.put("950", 0); c.put("554", "NZD"); cD.put("554", 2); c.put("188", "CRC"); cD.put("188", 2); c.put("952", "XOF"); cD.put("952", 0); c.put("191", "HRK"); cD.put("191", 2); c.put("192", "CUP"); cD.put("192", 2); c.put("931", "CUC"); cD.put("931", 2); c.put("532", "ANG"); cD.put("532", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("203", "CZK"); cD.put("203", 2); c.put("208", "DKK"); cD.put("208", 2); c.put("262", "DJF"); cD.put("262", 0); c.put("951", "XCD"); cD.put("951", 2); c.put("214", "DOP"); cD.put("214", 2); c.put("840", "USD"); cD.put("840", 2); c.put("818", "EGP"); cD.put("818", 2); c.put("222", "SVC"); cD.put("222", 2); c.put("840", "USD"); cD.put("840", 2); c.put("950", "XAF"); cD.put("950", 0); c.put("232", "ERN"); cD.put("232", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("230", "ETB"); cD.put("230", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("238", "FKP"); cD.put("238", 2); c.put("208", "DKK"); cD.put("208", 2); c.put("242", "FJD"); cD.put("242", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("953", "XPF"); cD.put("953", 0); c.put("978", "EUR"); cD.put("978", 2); c.put("950", "XAF"); cD.put("950", 0); c.put("270", "GMD"); cD.put("270", 2); c.put("981", "GEL"); cD.put("981", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("936", "GHS"); cD.put("936", 2); c.put("292", "GIP"); cD.put("292", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("208", "DKK"); cD.put("208", 2); c.put("951", "XCD"); cD.put("951", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("840", "USD"); cD.put("840", 2); c.put("320", "GTQ"); cD.put("320", 2); c.put("826", "GBP"); cD.put("826", 2); c.put("324", "GNF"); cD.put("324", 0); c.put("952", "XOF"); cD.put("952", 0); c.put("328", "GYD"); cD.put("328", 2); c.put("332", "HTG"); cD.put("332", 2); c.put("840", "USD"); cD.put("840", 2); c.put("036", "AUD"); cD.put("036", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("340", "HNL"); cD.put("340", 2); c.put("344", "HKD"); cD.put("344", 2); c.put("348", "HUF"); cD.put("348", 2); c.put("352", "ISK"); cD.put("352", 0); c.put("356", "INR"); cD.put("356", 2); c.put("360", "IDR"); cD.put("360", 2); c.put("364", "IRR"); cD.put("364", 2); c.put("368", "IQD"); cD.put("368", 3); c.put("978", "EUR"); cD.put("978", 2); c.put("826", "GBP"); cD.put("826", 2); c.put("376", "ILS"); cD.put("376", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("388", "JMD"); cD.put("388", 2); c.put("392", "JPY"); cD.put("392", 0); c.put("826", "GBP"); cD.put("826", 2); c.put("400", "JOD"); cD.put("400", 3); c.put("398", "KZT"); cD.put("398", 2); c.put("404", "KES"); cD.put("404", 2); c.put("036", "AUD"); cD.put("036", 2); c.put("408", "KPW"); cD.put("408", 2); c.put("410", "KRW"); cD.put("410", 0); c.put("414", "KWD"); cD.put("414", 3); c.put("417", "KGS"); cD.put("417", 2); c.put("418", "LAK"); cD.put("418", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("422", "LBP"); cD.put("422", 2); c.put("426", "LSL"); cD.put("426", 2); c.put("710", "ZAR"); cD.put("710", 2); c.put("430", "LRD"); cD.put("430", 2); c.put("434", "LYD"); cD.put("434", 3); c.put("756", "CHF"); cD.put("756", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("446", "MOP"); cD.put("446", 2); c.put("807", "MKD"); cD.put("807", 2); c.put("969", "MGA"); cD.put("969", 2); c.put("454", "MWK"); cD.put("454", 2); c.put("458", "MYR"); cD.put("458", 2); c.put("462", "MVR"); cD.put("462", 2); c.put("952", "XOF"); cD.put("952", 0); c.put("978", "EUR"); cD.put("978", 2); c.put("840", "USD"); cD.put("840", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("478", "MRO"); cD.put("478", 2); c.put("480", "MUR"); cD.put("480", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("484", "MXN"); cD.put("484", 2); c.put("979", "MXV"); cD.put("979", 2); c.put("840", "USD"); cD.put("840", 2); c.put("498", "MDL"); cD.put("498", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("496", "MNT"); cD.put("496", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("951", "XCD"); cD.put("951", 2); c.put("504", "MAD"); cD.put("504", 2); c.put("943", "MZN"); cD.put("943", 2); c.put("104", "MMK"); cD.put("104", 2); c.put("516", "NAD"); cD.put("516", 2); c.put("710", "ZAR"); cD.put("710", 2); c.put("036", "AUD"); cD.put("036", 2); c.put("524", "NPR"); cD.put("524", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("953", "XPF"); cD.put("953", 0); c.put("554", "NZD"); cD.put("554", 2); c.put("558", "NIO"); cD.put("558", 2); c.put("952", "XOF"); cD.put("952", 0); c.put("566", "NGN"); cD.put("566", 2); c.put("554", "NZD"); cD.put("554", 2); c.put("036", "AUD"); cD.put("036", 2); c.put("840", "USD"); cD.put("840", 2); c.put("578", "NOK"); cD.put("578", 2); c.put("512", "OMR"); cD.put("512", 3); c.put("586", "PKR"); cD.put("586", 2); c.put("840", "USD"); cD.put("840", 2); c.put("590", "PAB"); cD.put("590", 2); c.put("840", "USD"); cD.put("840", 2); c.put("598", "PGK"); cD.put("598", 2); c.put("600", "PYG"); cD.put("600", 0); c.put("604", "PEN"); cD.put("604", 2); c.put("608", "PHP"); cD.put("608", 2); c.put("554", "NZD"); cD.put("554", 2); c.put("985", "PLN"); cD.put("985", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("840", "USD"); cD.put("840", 2); c.put("634", "QAR"); cD.put("634", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("946", "RON"); cD.put("946", 2); c.put("643", "RUB"); cD.put("643", 2); c.put("646", "RWF"); cD.put("646", 0); c.put("978", "EUR"); cD.put("978", 2); c.put("654", "SHP"); cD.put("654", 2); c.put("951", "XCD"); cD.put("951", 2); c.put("951", "XCD"); cD.put("951", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("951", "XCD"); cD.put("951", 2); c.put("882", "WST"); cD.put("882", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("678", "STD"); cD.put("678", 2); c.put("682", "SAR"); cD.put("682", 2); c.put("952", "XOF"); cD.put("952", 0); c.put("941", "RSD"); cD.put("941", 2); c.put("690", "SCR"); cD.put("690", 2); c.put("694", "SLL"); cD.put("694", 2); c.put("702", "SGD"); cD.put("702", 2); c.put("532", "ANG"); cD.put("532", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("090", "SBD"); cD.put("090", 2); c.put("706", "SOS"); cD.put("706", 2); c.put("710", "ZAR"); cD.put("710", 2); c.put("728", "SSP"); cD.put("728", 2); c.put("978", "EUR"); cD.put("978", 2); c.put("144", "LKR"); cD.put("144", 2); c.put("938", "SDG"); cD.put("938", 2); c.put("968", "SRD"); cD.put("968", 2); c.put("578", "NOK"); cD.put("578", 2); c.put("748", "SZL"); cD.put("748", 2); c.put("752", "SEK"); cD.put("752", 2); c.put("756", "CHF"); cD.put("756", 2); c.put("947", "CHE"); cD.put("947", 2); c.put("948", "CHW"); cD.put("948", 2); c.put("760", "SYP"); cD.put("760", 2); c.put("901", "TWD"); cD.put("901", 2); c.put("972", "TJS"); cD.put("972", 2); c.put("834", "TZS"); cD.put("834", 2); c.put("764", "THB"); cD.put("764", 2); c.put("840", "USD"); cD.put("840", 2); c.put("952", "XOF"); cD.put("952", 0); c.put("554", "NZD"); cD.put("554", 2); c.put("776", "TOP"); cD.put("776", 2); c.put("780", "TTD"); cD.put("780", 2); c.put("788", "TND"); cD.put("788", 3); c.put("949", "TRY"); cD.put("949", 2); c.put("934", "TMT"); cD.put("934", 2); c.put("840", "USD"); cD.put("840", 2); c.put("036", "AUD"); cD.put("036", 2); c.put("800", "UGX"); cD.put("800", 0); c.put("980", "UAH"); cD.put("980", 2); c.put("784", "AED"); cD.put("784", 2); c.put("826", "GBP"); cD.put("826", 2); c.put("840", "USD"); cD.put("840", 2); c.put("840", "USD"); cD.put("840", 2); c.put("997", "USN"); cD.put("997", 2); c.put("858", "UYU"); cD.put("858", 2); c.put("940", "UYI"); cD.put("940", 0); c.put("860", "UZS"); cD.put("860", 2); c.put("548", "VUV"); cD.put("548", 0); c.put("937", "VEF"); cD.put("937", 2); c.put("704", "VND"); cD.put("704", 0); c.put("840", "USD"); cD.put("840", 2); c.put("840", "USD"); cD.put("840", 2); c.put("953", "XPF"); cD.put("953", 0); c.put("504", "MAD"); cD.put("504", 2); c.put("886", "YER"); cD.put("886", 2); c.put("967", "ZMW"); cD.put("967", 2); c.put("932", "ZWL"); cD.put("932", 2); StringBuilder msg = new StringBuilder(); for (String code: c.keySet()) { try { Currency currencyByCode = ISOCurrency.getCurrency(code); assertEquals(cD.get(code).intValue(), currencyByCode.getDecimals(), "Decimal digits do not match for " + currencyByCode); assertEquals(c.get(code), currencyByCode.getAlphaCode(), "Name does not match for " + currencyByCode); } catch (Throwable ignored) { msg.append(c.get(code) + "=" + code + " " + cD.get(code) + " } } assertEquals(msg.length(), 0, msg.toString()); }
public static Currency getCurrency(int code) throws ISOException { final String isoCode = ISOUtil.zeropad(Integer.toString(code), 3); return findCurrency(isoCode); }
ISOCurrency { public static Currency getCurrency(int code) throws ISOException { final String isoCode = ISOUtil.zeropad(Integer.toString(code), 3); return findCurrency(isoCode); } }
ISOCurrency { public static Currency getCurrency(int code) throws ISOException { final String isoCode = ISOUtil.zeropad(Integer.toString(code), 3); return findCurrency(isoCode); } private  ISOCurrency(); }
ISOCurrency { public static Currency getCurrency(int code) throws ISOException { final String isoCode = ISOUtil.zeropad(Integer.toString(code), 3); return findCurrency(isoCode); } private  ISOCurrency(); @SuppressWarnings({"EmptyCatchBlock"}) static void loadPropertiesFromClasspath(String base); static double convertFromIsoMsg(String isoamount, String currency); static String toISO87String(BigDecimal amount, String currency); static BigDecimal parseFromISO87String(String isoamount, String currency); static void addBundle(String bundleName); static String convertToIsoMsg(double amount, String currency); static Object[] decomposeComposedCurrency(String incurr); static String getIsoCodeFromAlphaCode(String alphacode); static Currency getCurrency(int code); static Currency getCurrency(String code); }
ISOCurrency { public static Currency getCurrency(int code) throws ISOException { final String isoCode = ISOUtil.zeropad(Integer.toString(code), 3); return findCurrency(isoCode); } private  ISOCurrency(); @SuppressWarnings({"EmptyCatchBlock"}) static void loadPropertiesFromClasspath(String base); static double convertFromIsoMsg(String isoamount, String currency); static String toISO87String(BigDecimal amount, String currency); static BigDecimal parseFromISO87String(String isoamount, String currency); static void addBundle(String bundleName); static String convertToIsoMsg(double amount, String currency); static Object[] decomposeComposedCurrency(String incurr); static String getIsoCodeFromAlphaCode(String alphacode); static Currency getCurrency(int code); static Currency getCurrency(String code);  }