Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
92e32815
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看板
提交
92e32815
编写于
4月 22, 2013
作者:
N
naoto
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
Reviewed-by: okutsu
上级
f0907e25
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
297 addition
and
50 deletion
+297
-50
src/macosx/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java
...n/util/locale/provider/HostLocaleProviderAdapterImpl.java
+11
-3
src/windows/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java
...n/util/locale/provider/HostLocaleProviderAdapterImpl.java
+130
-7
src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
...e/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
+103
-37
test/java/util/Locale/LocaleProviders.java
test/java/util/Locale/LocaleProviders.java
+40
-1
test/java/util/Locale/LocaleProviders.sh
test/java/util/Locale/LocaleProviders.sh
+13
-2
未找到文件。
src/macosx/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java
浏览文件 @
92e32815
/*
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
2013,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -520,14 +520,22 @@ public class HostLocaleProviderAdapterImpl {
...
@@ -520,14 +520,22 @@ public class HostLocaleProviderAdapterImpl {
}
}
private
static
boolean
isSupportedCalendarLocale
(
Locale
locale
)
{
private
static
boolean
isSupportedCalendarLocale
(
Locale
locale
)
{
Locale
base
=
locale
.
stripExtensions
();
Locale
base
=
locale
;
if
(
base
.
hasExtensions
()
||
base
.
getVariant
()
!=
""
)
{
base
=
new
Locale
.
Builder
()
.
setLocale
(
locale
)
.
clearExtensions
()
.
build
();
}
if
(!
supportedLocaleSet
.
contains
(
base
))
{
if
(!
supportedLocaleSet
.
contains
(
base
))
{
return
false
;
return
false
;
}
}
String
requestedCalType
=
locale
.
getUnicodeLocaleType
(
"ca"
);
String
requestedCalType
=
locale
.
getUnicodeLocaleType
(
"ca"
);
String
nativeCalType
=
String
nativeCalType
=
getCalendarID
(
local
e
.
toLanguageTag
()).
replaceFirst
(
"gregorian"
,
"gregory"
);
getCalendarID
(
bas
e
.
toLanguageTag
()).
replaceFirst
(
"gregorian"
,
"gregory"
);
if
(
requestedCalType
==
null
)
{
if
(
requestedCalType
==
null
)
{
return
Calendar
.
getAvailableCalendarTypes
().
contains
(
nativeCalType
);
return
Calendar
.
getAvailableCalendarTypes
().
contains
(
nativeCalType
);
...
...
src/windows/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java
浏览文件 @
92e32815
/*
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
2013,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -37,6 +37,7 @@ import java.text.spi.DecimalFormatSymbolsProvider;
...
@@ -37,6 +37,7 @@ import java.text.spi.DecimalFormatSymbolsProvider;
import
java.text.spi.NumberFormatProvider
;
import
java.text.spi.NumberFormatProvider
;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Currency
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Locale
;
import
java.util.Locale
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -48,6 +49,8 @@ import java.util.concurrent.ConcurrentMap;
...
@@ -48,6 +49,8 @@ import java.util.concurrent.ConcurrentMap;
import
java.util.concurrent.atomic.AtomicReferenceArray
;
import
java.util.concurrent.atomic.AtomicReferenceArray
;
import
java.util.spi.CalendarDataProvider
;
import
java.util.spi.CalendarDataProvider
;
import
java.util.spi.CalendarNameProvider
;
import
java.util.spi.CalendarNameProvider
;
import
java.util.spi.CurrencyNameProvider
;
import
java.util.spi.LocaleNameProvider
;
import
sun.util.spi.CalendarProvider
;
import
sun.util.spi.CalendarProvider
;
/**
/**
...
@@ -72,6 +75,14 @@ public class HostLocaleProviderAdapterImpl {
...
@@ -72,6 +75,14 @@ public class HostLocaleProviderAdapterImpl {
private
static
final
int
CD_FIRSTDAYOFWEEK
=
0
;
private
static
final
int
CD_FIRSTDAYOFWEEK
=
0
;
private
static
final
int
CD_MINIMALDAYSINFIRSTWEEK
=
1
;
private
static
final
int
CD_MINIMALDAYSINFIRSTWEEK
=
1
;
// Currency/Locale display name types
private
static
final
int
DN_CURRENCY_NAME
=
0
;
private
static
final
int
DN_CURRENCY_SYMBOL
=
1
;
private
static
final
int
DN_LOCALE_LANGUAGE
=
2
;
private
static
final
int
DN_LOCALE_SCRIPT
=
3
;
private
static
final
int
DN_LOCALE_REGION
=
4
;
private
static
final
int
DN_LOCALE_VARIANT
=
5
;
// Native Calendar ID to LDML calendar type map
// Native Calendar ID to LDML calendar type map
private
static
final
String
[]
calIDToLDML
=
{
private
static
final
String
[]
calIDToLDML
=
{
""
,
""
,
...
@@ -96,15 +107,25 @@ public class HostLocaleProviderAdapterImpl {
...
@@ -96,15 +107,25 @@ public class HostLocaleProviderAdapterImpl {
private
static
ConcurrentMap
<
Locale
,
SoftReference
<
DecimalFormatSymbols
>>
decimalFormatSymbolsCache
=
new
ConcurrentHashMap
<>();
private
static
ConcurrentMap
<
Locale
,
SoftReference
<
DecimalFormatSymbols
>>
decimalFormatSymbolsCache
=
new
ConcurrentHashMap
<>();
private
static
final
Set
<
Locale
>
supportedLocaleSet
;
private
static
final
Set
<
Locale
>
supportedLocaleSet
;
private
static
final
String
nativeDisplayLanguage
;
static
{
static
{
Set
<
Locale
>
tmpSet
=
new
HashSet
<>();
Set
<
Locale
>
tmpSet
=
new
HashSet
<>();
if
(
initialize
())
{
if
(
initialize
())
{
// Assuming the default locales do not include any extensions, so
// Assuming the default locales do not include any extensions, so
// no stripping is needed here.
// no stripping is needed here.
Locale
l
=
Locale
.
forLanguageTag
(
getDefaultLocale
(
CAT_FORMAT
).
replace
(
'_'
,
'-'
));
Control
c
=
Control
.
getNoFallbackControl
(
Control
.
FORMAT_DEFAULT
);
tmpSet
.
addAll
(
Control
.
getNoFallbackControl
(
Control
.
FORMAT_DEFAULT
).
getCandidateLocales
(
""
,
l
));
String
displayLocale
=
getDefaultLocale
(
CAT_DISPLAY
);
l
=
Locale
.
forLanguageTag
(
getDefaultLocale
(
CAT_DISPLAY
).
replace
(
'_'
,
'-'
));
Locale
l
=
Locale
.
forLanguageTag
(
displayLocale
.
replace
(
'_'
,
'-'
));
tmpSet
.
addAll
(
Control
.
getNoFallbackControl
(
Control
.
FORMAT_DEFAULT
).
getCandidateLocales
(
""
,
l
));
tmpSet
.
addAll
(
c
.
getCandidateLocales
(
""
,
l
));
nativeDisplayLanguage
=
l
.
getLanguage
();
String
formatLocale
=
getDefaultLocale
(
CAT_FORMAT
);
if
(!
formatLocale
.
equals
(
displayLocale
))
{
l
=
Locale
.
forLanguageTag
(
formatLocale
.
replace
(
'_'
,
'-'
));
tmpSet
.
addAll
(
c
.
getCandidateLocales
(
""
,
l
));
}
}
else
{
nativeDisplayLanguage
=
""
;
}
}
supportedLocaleSet
=
Collections
.
unmodifiableSet
(
tmpSet
);
supportedLocaleSet
=
Collections
.
unmodifiableSet
(
tmpSet
);
}
}
...
@@ -392,6 +413,96 @@ public class HostLocaleProviderAdapterImpl {
...
@@ -392,6 +413,96 @@ public class HostLocaleProviderAdapterImpl {
};
};
}
}
public
static
CurrencyNameProvider
getCurrencyNameProvider
()
{
return
new
CurrencyNameProvider
()
{
@Override
public
Locale
[]
getAvailableLocales
()
{
return
supportedLocale
;
}
@Override
public
boolean
isSupportedLocale
(
Locale
locale
)
{
// Ignore the extensions for now
return
supportedLocaleSet
.
contains
(
locale
.
stripExtensions
())
&&
locale
.
getLanguage
().
equals
(
nativeDisplayLanguage
);
}
@Override
public
String
getSymbol
(
String
currencyCode
,
Locale
locale
)
{
// Retrieves the currency symbol by calling
// GetLocaleInfoEx(LOCALE_SCURRENCY).
// It only works with the "locale"'s currency in its native
// language.
try
{
if
(
Currency
.
getInstance
(
locale
).
getCurrencyCode
()
.
equals
(
currencyCode
))
{
return
getDisplayString
(
locale
.
toLanguageTag
(),
DN_CURRENCY_SYMBOL
,
currencyCode
);
}
}
catch
(
IllegalArgumentException
iae
)
{}
return
null
;
}
@Override
public
String
getDisplayName
(
String
currencyCode
,
Locale
locale
)
{
// Retrieves the display name by calling
// GetLocaleInfoEx(LOCALE_SNATIVECURRNAME).
// It only works with the "locale"'s currency in its native
// language.
try
{
if
(
Currency
.
getInstance
(
locale
).
getCurrencyCode
()
.
equals
(
currencyCode
))
{
return
getDisplayString
(
locale
.
toLanguageTag
(),
DN_CURRENCY_NAME
,
currencyCode
);
}
}
catch
(
IllegalArgumentException
iae
)
{}
return
null
;
}
};
}
public
static
LocaleNameProvider
getLocaleNameProvider
()
{
return
new
LocaleNameProvider
()
{
@Override
public
Locale
[]
getAvailableLocales
()
{
return
supportedLocale
;
}
@Override
public
boolean
isSupportedLocale
(
Locale
locale
)
{
return
supportedLocaleSet
.
contains
(
locale
.
stripExtensions
())
&&
locale
.
getLanguage
().
equals
(
nativeDisplayLanguage
);
}
@Override
public
String
getDisplayLanguage
(
String
languageCode
,
Locale
locale
)
{
// Retrieves the display language name by calling
// GetLocaleInfoEx(LOCALE_SLOCALIZEDLANGUAGENAME).
return
getDisplayString
(
locale
.
toLanguageTag
(),
DN_LOCALE_LANGUAGE
,
languageCode
);
}
@Override
public
String
getDisplayCountry
(
String
countryCode
,
Locale
locale
)
{
// Retrieves the display country name by calling
// GetLocaleInfoEx(LOCALE_SLOCALIZEDCOUNTRYNAME).
return
getDisplayString
(
locale
.
toLanguageTag
(),
DN_LOCALE_REGION
,
nativeDisplayLanguage
+
"-"
+
countryCode
);
}
@Override
public
String
getDisplayScript
(
String
scriptCode
,
Locale
locale
)
{
return
null
;
}
@Override
public
String
getDisplayVariant
(
String
variantCode
,
Locale
locale
)
{
return
null
;
}
};
}
private
static
String
convertDateTimePattern
(
String
winPattern
)
{
private
static
String
convertDateTimePattern
(
String
winPattern
)
{
String
ret
=
winPattern
.
replaceAll
(
"dddd"
,
"EEEE"
);
String
ret
=
winPattern
.
replaceAll
(
"dddd"
,
"EEEE"
);
ret
=
ret
.
replaceAll
(
"ddd"
,
"EEE"
);
ret
=
ret
.
replaceAll
(
"ddd"
,
"EEE"
);
...
@@ -413,12 +524,21 @@ public class HostLocaleProviderAdapterImpl {
...
@@ -413,12 +524,21 @@ public class HostLocaleProviderAdapterImpl {
}
}
private
static
boolean
isSupportedCalendarLocale
(
Locale
locale
)
{
private
static
boolean
isSupportedCalendarLocale
(
Locale
locale
)
{
Locale
base
=
locale
.
stripExtensions
();
Locale
base
=
locale
;
if
(
base
.
hasExtensions
()
||
base
.
getVariant
()
!=
""
)
{
// strip off extensions and variant.
base
=
new
Locale
.
Builder
()
.
setLocale
(
locale
)
.
clearExtensions
()
.
build
();
}
if
(!
supportedLocaleSet
.
contains
(
base
))
{
if
(!
supportedLocaleSet
.
contains
(
base
))
{
return
false
;
return
false
;
}
}
int
calid
=
getCalendarID
(
local
e
.
toLanguageTag
());
int
calid
=
getCalendarID
(
bas
e
.
toLanguageTag
());
if
(
calid
<=
0
||
calid
>=
calIDToLDML
.
length
)
{
if
(
calid
<=
0
||
calid
>=
calIDToLDML
.
length
)
{
return
false
;
return
false
;
}
}
...
@@ -546,4 +666,7 @@ public class HostLocaleProviderAdapterImpl {
...
@@ -546,4 +666,7 @@ public class HostLocaleProviderAdapterImpl {
// For CalendarDataProvider
// For CalendarDataProvider
private
static
native
int
getCalendarDataValue
(
String
langTag
,
int
type
);
private
static
native
int
getCalendarDataValue
(
String
langTag
,
int
type
);
// For Locale/CurrencyNameProvider
private
static
native
String
getDisplayString
(
String
langTag
,
int
key
,
String
value
);
}
}
src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
浏览文件 @
92e32815
/*
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
2013,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -196,7 +196,7 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte
...
@@ -196,7 +196,7 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte
break
;
break
;
}
}
localeString
=
getJavaIDFromLangID
(
langid
);
localeString
=
(
char
*
)
getJavaIDFromLangID
(
langid
);
ret
=
(
*
env
)
->
NewStringUTF
(
env
,
localeString
);
ret
=
(
*
env
)
->
NewStringUTF
(
env
,
localeString
);
free
(
localeString
);
free
(
localeString
);
return
ret
;
return
ret
;
...
@@ -366,12 +366,14 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte
...
@@ -366,12 +366,14 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte
*/
*/
JNIEXPORT
jboolean
JNICALL
Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_isNativeDigit
JNIEXPORT
jboolean
JNICALL
Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_isNativeDigit
(
JNIEnv
*
env
,
jclass
cls
,
jstring
jlangtag
)
{
(
JNIEnv
*
env
,
jclass
cls
,
jstring
jlangtag
)
{
WCHAR
buf
[
BUFLEN
]
;
DWORD
num
;
const
jchar
*
langtag
=
(
*
env
)
->
GetStringChars
(
env
,
jlangtag
,
JNI_FALSE
);
const
jchar
*
langtag
=
(
*
env
)
->
GetStringChars
(
env
,
jlangtag
,
JNI_FALSE
);
int
got
=
getLocaleInfoWrapper
(
langtag
,
LOCALE_IDIGITSUBSTITUTION
,
buf
,
BUFLEN
);
int
got
=
getLocaleInfoWrapper
(
langtag
,
LOCALE_IDIGITSUBSTITUTION
|
LOCALE_RETURN_NUMBER
,
(
LPWSTR
)
&
num
,
sizeof
(
num
));
(
*
env
)
->
ReleaseStringChars
(
env
,
jlangtag
,
langtag
);
(
*
env
)
->
ReleaseStringChars
(
env
,
jlangtag
,
langtag
);
return
got
&&
buf
[
0
]
==
L'2'
;
// 2: native digit substitution
return
got
&&
num
==
2
;
// 2: native digit substitution
}
}
/*
/*
...
@@ -590,25 +592,72 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI
...
@@ -590,25 +592,72 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI
*/
*/
JNIEXPORT
jint
JNICALL
Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getCalendarDataValue
JNIEXPORT
jint
JNICALL
Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getCalendarDataValue
(
JNIEnv
*
env
,
jclass
cls
,
jstring
jlangtag
,
jint
type
)
{
(
JNIEnv
*
env
,
jclass
cls
,
jstring
jlangtag
,
jint
type
)
{
WCHAR
buf
[
BUFLEN
]
;
DWORD
num
;
const
jchar
*
langtag
=
(
*
env
)
->
GetStringChars
(
env
,
jlangtag
,
JNI_FALSE
);
const
jchar
*
langtag
=
(
*
env
)
->
GetStringChars
(
env
,
jlangtag
,
JNI_FALSE
);
int
got
=
0
;
int
got
=
0
;
switch
(
type
)
{
switch
(
type
)
{
case
sun_util_locale_provider_HostLocaleProviderAdapterImpl_CD_FIRSTDAYOFWEEK
:
case
sun_util_locale_provider_HostLocaleProviderAdapterImpl_CD_FIRSTDAYOFWEEK
:
got
=
getLocaleInfoWrapper
(
langtag
,
LOCALE_IFIRSTDAYOFWEEK
,
buf
,
BUFLEN
);
got
=
getLocaleInfoWrapper
(
langtag
,
LOCALE_IFIRSTDAYOFWEEK
|
LOCALE_RETURN_NUMBER
,
(
LPWSTR
)
&
num
,
sizeof
(
num
));
break
;
break
;
}
}
(
*
env
)
->
ReleaseStringChars
(
env
,
jlangtag
,
langtag
);
(
*
env
)
->
ReleaseStringChars
(
env
,
jlangtag
,
langtag
);
if
(
got
)
{
if
(
got
)
{
return
_wtoi
(
buf
)
;
return
num
;
}
else
{
}
else
{
return
-
1
;
return
-
1
;
}
}
}
}
/*
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl
* Method: getDisplayString
* Signature: (Ljava/lang/String;ILjava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT
jstring
JNICALL
Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getDisplayString
(
JNIEnv
*
env
,
jclass
cls
,
jstring
jlangtag
,
jint
type
,
jstring
jvalue
)
{
LCTYPE
lcType
;
jstring
jStr
;
const
jchar
*
pjChar
;
WCHAR
buf
[
BUFLEN
];
int
got
=
0
;
switch
(
type
)
{
case
sun_util_locale_provider_HostLocaleProviderAdapterImpl_DN_CURRENCY_NAME
:
lcType
=
LOCALE_SNATIVECURRNAME
;
jStr
=
jlangtag
;
break
;
case
sun_util_locale_provider_HostLocaleProviderAdapterImpl_DN_CURRENCY_SYMBOL
:
lcType
=
LOCALE_SCURRENCY
;
jStr
=
jlangtag
;
break
;
case
sun_util_locale_provider_HostLocaleProviderAdapterImpl_DN_LOCALE_LANGUAGE
:
lcType
=
LOCALE_SLOCALIZEDLANGUAGENAME
;
jStr
=
jvalue
;
break
;
case
sun_util_locale_provider_HostLocaleProviderAdapterImpl_DN_LOCALE_REGION
:
lcType
=
LOCALE_SLOCALIZEDCOUNTRYNAME
;
jStr
=
jvalue
;
break
;
default:
return
NULL
;
}
pjChar
=
(
*
env
)
->
GetStringChars
(
env
,
jStr
,
JNI_FALSE
);
got
=
getLocaleInfoWrapper
(
pjChar
,
lcType
,
buf
,
BUFLEN
);
(
*
env
)
->
ReleaseStringChars
(
env
,
jStr
,
pjChar
);
if
(
got
)
{
return
(
*
env
)
->
NewString
(
env
,
buf
,
wcslen
(
buf
));
}
else
{
return
NULL
;
}
}
int
getLocaleInfoWrapper
(
const
jchar
*
langtag
,
LCTYPE
type
,
LPWSTR
data
,
int
buflen
)
{
int
getLocaleInfoWrapper
(
const
jchar
*
langtag
,
LCTYPE
type
,
LPWSTR
data
,
int
buflen
)
{
if
(
pGetLocaleInfoEx
)
{
if
(
pGetLocaleInfoEx
)
{
if
(
wcscmp
(
L"und"
,
(
LPWSTR
)
langtag
)
==
0
)
{
if
(
wcscmp
(
L"und"
,
(
LPWSTR
)
langtag
)
==
0
)
{
...
@@ -642,11 +691,13 @@ int getCalendarInfoWrapper(const jchar *langtag, CALID id, LPCWSTR reserved, CAL
...
@@ -642,11 +691,13 @@ int getCalendarInfoWrapper(const jchar *langtag, CALID id, LPCWSTR reserved, CAL
}
}
jint
getCalendarID
(
const
jchar
*
langtag
)
{
jint
getCalendarID
(
const
jchar
*
langtag
)
{
WCHAR
type
[
BUFLEN
];
DWORD
type
;
int
got
=
getLocaleInfoWrapper
(
langtag
,
LOCALE_ICALENDARTYPE
,
type
,
BUFLEN
);
int
got
=
getLocaleInfoWrapper
(
langtag
,
LOCALE_ICALENDARTYPE
|
LOCALE_RETURN_NUMBER
,
(
LPWSTR
)
&
type
,
sizeof
(
type
));
if
(
got
)
{
if
(
got
)
{
return
_wtoi
(
type
)
;
return
type
;
}
else
{
}
else
{
return
0
;
return
0
;
}
}
...
@@ -691,28 +742,37 @@ WCHAR * getNumberPattern(const jchar * langtag, const jint numberStyle) {
...
@@ -691,28 +742,37 @@ WCHAR * getNumberPattern(const jchar * langtag, const jint numberStyle) {
}
}
void
getNumberPart
(
const
jchar
*
langtag
,
const
jint
numberStyle
,
WCHAR
*
number
)
{
void
getNumberPart
(
const
jchar
*
langtag
,
const
jint
numberStyle
,
WCHAR
*
number
)
{
WCHAR
buf
[
BUFLEN
];
DWORD
digits
=
0
;
DWORD
leadingZero
=
0
;
WCHAR
grouping
[
BUFLEN
];
WCHAR
grouping
[
BUFLEN
];
int
groupingLen
;
WCHAR
fractionPattern
[
BUFLEN
];
WCHAR
fractionPattern
[
BUFLEN
];
WCHAR
*
integerPattern
=
number
;
WCHAR
*
integerPattern
=
number
;
int
digits
;
BOOL
leadingZero
;
WCHAR
*
pDest
;
WCHAR
*
pDest
;
int
groupingLen
;
// Get info from Windows
// Get info from Windows
if
(
numberStyle
==
sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_CURRENCY
)
{
switch
(
numberStyle
)
{
getLocaleInfoWrapper
(
langtag
,
LOCALE_ICURRDIGITS
,
buf
,
BUFLEN
);
case
sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_CURRENCY
:
}
else
{
getLocaleInfoWrapper
(
langtag
,
getLocaleInfoWrapper
(
langtag
,
LOCALE_IDIGITS
,
buf
,
BUFLEN
);
LOCALE_ICURRDIGITS
|
LOCALE_RETURN_NUMBER
,
}
(
LPWSTR
)
&
digits
,
sizeof
(
digits
));
if
(
numberStyle
==
sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_INTEGER
)
{
break
;
digits
=
0
;
}
else
{
case
sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_INTEGER
:
digits
=
_wtoi
(
buf
);
break
;
case
sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_NUMBER
:
case
sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_PERCENT
:
default:
getLocaleInfoWrapper
(
langtag
,
LOCALE_IDIGITS
|
LOCALE_RETURN_NUMBER
,
(
LPWSTR
)
&
digits
,
sizeof
(
digits
));
break
;
}
}
getLocaleInfoWrapper
(
langtag
,
LOCALE_ILZERO
,
buf
,
BUFLEN
);
leadingZero
=
_wtoi
(
buf
)
!=
0
;
getLocaleInfoWrapper
(
langtag
,
LOCALE_ILZERO
|
LOCALE_RETURN_NUMBER
,
(
LPWSTR
)
&
leadingZero
,
sizeof
(
leadingZero
));
groupingLen
=
getLocaleInfoWrapper
(
langtag
,
LOCALE_SGROUPING
,
grouping
,
BUFLEN
);
groupingLen
=
getLocaleInfoWrapper
(
langtag
,
LOCALE_SGROUPING
,
grouping
,
BUFLEN
);
// fraction pattern
// fraction pattern
...
@@ -749,7 +809,7 @@ void getNumberPart(const jchar * langtag, const jint numberStyle, WCHAR * number
...
@@ -749,7 +809,7 @@ void getNumberPart(const jchar * langtag, const jint numberStyle, WCHAR * number
}
}
}
}
if
(
leadingZero
)
{
if
(
leadingZero
!=
0
)
{
*
pDest
++
=
L'0'
;
*
pDest
++
=
L'0'
;
}
else
{
}
else
{
*
pDest
++
=
L'#'
;
*
pDest
++
=
L'#'
;
...
@@ -760,29 +820,35 @@ void getNumberPart(const jchar * langtag, const jint numberStyle, WCHAR * number
...
@@ -760,29 +820,35 @@ void getNumberPart(const jchar * langtag, const jint numberStyle, WCHAR * number
}
}
void
getFixPart
(
const
jchar
*
langtag
,
const
jint
numberStyle
,
BOOL
positive
,
BOOL
prefix
,
WCHAR
*
ret
)
{
void
getFixPart
(
const
jchar
*
langtag
,
const
jint
numberStyle
,
BOOL
positive
,
BOOL
prefix
,
WCHAR
*
ret
)
{
WCHAR
buf
[
BUFLEN
];
DWORD
pattern
=
0
;
int
pattern
=
0
;
int
style
=
numberStyle
;
int
style
=
numberStyle
;
int
got
=
0
;
int
got
=
0
;
if
(
positive
)
{
if
(
positive
)
{
if
(
style
==
sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_CURRENCY
)
{
if
(
style
==
sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_CURRENCY
)
{
got
=
getLocaleInfoWrapper
(
langtag
,
LOCALE_ICURRENCY
,
buf
,
BUFLEN
);
got
=
getLocaleInfoWrapper
(
langtag
,
LOCALE_ICURRENCY
|
LOCALE_RETURN_NUMBER
,
(
LPWSTR
)
&
pattern
,
sizeof
(
pattern
));
}
else
if
(
style
==
sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_PERCENT
)
{
}
else
if
(
style
==
sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_PERCENT
)
{
got
=
getLocaleInfoWrapper
(
langtag
,
LOCALE_IPOSITIVEPERCENT
,
buf
,
BUFLEN
);
got
=
getLocaleInfoWrapper
(
langtag
,
LOCALE_IPOSITIVEPERCENT
|
LOCALE_RETURN_NUMBER
,
(
LPWSTR
)
&
pattern
,
sizeof
(
pattern
));
}
}
}
else
{
}
else
{
if
(
style
==
sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_CURRENCY
)
{
if
(
style
==
sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_CURRENCY
)
{
got
=
getLocaleInfoWrapper
(
langtag
,
LOCALE_INEGCURR
,
buf
,
BUFLEN
);
got
=
getLocaleInfoWrapper
(
langtag
,
LOCALE_INEGCURR
|
LOCALE_RETURN_NUMBER
,
(
LPWSTR
)
&
pattern
,
sizeof
(
pattern
));
}
else
if
(
style
==
sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_PERCENT
)
{
}
else
if
(
style
==
sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_PERCENT
)
{
got
=
getLocaleInfoWrapper
(
langtag
,
LOCALE_INEGATIVEPERCENT
,
buf
,
BUFLEN
);
got
=
getLocaleInfoWrapper
(
langtag
,
LOCALE_INEGATIVEPERCENT
|
LOCALE_RETURN_NUMBER
,
(
LPWSTR
)
&
pattern
,
sizeof
(
pattern
));
}
else
{
}
else
{
got
=
getLocaleInfoWrapper
(
langtag
,
LOCALE_INEGNUMBER
,
buf
,
BUFLEN
);
got
=
getLocaleInfoWrapper
(
langtag
,
LOCALE_INEGNUMBER
|
LOCALE_RETURN_NUMBER
,
(
LPWSTR
)
&
pattern
,
sizeof
(
pattern
));
}
}
}
}
if
(
got
)
{
pattern
=
_wtoi
(
buf
);
}
if
(
numberStyle
==
sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_INTEGER
)
{
if
(
numberStyle
==
sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_INTEGER
)
{
style
=
sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_NUMBER
;
style
=
sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_NUMBER
;
...
...
test/java/util/Locale/LocaleProviders.java
浏览文件 @
92e32815
/*
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
2013,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
import
java.text.*
;
import
java.text.*
;
import
java.text.spi.*
;
import
java.text.spi.*
;
import
java.util.*
;
import
java.util.*
;
import
java.util.spi.*
;
import
sun.util.locale.provider.LocaleProviderAdapter
;
import
sun.util.locale.provider.LocaleProviderAdapter
;
public
class
LocaleProviders
{
public
class
LocaleProviders
{
...
@@ -55,6 +56,10 @@ public class LocaleProviders {
...
@@ -55,6 +56,10 @@ public class LocaleProviders {
bug8001440Test
();
bug8001440Test
();
break
;
break
;
case
"bug8010666Test"
:
bug8010666Test
();
break
;
default
:
default
:
throw
new
RuntimeException
(
"Test method '"
+
methodName
+
"' not found."
);
throw
new
RuntimeException
(
"Test method '"
+
methodName
+
"' not found."
);
}
}
...
@@ -103,4 +108,38 @@ public class LocaleProviders {
...
@@ -103,4 +108,38 @@ public class LocaleProviders {
NumberFormat
nf
=
NumberFormat
.
getInstance
(
locale
);
NumberFormat
nf
=
NumberFormat
.
getInstance
(
locale
);
String
nu
=
nf
.
format
(
1234560
);
String
nu
=
nf
.
format
(
1234560
);
}
}
// This test assumes Windows localized language/country display names.
static
void
bug8010666Test
()
{
if
(
System
.
getProperty
(
"os.name"
).
startsWith
(
"Windows"
))
{
NumberFormat
nf
=
NumberFormat
.
getInstance
(
Locale
.
US
);
try
{
double
ver
=
nf
.
parse
(
System
.
getProperty
(
"os.version"
)).
doubleValue
();
System
.
out
.
printf
(
"Windows version: %.1f\n"
,
ver
);
if
(
ver
>=
6.0
)
{
LocaleProviderAdapter
lda
=
LocaleProviderAdapter
.
getAdapter
(
LocaleNameProvider
.
class
,
Locale
.
ENGLISH
);
LocaleProviderAdapter
.
Type
type
=
lda
.
getAdapterType
();
if
(
type
==
LocaleProviderAdapter
.
Type
.
HOST
)
{
Locale
mkmk
=
Locale
.
forLanguageTag
(
"mk-MK"
);
String
result
=
mkmk
.
getDisplayLanguage
(
Locale
.
ENGLISH
);
if
(!
"Macedonian (FYROM)"
.
equals
(
result
))
{
throw
new
RuntimeException
(
"Windows locale name provider did not return expected localized language name for \"mk\". Returned name was \""
+
result
+
"\""
);
}
result
=
Locale
.
US
.
getDisplayLanguage
(
Locale
.
ENGLISH
);
if
(!
"English"
.
equals
(
result
))
{
throw
new
RuntimeException
(
"Windows locale name provider did not return expected localized language name for \"en\". Returned name was \""
+
result
+
"\""
);
}
result
=
Locale
.
US
.
getDisplayCountry
(
Locale
.
ENGLISH
);
if
(
ver
>=
6.1
&&
!
"United States"
.
equals
(
result
))
{
throw
new
RuntimeException
(
"Windows locale name provider did not return expected localized country name for \"US\". Returned name was \""
+
result
+
"\""
);
}
}
else
{
throw
new
RuntimeException
(
"Windows Host LocaleProviderAdapter was not selected for English locale."
);
}
}
}
catch
(
ParseException
pe
)
{
throw
new
RuntimeException
(
"Parsing Windows version failed: "
+
pe
.
toString
());
}
}
}
}
}
test/java/util/Locale/LocaleProviders.sh
浏览文件 @
92e32815
#
#
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2012,
2013,
Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# This code is free software; you can redistribute it and/or modify it
# This code is free software; you can redistribute it and/or modify it
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
#!/bin/sh
#!/bin/sh
#
#
# @test
# @test
# @bug 6336885 7196799 7197573 7198834 8000245 8000615 8001440
# @bug 6336885 7196799 7197573 7198834 8000245 8000615 8001440
8010666
# @summary tests for "java.locale.providers" system property
# @summary tests for "java.locale.providers" system property
# @compile -XDignore.symbol.file LocaleProviders.java
# @compile -XDignore.symbol.file LocaleProviders.java
# @run shell/timeout=600 LocaleProviders.sh
# @run shell/timeout=600 LocaleProviders.sh
...
@@ -258,4 +258,15 @@ PARAM2=
...
@@ -258,4 +258,15 @@ PARAM2=
PARAM3
=
PARAM3
=
runTest
runTest
# testing 8010666 fix.
if
[
"
${
DEFLANG
}
"
=
"en"
]
then
METHODNAME
=
bug8010666Test
PREFLIST
=
HOST
PARAM1
=
PARAM2
=
PARAM3
=
runTest
fi
exit
$result
exit
$result
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录