8074350: Support ISO 4217 "Current funds codes" table (A.2)
8074351: Support for currencies with the 4 digits (or more) minor unit Reviewed-by: okutsu
This commit is contained in:
parent
f15d56a3a6
commit
ca08065c34
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2000, 2015, 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
|
||||
@ -23,7 +23,10 @@
|
||||
# questions.
|
||||
#
|
||||
|
||||
formatVersion=1
|
||||
# Version of the currency data format.
|
||||
# 1: initial
|
||||
# 2: Change in minor unit (allowing 4-9 digits)
|
||||
formatVersion=2
|
||||
|
||||
# Version of the currency code information in this class.
|
||||
# It is a serial number that accompanies with each amendment.
|
||||
@ -36,7 +39,7 @@ dataVersion=159
|
||||
all=ADP020-AED784-AFA004-AFN971-ALL008-AMD051-ANG532-AOA973-ARS032-ATS040-AUD036-\
|
||||
AWG533-AYM945-AZM031-AZN944-BAM977-BBD052-BDT050-BEF056-BGL100-BGN975-BHD048-BIF108-\
|
||||
BMD060-BND096-BOB068-BOV984-BRL986-BSD044-BTN064-BWP072-BYB112-BYR974-\
|
||||
BZD084-CAD124-CDF976-CHF756-CLF990-CLP152-CNY156-COP170-CRC188-CSD891-CUP192-CUC931-\
|
||||
BZD084-CAD124-CDF976-CHE947-CHF756-CHW948-CLF990-CLP152-CNY156-COP170-COU970-CRC188-CSD891-CUP192-CUC931-\
|
||||
CVE132-CYP196-CZK203-DEM276-DJF262-DKK208-DOP214-DZD012-EEK233-EGP818-\
|
||||
ERN232-ESP724-ETB230-EUR978-FIM246-FJD242-FKP238-FRF250-GBP826-GEL981-\
|
||||
GHC288-GHS936-GIP292-GMD270-GNF324-GRD300-GTQ320-GWP624-GYD328-HKD344-HNL340-\
|
||||
@ -49,7 +52,7 @@ all=ADP020-AED784-AFA004-AFN971-ALL008-AMD051-ANG532-AOA973-ARS032-ATS040-AUD036
|
||||
PKR586-PLN985-PTE620-PYG600-QAR634-ROL946-RON946-RSD941-RUB643-RUR810-RWF646-SAR682-\
|
||||
SBD090-SCR690-SDD736-SDG938-SEK752-SGD702-SHP654-SIT705-SKK703-SLL694-SOS706-\
|
||||
SRD968-SRG740-SSP728-STD678-SVC222-SYP760-SZL748-THB764-TJS972-TMM795-TMT934-TND788-TOP776-\
|
||||
TPE626-TRL792-TRY949-TTD780-TWD901-TZS834-UAH980-UGX800-USD840-USN997-USS998-\
|
||||
TPE626-TRL792-TRY949-TTD780-TWD901-TZS834-UAH980-UGX800-USD840-USN997-USS998-UYI940-\
|
||||
UYU858-UZS860-VEB862-VEF937-VND704-VUV548-WST882-XAF950-XAG961-XAU959-XBA955-\
|
||||
XBB956-XBC957-XBD958-XCD951-XDR960-XFO000-XFU000-XOF952-XPD964-XPF953-\
|
||||
XPT962-XSU994-XTS963-XUA965-XXX999-YER886-YUM891-ZAR710-ZMK894-ZMW967-ZWD716-ZWL932-\
|
||||
@ -579,16 +582,17 @@ ZM=ZMW
|
||||
ZW=ZWL
|
||||
|
||||
|
||||
# List of currencies with 0, 1, OR 3 decimals for minor units, or where there
|
||||
# are no minor units defined. All others use 2 decimals.
|
||||
# List of currencies with non-2digit decimals for minor units,
|
||||
# or where there are no minor units defined. All others use 2 decimals.
|
||||
|
||||
minor0=\
|
||||
ADP-BEF-BIF-BYB-BYR-CLF-CLP-DJF-ESP-GNF-\
|
||||
ADP-BEF-BIF-BYB-BYR-CLP-DJF-ESP-GNF-\
|
||||
GRD-ISK-ITL-JPY-KMF-KRW-LUF-MGF-PYG-PTE-RWF-\
|
||||
TPE-TRL-UGX-VND-VUV-XAF-XOF-XPF
|
||||
minor1=
|
||||
TPE-TRL-UGX-UYI-VND-VUV-XAF-XOF-XPF
|
||||
minor3=\
|
||||
BHD-IQD-JOD-KWD-LYD-OMR-TND
|
||||
minor4=\
|
||||
CLF
|
||||
minorUndefined=\
|
||||
XAG-XAU-XBA-XBB-XBC-XBD-XDR-XFO-XFU-XPD-\
|
||||
XPT-XSU-XTS-XUA-XXX
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2015, 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
|
||||
@ -33,6 +33,7 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Properties;
|
||||
import java.util.TimeZone;
|
||||
|
||||
@ -72,10 +73,6 @@ public class GenerateCurrencyData {
|
||||
private static String formatVersion;
|
||||
private static String dataVersion;
|
||||
private static String validCurrencyCodes;
|
||||
private static String currenciesWith0MinorUnitDecimals;
|
||||
private static String currenciesWith1MinorUnitDecimal;
|
||||
private static String currenciesWith3MinorUnitDecimal;
|
||||
private static String currenciesWithMinorUnitsUndefined;
|
||||
|
||||
// handy constants - must match definitions in java.util.Currency
|
||||
// magic number
|
||||
@ -83,29 +80,31 @@ public class GenerateCurrencyData {
|
||||
// number of characters from A to Z
|
||||
private static final int A_TO_Z = ('Z' - 'A') + 1;
|
||||
// entry for invalid country codes
|
||||
private static final int INVALID_COUNTRY_ENTRY = 0x007F;
|
||||
private static final int INVALID_COUNTRY_ENTRY = 0x0000007F;
|
||||
// entry for countries without currency
|
||||
private static final int COUNTRY_WITHOUT_CURRENCY_ENTRY = 0x0080;
|
||||
private static final int COUNTRY_WITHOUT_CURRENCY_ENTRY = 0x00000200;
|
||||
// mask for simple case country entries
|
||||
private static final int SIMPLE_CASE_COUNTRY_MASK = 0x0000;
|
||||
private static final int SIMPLE_CASE_COUNTRY_MASK = 0x00000000;
|
||||
// mask for simple case country entry final character
|
||||
private static final int SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK = 0x001F;
|
||||
private static final int SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK = 0x0000001F;
|
||||
// mask for simple case country entry default currency digits
|
||||
private static final int SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK = 0x0060;
|
||||
private static final int SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK = 0x000001E0;
|
||||
// shift count for simple case country entry default currency digits
|
||||
private static final int SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT = 5;
|
||||
// maximum number for simple case country entry default currency digits
|
||||
private static final int SIMPLE_CASE_COUNTRY_MAX_DEFAULT_DIGITS = 9;
|
||||
// mask for special case country entries
|
||||
private static final int SPECIAL_CASE_COUNTRY_MASK = 0x0080;
|
||||
private static final int SPECIAL_CASE_COUNTRY_MASK = 0x00000200;
|
||||
// mask for special case country index
|
||||
private static final int SPECIAL_CASE_COUNTRY_INDEX_MASK = 0x001F;
|
||||
private static final int SPECIAL_CASE_COUNTRY_INDEX_MASK = 0x0000001F;
|
||||
// delta from entry index component in main table to index into special case tables
|
||||
private static final int SPECIAL_CASE_COUNTRY_INDEX_DELTA = 1;
|
||||
// mask for distinguishing simple and special case countries
|
||||
private static final int COUNTRY_TYPE_MASK = SIMPLE_CASE_COUNTRY_MASK | SPECIAL_CASE_COUNTRY_MASK;
|
||||
// mask for the numeric code of the currency
|
||||
private static final int NUMERIC_CODE_MASK = 0x0003FF00;
|
||||
private static final int NUMERIC_CODE_MASK = 0x000FFC00;
|
||||
// shift count for the numeric code of the currency
|
||||
private static final int NUMERIC_CODE_SHIFT = 8;
|
||||
private static final int NUMERIC_CODE_SHIFT = 10;
|
||||
|
||||
// generated data
|
||||
private static int[] mainTable = new int[A_TO_Z * A_TO_Z];
|
||||
@ -120,7 +119,7 @@ public class GenerateCurrencyData {
|
||||
private static int[] specialCaseOldCurrenciesNumericCode = new int[maxSpecialCases];
|
||||
private static int[] specialCaseNewCurrenciesNumericCode = new int[maxSpecialCases];
|
||||
|
||||
private static final int maxOtherCurrencies = 70;
|
||||
private static final int maxOtherCurrencies = 128;
|
||||
private static int otherCurrenciesCount = 0;
|
||||
private static StringBuffer otherCurrencies = new StringBuffer();
|
||||
private static int[] otherCurrenciesDefaultFractionDigits = new int[maxOtherCurrencies];
|
||||
@ -129,6 +128,11 @@ public class GenerateCurrencyData {
|
||||
// date format for parsing cut-over times
|
||||
private static SimpleDateFormat format;
|
||||
|
||||
// Minor Units
|
||||
private static String[] currenciesWithDefinedMinorUnitDecimals =
|
||||
new String[SIMPLE_CASE_COUNTRY_MAX_DEFAULT_DIGITS + 1];
|
||||
private static String currenciesWithMinorUnitsUndefined;
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
// Look for "-o outputfilename" option
|
||||
@ -171,16 +175,14 @@ public class GenerateCurrencyData {
|
||||
formatVersion = (String) currencyData.get("formatVersion");
|
||||
dataVersion = (String) currencyData.get("dataVersion");
|
||||
validCurrencyCodes = (String) currencyData.get("all");
|
||||
currenciesWith0MinorUnitDecimals = (String) currencyData.get("minor0");
|
||||
currenciesWith1MinorUnitDecimal = (String) currencyData.get("minor1");
|
||||
currenciesWith3MinorUnitDecimal = (String) currencyData.get("minor3");
|
||||
for (int i = 0; i <= SIMPLE_CASE_COUNTRY_MAX_DEFAULT_DIGITS; i++) {
|
||||
currenciesWithDefinedMinorUnitDecimals[i]
|
||||
= (String) currencyData.get("minor"+i);
|
||||
}
|
||||
currenciesWithMinorUnitsUndefined = (String) currencyData.get("minorUndefined");
|
||||
if (formatVersion == null ||
|
||||
dataVersion == null ||
|
||||
validCurrencyCodes == null ||
|
||||
currenciesWith0MinorUnitDecimals == null ||
|
||||
currenciesWith1MinorUnitDecimal == null ||
|
||||
currenciesWith3MinorUnitDecimal == null ||
|
||||
currenciesWithMinorUnitsUndefined == null) {
|
||||
throw new NullPointerException("not all required data is defined in input");
|
||||
}
|
||||
@ -207,7 +209,7 @@ public class GenerateCurrencyData {
|
||||
if (currencyInfo.charAt(0) == firstChar && currencyInfo.charAt(1) == secondChar) {
|
||||
checkCurrencyCode(currencyInfo);
|
||||
int digits = getDefaultFractionDigits(currencyInfo);
|
||||
if (digits < 0 || digits > 3) {
|
||||
if (digits < 0 || digits > SIMPLE_CASE_COUNTRY_MAX_DEFAULT_DIGITS) {
|
||||
throw new RuntimeException("fraction digits out of range for " + currencyInfo);
|
||||
}
|
||||
int numericCode= getNumericCode(currencyInfo);
|
||||
@ -231,13 +233,14 @@ public class GenerateCurrencyData {
|
||||
}
|
||||
|
||||
private static int getDefaultFractionDigits(String currencyCode) {
|
||||
if (currenciesWith0MinorUnitDecimals.indexOf(currencyCode) != -1) {
|
||||
return 0;
|
||||
} else if (currenciesWith1MinorUnitDecimal.indexOf(currencyCode) != -1) {
|
||||
return 1;
|
||||
} else if (currenciesWith3MinorUnitDecimal.indexOf(currencyCode) != -1) {
|
||||
return 3;
|
||||
} else if (currenciesWithMinorUnitsUndefined.indexOf(currencyCode) != -1) {
|
||||
for (int i = 0; i <= SIMPLE_CASE_COUNTRY_MAX_DEFAULT_DIGITS; i++) {
|
||||
if (Objects.nonNull(currenciesWithDefinedMinorUnitDecimals[i]) &&
|
||||
currenciesWithDefinedMinorUnitDecimals[i].indexOf(currencyCode) != -1) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
if (currenciesWithMinorUnitsUndefined.indexOf(currencyCode) != -1) {
|
||||
return -1;
|
||||
} else {
|
||||
return 2;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2015, 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
|
||||
@ -140,11 +140,11 @@ public final class Currency implements Serializable {
|
||||
// - maps country code to 32-bit int
|
||||
// - 26*26 entries, corresponding to [A-Z]*[A-Z]
|
||||
// - \u007F -> not valid country
|
||||
// - bits 18-31: unused
|
||||
// - bits 8-17: numeric code (0 to 1023)
|
||||
// - bit 7: 1 - special case, bits 0-4 indicate which one
|
||||
// - bits 20-31: unused
|
||||
// - bits 10-19: numeric code (0 to 1023)
|
||||
// - bit 9: 1 - special case, bits 0-4 indicate which one
|
||||
// 0 - simple country, bits 0-4 indicate final char of currency code
|
||||
// - bits 5-6: fraction digits for simple countries, 0 for special cases
|
||||
// - bits 5-8: fraction digits for simple countries, 0 for special cases
|
||||
// - bits 0-4: final char for currency code for simple country, or ID of special case
|
||||
// - special case IDs:
|
||||
// - 0: country has no currency
|
||||
@ -182,32 +182,34 @@ public final class Currency implements Serializable {
|
||||
// number of characters from A to Z
|
||||
private static final int A_TO_Z = ('Z' - 'A') + 1;
|
||||
// entry for invalid country codes
|
||||
private static final int INVALID_COUNTRY_ENTRY = 0x007F;
|
||||
private static final int INVALID_COUNTRY_ENTRY = 0x0000007F;
|
||||
// entry for countries without currency
|
||||
private static final int COUNTRY_WITHOUT_CURRENCY_ENTRY = 0x0080;
|
||||
private static final int COUNTRY_WITHOUT_CURRENCY_ENTRY = 0x00000200;
|
||||
// mask for simple case country entries
|
||||
private static final int SIMPLE_CASE_COUNTRY_MASK = 0x0000;
|
||||
private static final int SIMPLE_CASE_COUNTRY_MASK = 0x00000000;
|
||||
// mask for simple case country entry final character
|
||||
private static final int SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK = 0x001F;
|
||||
private static final int SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK = 0x0000001F;
|
||||
// mask for simple case country entry default currency digits
|
||||
private static final int SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK = 0x0060;
|
||||
private static final int SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK = 0x000001E0;
|
||||
// shift count for simple case country entry default currency digits
|
||||
private static final int SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT = 5;
|
||||
// maximum number for simple case country entry default currency digits
|
||||
private static final int SIMPLE_CASE_COUNTRY_MAX_DEFAULT_DIGITS = 9;
|
||||
// mask for special case country entries
|
||||
private static final int SPECIAL_CASE_COUNTRY_MASK = 0x0080;
|
||||
private static final int SPECIAL_CASE_COUNTRY_MASK = 0x00000200;
|
||||
// mask for special case country index
|
||||
private static final int SPECIAL_CASE_COUNTRY_INDEX_MASK = 0x001F;
|
||||
private static final int SPECIAL_CASE_COUNTRY_INDEX_MASK = 0x0000001F;
|
||||
// delta from entry index component in main table to index into special case tables
|
||||
private static final int SPECIAL_CASE_COUNTRY_INDEX_DELTA = 1;
|
||||
// mask for distinguishing simple and special case countries
|
||||
private static final int COUNTRY_TYPE_MASK = SIMPLE_CASE_COUNTRY_MASK | SPECIAL_CASE_COUNTRY_MASK;
|
||||
// mask for the numeric code of the currency
|
||||
private static final int NUMERIC_CODE_MASK = 0x0003FF00;
|
||||
private static final int NUMERIC_CODE_MASK = 0x000FFC00;
|
||||
// shift count for the numeric code of the currency
|
||||
private static final int NUMERIC_CODE_SHIFT = 8;
|
||||
private static final int NUMERIC_CODE_SHIFT = 10;
|
||||
|
||||
// Currency data format version
|
||||
private static final int VALID_FORMAT_VERSION = 1;
|
||||
private static final int VALID_FORMAT_VERSION = 2;
|
||||
|
||||
static {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
@ -261,7 +263,7 @@ public final class Currency implements Serializable {
|
||||
Set<String> keys = props.stringPropertyNames();
|
||||
Pattern propertiesPattern =
|
||||
Pattern.compile("([A-Z]{3})\\s*,\\s*(\\d{3})\\s*,\\s*" +
|
||||
"([0-3])\\s*,?\\s*(\\d{4}-\\d{2}-\\d{2}T\\d{2}:" +
|
||||
"(\\d+)\\s*,?\\s*(\\d{4}-\\d{2}-\\d{2}T\\d{2}:" +
|
||||
"\\d{2}:\\d{2})?");
|
||||
for (String key : keys) {
|
||||
replaceCurrencyData(propertiesPattern,
|
||||
@ -682,7 +684,7 @@ public final class Currency implements Serializable {
|
||||
* @param ctry country code
|
||||
* @param curdata currency data. This is a comma separated string that
|
||||
* consists of "three-letter alphabet code", "three-digit numeric code",
|
||||
* and "one-digit (0,1,2, or 3) default fraction digit".
|
||||
* and "one-digit (0-9) default fraction digit".
|
||||
* For example, "JPZ,392,0".
|
||||
* An optional UTC date can be appended to the string (comma separated)
|
||||
* to allow a currency change take effect after date specified.
|
||||
@ -721,8 +723,14 @@ public final class Currency implements Serializable {
|
||||
|
||||
String code = m.group(1);
|
||||
int numeric = Integer.parseInt(m.group(2));
|
||||
int fraction = Integer.parseInt(m.group(3));
|
||||
int entry = numeric << NUMERIC_CODE_SHIFT;
|
||||
int fraction = Integer.parseInt(m.group(3));
|
||||
if (fraction > SIMPLE_CASE_COUNTRY_MAX_DEFAULT_DIGITS) {
|
||||
info("currency.properties entry for " + ctry +
|
||||
" ignored since the fraction is more than " +
|
||||
SIMPLE_CASE_COUNTRY_MAX_DEFAULT_DIGITS + ":" + curdata, null);
|
||||
return;
|
||||
}
|
||||
|
||||
int index;
|
||||
for (index = 0; index < scOldCurrencies.length; index++) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2015, 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
|
||||
@ -23,7 +23,7 @@
|
||||
/*
|
||||
* @test
|
||||
* @bug 4290801 4692419 4693631 5101540 5104960 6296410 6336600 6371531
|
||||
* 6488442 7036905 8039317
|
||||
* 6488442 7036905 8039317 8074350 8074351
|
||||
* @summary Basic tests for Currency class.
|
||||
*/
|
||||
|
||||
@ -49,6 +49,7 @@ public class CurrencyTest {
|
||||
testFractionDigits();
|
||||
testSerialization();
|
||||
testDisplayNames();
|
||||
testFundsCodes();
|
||||
}
|
||||
|
||||
static void testCurrencyCodeValidation() {
|
||||
@ -265,4 +266,41 @@ public class CurrencyTest {
|
||||
}
|
||||
}
|
||||
|
||||
static void testFundsCodes() {
|
||||
testValidCurrency("BOV");
|
||||
testValidCurrency("CHE");
|
||||
testValidCurrency("CHW");
|
||||
testValidCurrency("CLF");
|
||||
testValidCurrency("COU");
|
||||
testValidCurrency("MXV");
|
||||
testValidCurrency("USN");
|
||||
testValidCurrency("UYI");
|
||||
|
||||
testFractionDigits("BOV", 2);
|
||||
testFractionDigits("CHE", 2);
|
||||
testFractionDigits("CHW", 2);
|
||||
testFractionDigits("CLF", 4);
|
||||
testFractionDigits("COU", 2);
|
||||
testFractionDigits("MXV", 2);
|
||||
testFractionDigits("USN", 2);
|
||||
testFractionDigits("UYI", 0);
|
||||
|
||||
testNumericCode("BOV", 984);
|
||||
testNumericCode("CHE", 947);
|
||||
testNumericCode("CHW", 948);
|
||||
testNumericCode("CLF", 990);
|
||||
testNumericCode("COU", 970);
|
||||
testNumericCode("MXV", 979);
|
||||
testNumericCode("USN", 997);
|
||||
testNumericCode("UYI", 940);
|
||||
}
|
||||
|
||||
static void testNumericCode(String currencyCode, int expectedNumeric) {
|
||||
int numeric = Currency.getInstance(currencyCode).getNumericCode();
|
||||
if (numeric != expectedNumeric) {
|
||||
throw new RuntimeException("Wrong numeric code for currency " +
|
||||
currencyCode +": expected " + expectedNumeric +
|
||||
", got " + numeric);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2015, 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
|
||||
@ -107,7 +107,7 @@ public class PropertiesTest {
|
||||
keys = p.stringPropertyNames();
|
||||
Pattern propertiesPattern =
|
||||
Pattern.compile("([A-Z]{3})\\s*,\\s*(\\d{3})\\s*,\\s*" +
|
||||
"([0-3])\\s*,?\\s*(\\d{4}-\\d{2}-\\d{2}T\\d{2}:" +
|
||||
"(\\d+)\\s*,?\\s*(\\d{4}-\\d{2}-\\d{2}T\\d{2}:" +
|
||||
"\\d{2}:\\d{2})?");
|
||||
for (String key: keys) {
|
||||
String val = p.getProperty(key);
|
||||
@ -135,14 +135,20 @@ public class PropertiesTest {
|
||||
// ignore this
|
||||
continue;
|
||||
}
|
||||
|
||||
String code = m.group(1);
|
||||
int numeric = Integer.parseInt(m.group(2));
|
||||
int fraction = Integer.parseInt(m.group(3));
|
||||
if (fraction > 9) {
|
||||
System.out.println("Skipping since the fraction is greater than 9");
|
||||
continue;
|
||||
}
|
||||
|
||||
Matcher mAfter = propertiesPattern.matcher(afterVal);
|
||||
mAfter.find();
|
||||
|
||||
String code = m.group(1);
|
||||
String codeAfter = mAfter.group(1);
|
||||
int numeric = Integer.parseInt(m.group(2));
|
||||
int numericAfter = Integer.parseInt(mAfter.group(2));
|
||||
int fraction = Integer.parseInt(m.group(3));
|
||||
int fractionAfter = Integer.parseInt(mAfter.group(3));
|
||||
if (code.equals(codeAfter) &&
|
||||
(numeric == numericAfter)&&
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2007, 2015, 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
|
||||
@ -23,7 +23,7 @@
|
||||
#
|
||||
|
||||
# @test
|
||||
# @bug 6332666 6863624 7180362 8003846
|
||||
# @bug 6332666 6863624 7180362 8003846 8074350 8074351
|
||||
# @summary tests the capability of replacing the currency data with user
|
||||
# specified currency properties file
|
||||
# @build PropertiesTest
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2015, 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
|
||||
@ -23,7 +23,7 @@
|
||||
/*
|
||||
* @test
|
||||
* @bug 4691089 4819436 4942982 5104960 6544471 6627549 7066203 7195759
|
||||
* 8039317
|
||||
* 8039317 8074350 8074351
|
||||
* @summary Validate ISO 4217 data for Currency class.
|
||||
*/
|
||||
|
||||
@ -93,7 +93,7 @@ public class ValidateISO4217 {
|
||||
|
||||
/* Codes that are obsolete, do not have related country */
|
||||
static final String otherCodes =
|
||||
"ADP-AFA-ATS-AYM-AZM-BEF-BGL-BOV-BYB-CLF-CUC-CYP-DEM-EEK-ESP-FIM-FRF-GHC-GRD-GWP-IEP-ITL-LUF-MGF-MTL-MXV-MZM-NLG-PTE-ROL-RUR-SDD-SIT-SKK-SRG-TMM-TPE-TRL-VEF-USN-USS-VEB-XAG-XAU-XBA-XBB-XBC-XBD-XDR-XFO-XFU-XPD-XPT-XSU-XTS-XUA-XXX-YUM-ZMK-ZWD-ZWN-ZWR";
|
||||
"ADP-AFA-ATS-AYM-AZM-BEF-BGL-BOV-BYB-CHE-CHW-CLF-COU-CUC-CYP-DEM-EEK-ESP-FIM-FRF-GHC-GRD-GWP-IEP-ITL-LUF-MGF-MTL-MXV-MZM-NLG-PTE-ROL-RUR-SDD-SIT-SKK-SRG-TMM-TPE-TRL-VEF-UYI-USN-USS-VEB-XAG-XAU-XBA-XBB-XBC-XBD-XDR-XFO-XFU-XPD-XPT-XSU-XTS-XUA-XXX-YUM-ZMK-ZWD-ZWN-ZWR";
|
||||
|
||||
static boolean err = false;
|
||||
|
||||
|
@ -1,20 +1,30 @@
|
||||
#
|
||||
# Test data for replacing the currency data
|
||||
#
|
||||
JP=JPZ,123,2
|
||||
ES=ESD,877,2
|
||||
US=euR,978,2,2001-01-01T00:00:00
|
||||
|
||||
# valid entries
|
||||
CL=CLF,990,4
|
||||
CM=IED,111,2, 2004-01-01T00:70:00
|
||||
SB=EUR,111,2, 2099-01-01T00:00:00
|
||||
ZZ = ZZZ , 999 , 3
|
||||
ES=ESD,877,2
|
||||
JP=JPZ,123,2
|
||||
MA=MAA,555,5
|
||||
MC=MCC,555,6
|
||||
MD=MDD,555,7
|
||||
ME=MEE,555,8
|
||||
MF=MFF,555,9
|
||||
NO=EUR ,978 ,2, 2099-01-01T00:00:00
|
||||
SB=EUR,111,2, 2099-01-01T00:00:00
|
||||
US=euR,978,2,2001-01-01T00:00:00
|
||||
ZZ = ZZZ , 999 , 3
|
||||
|
||||
# invalid entries
|
||||
GB=123
|
||||
FR=zzzzz.123
|
||||
DE=2009-01-01T00:00:00,EUR,111,2
|
||||
IE=euR,111,2,#testcomment
|
||||
=euR,111,2, 2099-01-01-00-00-00
|
||||
FM=DED,194,2,eeee-01-01T00:00:00
|
||||
PE=EUR ,978 ,2, 20399-01-01T00:00:00
|
||||
FR=zzzzz.123
|
||||
GB=123
|
||||
IE=euR,111,2,#testcomment
|
||||
MG=MGG,990,10
|
||||
MX=SSS,493,2,2001-01-01-00-00-00
|
||||
PE=EUR ,978 ,2, 20399-01-01T00:00:00
|
||||
MG=MGG,990,10
|
||||
=euR,111,2, 2099-01-01-00-00-00
|
||||
|
@ -5,7 +5,7 @@
|
||||
#
|
||||
|
||||
# Version
|
||||
FILEVERSION=1
|
||||
FILEVERSION=2
|
||||
DATAVERSION=159
|
||||
|
||||
# ISO 4217 currency data
|
||||
@ -55,7 +55,7 @@ KY KYD 136 2
|
||||
CF XAF 950 0
|
||||
TD XAF 950 0
|
||||
CL CLP 152 0
|
||||
#CL CLF 990 0
|
||||
#CL CLF 990 4
|
||||
CN CNY 156 2
|
||||
CX AUD 36 2
|
||||
CC AUD 36 2
|
||||
@ -265,6 +265,7 @@ US USD 840 2
|
||||
#US USN 997 2
|
||||
UM USD 840 2
|
||||
UY UYU 858 2
|
||||
#UY UYI 940 0
|
||||
UZ UZS 860 2
|
||||
VU VUV 548 0
|
||||
VE VEF 937 2
|
||||
|
Loading…
Reference in New Issue
Block a user