Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
c1b50064
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c1b50064
编写于
4月 22, 2015
作者:
R
robm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8074350: Support ISO 4217 "Current funds codes" table (A.2)
Reviewed-by: naoto
上级
4181519a
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
145 addition
and
75 deletion
+145
-75
make/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java
...uild/tools/generatecurrencydata/GenerateCurrencyData.java
+31
-29
src/share/classes/java/util/Currency.java
src/share/classes/java/util/Currency.java
+26
-18
src/share/classes/java/util/CurrencyData.properties
src/share/classes/java/util/CurrencyData.properties
+12
-8
test/java/util/Currency/CurrencyTest.java
test/java/util/Currency/CurrencyTest.java
+39
-1
test/java/util/Currency/PropertiesTest.java
test/java/util/Currency/PropertiesTest.java
+11
-5
test/java/util/Currency/PropertiesTest.sh
test/java/util/Currency/PropertiesTest.sh
+2
-2
test/java/util/Currency/ValidateISO4217.java
test/java/util/Currency/ValidateISO4217.java
+2
-1
test/java/util/Currency/currency.properties
test/java/util/Currency/currency.properties
+19
-9
test/java/util/Currency/tablea1.txt
test/java/util/Currency/tablea1.txt
+3
-2
未找到文件。
make/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java
浏览文件 @
c1b50064
/*
* Copyright (c) 2001, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 201
5
, 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
...
...
@@ -72,10 +72,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 +79,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
=
0x00
0000
7F
;
// entry for countries without currency
private
static
final
int
COUNTRY_WITHOUT_CURRENCY_ENTRY
=
0x00
8
0
;
private
static
final
int
COUNTRY_WITHOUT_CURRENCY_ENTRY
=
0x00
00020
0
;
// mask for simple case country entries
private
static
final
int
SIMPLE_CASE_COUNTRY_MASK
=
0x0000
;
private
static
final
int
SIMPLE_CASE_COUNTRY_MASK
=
0x0000
0000
;
// 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
=
0x00
0000
1F
;
// mask for simple case country entry default currency digits
private
static
final
int
SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK
=
0x00
6
0
;
private
static
final
int
SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK
=
0x00
0001E
0
;
// 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
=
0x00
8
0
;
private
static
final
int
SPECIAL_CASE_COUNTRY_MASK
=
0x00
00020
0
;
// 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
=
0x00
0000
1F
;
// 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
=
0x000
3FF
00
;
private
static
final
int
NUMERIC_CODE_MASK
=
0x000
FFC
00
;
// 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 +118,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 +127,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 +174,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 +208,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 +232,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
(
currenciesWithDefinedMinorUnitDecimals
[
i
]
!=
null
&&
currenciesWithDefinedMinorUnitDecimals
[
i
].
indexOf
(
currencyCode
)
!=
-
1
)
{
return
i
;
}
}
if
(
currenciesWithMinorUnitsUndefined
.
indexOf
(
currencyCode
)
!=
-
1
)
{
return
-
1
;
}
else
{
return
2
;
...
...
src/share/classes/java/util/Currency.java
浏览文件 @
c1b50064
/*
* Copyright (c) 2000, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 201
5
, 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
...
...
@@ -139,11 +139,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
...
...
@@ -181,32 +181,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
=
0x00
0000
7F
;
// entry for countries without currency
private
static
final
int
COUNTRY_WITHOUT_CURRENCY_ENTRY
=
0x00
8
0
;
private
static
final
int
COUNTRY_WITHOUT_CURRENCY_ENTRY
=
0x00
00020
0
;
// mask for simple case country entries
private
static
final
int
SIMPLE_CASE_COUNTRY_MASK
=
0x0000
;
private
static
final
int
SIMPLE_CASE_COUNTRY_MASK
=
0x0000
0000
;
// 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
=
0x00
0000
1F
;
// mask for simple case country entry default currency digits
private
static
final
int
SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK
=
0x00
6
0
;
private
static
final
int
SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK
=
0x00
0001E
0
;
// 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
=
0x00
8
0
;
private
static
final
int
SPECIAL_CASE_COUNTRY_MASK
=
0x00
00020
0
;
// 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
=
0x00
0000
1F
;
// 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
=
0x000
3FF
00
;
private
static
final
int
NUMERIC_CODE_MASK
=
0x000
FFC
00
;
// 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
++)
{
...
...
src/share/classes/java/util/CurrencyData.properties
浏览文件 @
c1b50064
...
...
@@ -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-CH
F756-CLF990-CLP152-CNY156-COP1
70-CRC188-CSD891-CUP192-CUC931-
\
BZD084-CAD124-CDF976-CH
E947-CHF756-CHW948-CLF990-CLP152-CNY156-COP170-COU9
70-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-CL
F-CL
P-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
test/java/util/Currency/CurrencyTest.java
浏览文件 @
c1b50064
...
...
@@ -23,7 +23,7 @@
/*
* @test
* @bug 4290801 4692419 4693631 5101540 5104960 6296410 6336600 6371531
* 6488442 7036905
* 6488442 7036905
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
);
}
}
}
test/java/util/Currency/PropertiesTest.java
浏览文件 @
c1b50064
/*
* Copyright (c) 2007, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 201
5
, 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
)&&
...
...
test/java/util/Currency/PropertiesTest.sh
浏览文件 @
c1b50064
#!/bin/sh
# Copyright (c) 2007, 201
2
, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2007, 201
5
, 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
...
...
test/java/util/Currency/ValidateISO4217.java
浏览文件 @
c1b50064
...
...
@@ -23,6 +23,7 @@
/*
* @test
* @bug 4691089 4819436 4942982 5104960 6544471 6627549 7066203 7195759
* 8074350 8074351
* @summary Validate ISO 4217 data for Currency class.
*/
...
...
@@ -92,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-C
LF-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-C
HE-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
;
...
...
test/java/util/Currency/currency.properties
浏览文件 @
c1b50064
#
# 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
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
NO
=
EUR ,978 ,2, 2099-01-01T00:00:00
# 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
test/java/util/Currency/tablea1.txt
浏览文件 @
c1b50064
...
...
@@ -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
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录