author | chegar |
Sun, 17 Aug 2014 15:54:13 +0100 | |
changeset 25859 | 3317bb8137f4 |
parent 24121 | jdk/src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c@0de1e14447a8 |
child 34878 | 7d7e55ff253a |
permissions | -rw-r--r-- |
13583 | 1 |
/* |
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
2 |
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
13583 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
#include "sun_util_locale_provider_HostLocaleProviderAdapterImpl.h" |
|
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
27 |
#include "jni_util.h" |
13583 | 28 |
#include <windows.h> |
29 |
#include <gdefs.h> |
|
30 |
#include <stdlib.h> |
|
31 |
||
32 |
#define BUFLEN 256 |
|
33 |
||
34 |
// global variables |
|
35 |
typedef int (WINAPI *PGLIE)(const jchar *, LCTYPE, LPWSTR, int); |
|
36 |
typedef int (WINAPI *PGCIE)(const jchar *, CALID, LPCWSTR, CALTYPE, LPWSTR, int, LPDWORD); |
|
37 |
PGLIE pGetLocaleInfoEx; |
|
38 |
PGCIE pGetCalendarInfoEx; |
|
39 |
BOOL initialized = FALSE; |
|
40 |
||
41 |
// prototypes |
|
42 |
int getLocaleInfoWrapper(const jchar *langtag, LCTYPE type, LPWSTR data, int buflen); |
|
43 |
int getCalendarInfoWrapper(const jchar *langtag, CALID id, LPCWSTR reserved, CALTYPE type, LPWSTR data, int buflen, LPDWORD val); |
|
44 |
jint getCalendarID(const jchar *langtag); |
|
45 |
void replaceCalendarArrayElems(JNIEnv *env, jstring jlangtag, jobjectArray jarray, |
|
46 |
CALTYPE* pCalTypes, int offset, int length); |
|
47 |
WCHAR * getNumberPattern(const jchar * langtag, const jint numberStyle); |
|
48 |
void getNumberPart(const jchar * langtag, const jint numberStyle, WCHAR * number); |
|
49 |
void getFixPart(const jchar * langtag, const jint numberStyle, BOOL positive, BOOL prefix, WCHAR * ret); |
|
50 |
||
51 |
// from java_props_md.c |
|
52 |
extern __declspec(dllexport) const char * getJavaIDFromLangID(LANGID langID); |
|
53 |
||
54 |
CALTYPE monthsType[] = { |
|
55 |
CAL_SMONTHNAME1, |
|
56 |
CAL_SMONTHNAME2, |
|
57 |
CAL_SMONTHNAME3, |
|
58 |
CAL_SMONTHNAME4, |
|
59 |
CAL_SMONTHNAME5, |
|
60 |
CAL_SMONTHNAME6, |
|
61 |
CAL_SMONTHNAME7, |
|
62 |
CAL_SMONTHNAME8, |
|
63 |
CAL_SMONTHNAME9, |
|
64 |
CAL_SMONTHNAME10, |
|
65 |
CAL_SMONTHNAME11, |
|
66 |
CAL_SMONTHNAME12, |
|
67 |
CAL_SMONTHNAME13, |
|
68 |
}; |
|
69 |
||
70 |
CALTYPE sMonthsType[] = { |
|
71 |
CAL_SABBREVMONTHNAME1, |
|
72 |
CAL_SABBREVMONTHNAME2, |
|
73 |
CAL_SABBREVMONTHNAME3, |
|
74 |
CAL_SABBREVMONTHNAME4, |
|
75 |
CAL_SABBREVMONTHNAME5, |
|
76 |
CAL_SABBREVMONTHNAME6, |
|
77 |
CAL_SABBREVMONTHNAME7, |
|
78 |
CAL_SABBREVMONTHNAME8, |
|
79 |
CAL_SABBREVMONTHNAME9, |
|
80 |
CAL_SABBREVMONTHNAME10, |
|
81 |
CAL_SABBREVMONTHNAME11, |
|
82 |
CAL_SABBREVMONTHNAME12, |
|
83 |
CAL_SABBREVMONTHNAME13, |
|
84 |
}; |
|
85 |
||
86 |
CALTYPE wDaysType[] = { |
|
87 |
CAL_SDAYNAME7, |
|
88 |
CAL_SDAYNAME1, |
|
89 |
CAL_SDAYNAME2, |
|
90 |
CAL_SDAYNAME3, |
|
91 |
CAL_SDAYNAME4, |
|
92 |
CAL_SDAYNAME5, |
|
93 |
CAL_SDAYNAME6, |
|
94 |
}; |
|
95 |
||
96 |
CALTYPE sWDaysType[] = { |
|
97 |
CAL_SABBREVDAYNAME7, |
|
98 |
CAL_SABBREVDAYNAME1, |
|
99 |
CAL_SABBREVDAYNAME2, |
|
100 |
CAL_SABBREVDAYNAME3, |
|
101 |
CAL_SABBREVDAYNAME4, |
|
102 |
CAL_SABBREVDAYNAME5, |
|
103 |
CAL_SABBREVDAYNAME6, |
|
104 |
}; |
|
105 |
||
106 |
WCHAR * fixes[2][2][3][16] = |
|
107 |
{ |
|
108 |
{ //prefix |
|
109 |
{ //positive |
|
110 |
{ // number |
|
111 |
L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", |
|
112 |
}, |
|
113 |
{ // currency |
|
114 |
L"\xA4", L"", L"\xA4 ", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", |
|
115 |
}, |
|
116 |
{ // percent |
|
117 |
L"", L"", L"%", L"% ", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", |
|
118 |
} |
|
119 |
}, |
|
120 |
{ // negative |
|
121 |
{ // number |
|
122 |
L"(", L"-", L"- ", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", |
|
123 |
}, |
|
124 |
{ //currency |
|
125 |
L"(\xA4", L"-\xA4", L"\xA4-", L"\xA4", L"(", L"-", L"", L"", L"-", L"-\xA4 ", L"", L"\xA4 ", L"\xA4 -", L"", L"(\xA4 ", L"(" |
|
126 |
}, |
|
127 |
{ // percent |
|
128 |
L"-", L"-", L"-%", L"%-", L"%", L"", L"", L"-% ", L"", L"% ", L"% -", L"", L"", L"", L"", L"", |
|
129 |
} |
|
130 |
} |
|
131 |
}, |
|
132 |
{ // suffix |
|
133 |
{ //positive |
|
134 |
{ // number |
|
135 |
L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"" |
|
136 |
}, |
|
137 |
{ // currency |
|
138 |
L"", L"\xA4 ", L"", L" \xA4", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", |
|
139 |
}, |
|
140 |
{ // percent |
|
141 |
L" %", L"%", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", |
|
142 |
} |
|
143 |
}, |
|
144 |
{ // negative |
|
145 |
{ // number |
|
146 |
L")", L"", L" ", L"-", L" -", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", L"", |
|
147 |
}, |
|
148 |
{ //currency |
|
149 |
L")", L"", L"", L"-", L"\xA4)", L"\xA4", L"-\xA4", L"\xA4-", L" \xA4", L"", L" \xA4-", L"-", L"", L"- \xA4", L")", L" \xA4)" |
|
150 |
}, |
|
151 |
{ // percent |
|
152 |
L" %", L"%", L"", L"", L"-", L"-%", L"%-", L"", L" %-", L"-", L"", L"- %", L"", L"", L"", L"", |
|
153 |
} |
|
154 |
} |
|
155 |
} |
|
156 |
}; |
|
157 |
||
158 |
/* |
|
159 |
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl |
|
160 |
* Method: initialize |
|
161 |
* Signature: ()Z |
|
162 |
*/ |
|
163 |
JNIEXPORT jboolean JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_initialize |
|
164 |
(JNIEnv *env, jclass cls) { |
|
165 |
if (!initialized) { |
|
166 |
pGetLocaleInfoEx = (PGLIE)GetProcAddress( |
|
167 |
GetModuleHandle("kernel32.dll"), |
|
168 |
"GetLocaleInfoEx"); |
|
169 |
pGetCalendarInfoEx = (PGCIE)GetProcAddress( |
|
170 |
GetModuleHandle("kernel32.dll"), |
|
171 |
"GetCalendarInfoEx"); |
|
172 |
initialized =TRUE; |
|
173 |
} |
|
174 |
||
175 |
return pGetLocaleInfoEx != NULL && |
|
176 |
pGetCalendarInfoEx != NULL; |
|
177 |
} |
|
178 |
||
179 |
/* |
|
180 |
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl |
|
181 |
* Method: getDefaultLocale |
|
182 |
* Signature: (I)Ljava/lang/String; |
|
183 |
*/ |
|
184 |
JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getDefaultLocale |
|
185 |
(JNIEnv *env, jclass cls, jint cat) { |
|
186 |
char * localeString = NULL; |
|
187 |
LANGID langid; |
|
188 |
jstring ret; |
|
189 |
||
190 |
switch (cat) { |
|
191 |
case sun_util_locale_provider_HostLocaleProviderAdapterImpl_CAT_DISPLAY: |
|
192 |
langid = LANGIDFROMLCID(GetUserDefaultUILanguage()); |
|
193 |
break; |
|
194 |
case sun_util_locale_provider_HostLocaleProviderAdapterImpl_CAT_FORMAT: |
|
195 |
default: |
|
196 |
langid = LANGIDFROMLCID(GetUserDefaultLCID()); |
|
197 |
break; |
|
198 |
} |
|
199 |
||
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
200 |
localeString = (char *)getJavaIDFromLangID(langid); |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
201 |
if (localeString != NULL) { |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
202 |
ret = (*env)->NewStringUTF(env, localeString); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
203 |
free(localeString); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
204 |
} else { |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
205 |
JNU_ThrowOutOfMemoryError(env, "memory allocation error"); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
206 |
ret = NULL; |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
207 |
} |
13583 | 208 |
return ret; |
209 |
} |
|
210 |
||
211 |
/* |
|
212 |
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl |
|
213 |
* Method: getDateTimePattern |
|
214 |
* Signature: (IILjava/lang/String;)Ljava/lang/String; |
|
215 |
*/ |
|
216 |
JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getDateTimePattern |
|
217 |
(JNIEnv *env, jclass cls, jint dateStyle, jint timeStyle, jstring jlangtag) { |
|
14028
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
13583
diff
changeset
|
218 |
WCHAR pattern[BUFLEN]; |
13583 | 219 |
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
220 |
CHECK_NULL_RETURN(langtag, NULL); |
13583 | 221 |
|
14028
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
13583
diff
changeset
|
222 |
pattern[0] = L'\0'; |
13583 | 223 |
|
224 |
if (dateStyle == 0 || dateStyle == 1) { |
|
14028
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
13583
diff
changeset
|
225 |
getLocaleInfoWrapper(langtag, LOCALE_SLONGDATE, pattern, BUFLEN); |
13583 | 226 |
} else if (dateStyle == 2 || dateStyle == 3) { |
14028
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
13583
diff
changeset
|
227 |
getLocaleInfoWrapper(langtag, LOCALE_SSHORTDATE, pattern, BUFLEN); |
13583 | 228 |
} |
229 |
||
230 |
if (timeStyle == 0 || timeStyle == 1) { |
|
14028
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
13583
diff
changeset
|
231 |
getLocaleInfoWrapper(langtag, LOCALE_STIMEFORMAT, pattern, BUFLEN); |
13583 | 232 |
} else if (timeStyle == 2 || timeStyle == 3) { |
14028
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
13583
diff
changeset
|
233 |
getLocaleInfoWrapper(langtag, LOCALE_SSHORTTIME, pattern, BUFLEN); |
13583 | 234 |
} |
235 |
||
236 |
(*env)->ReleaseStringChars(env, jlangtag, langtag); |
|
237 |
||
24121
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
238 |
return (*env)->NewString(env, pattern, (jsize)wcslen(pattern)); |
13583 | 239 |
} |
240 |
||
241 |
/* |
|
242 |
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl |
|
243 |
* Method: getCalendarID |
|
244 |
* Signature: (Ljava/lang/String;)I |
|
245 |
*/ |
|
246 |
JNIEXPORT jint JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getCalendarID |
|
247 |
(JNIEnv *env, jclass cls, jstring jlangtag) { |
|
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
248 |
const jchar *langtag; |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
249 |
jint ret; |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
250 |
langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
251 |
CHECK_NULL_RETURN(langtag, 0); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
252 |
ret = getCalendarID(langtag); |
13583 | 253 |
(*env)->ReleaseStringChars(env, jlangtag, langtag); |
254 |
return ret; |
|
255 |
} |
|
256 |
||
257 |
/* |
|
258 |
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl |
|
259 |
* Method: getAmPmStrings |
|
260 |
* Signature: (Ljava/lang/String;[Ljava/lang/String;)[Ljava/lang/String; |
|
261 |
*/ |
|
262 |
JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getAmPmStrings |
|
263 |
(JNIEnv *env, jclass cls, jstring jlangtag, jobjectArray ampms) { |
|
264 |
WCHAR buf[BUFLEN]; |
|
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
265 |
const jchar *langtag; |
24121
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
266 |
jstring tmp_string; |
13583 | 267 |
|
268 |
// AM |
|
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
269 |
int got; |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
270 |
langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
271 |
CHECK_NULL_RETURN(langtag, NULL); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
272 |
got = getLocaleInfoWrapper(langtag, LOCALE_S1159, buf, BUFLEN); |
13583 | 273 |
if (got) { |
24121
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
274 |
tmp_string = (*env)->NewString(env, buf, (jsize)wcslen(buf)); |
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
275 |
if (tmp_string != NULL) { |
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
276 |
(*env)->SetObjectArrayElement(env, ampms, 0, tmp_string); |
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
277 |
} |
13583 | 278 |
} |
279 |
||
24121
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
280 |
if (!(*env)->ExceptionCheck(env)){ |
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
281 |
// PM |
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
282 |
got = getLocaleInfoWrapper(langtag, LOCALE_S2359, buf, BUFLEN); |
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
283 |
if (got) { |
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
284 |
tmp_string = (*env)->NewString(env, buf, (jsize)wcslen(buf)); |
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
285 |
if (tmp_string != NULL) { |
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
286 |
(*env)->SetObjectArrayElement(env, ampms, 1, tmp_string); |
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
287 |
} |
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
288 |
} |
13583 | 289 |
} |
290 |
||
291 |
(*env)->ReleaseStringChars(env, jlangtag, langtag); |
|
292 |
||
293 |
return ampms; |
|
294 |
} |
|
295 |
||
296 |
/* |
|
297 |
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl |
|
298 |
* Method: getEras |
|
299 |
* Signature: (Ljava/lang/String;[Ljava/lang/String;)[Ljava/lang/String; |
|
300 |
*/ |
|
301 |
JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getEras |
|
302 |
(JNIEnv *env, jclass cls, jstring jlangtag, jobjectArray eras) { |
|
303 |
WCHAR ad[BUFLEN]; |
|
304 |
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); |
|
24121
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
305 |
jstring tmp_string; |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
306 |
CHECK_NULL_RETURN(langtag, eras); |
13583 | 307 |
|
308 |
getCalendarInfoWrapper(langtag, getCalendarID(langtag), NULL, |
|
309 |
CAL_SERASTRING, ad, BUFLEN, NULL); |
|
310 |
||
311 |
// Windows does not provide B.C. era. |
|
24121
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
312 |
tmp_string = (*env)->NewString(env, ad, (jsize)wcslen(ad)); |
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
313 |
if (tmp_string != NULL) { |
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
314 |
(*env)->SetObjectArrayElement(env, eras, 1, tmp_string); |
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
315 |
} |
13583 | 316 |
|
317 |
(*env)->ReleaseStringChars(env, jlangtag, langtag); |
|
318 |
||
319 |
return eras; |
|
320 |
} |
|
321 |
||
322 |
/* |
|
323 |
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl |
|
324 |
* Method: getMonths |
|
325 |
* Signature: (Ljava/lang/String;[Ljava/lang/String;)[Ljava/lang/String; |
|
326 |
*/ |
|
327 |
JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getMonths |
|
328 |
(JNIEnv *env, jclass cls, jstring jlangtag, jobjectArray months) { |
|
329 |
replaceCalendarArrayElems(env, jlangtag, months, monthsType, |
|
330 |
0, sizeof(monthsType)/sizeof(CALTYPE)); |
|
331 |
return months; |
|
332 |
} |
|
333 |
||
334 |
/* |
|
335 |
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl |
|
336 |
* Method: getShortMonths |
|
337 |
* Signature: (Ljava/lang/String;[Ljava/lang/String;)[Ljava/lang/String; |
|
338 |
*/ |
|
339 |
JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getShortMonths |
|
340 |
(JNIEnv *env, jclass cls, jstring jlangtag, jobjectArray smonths) { |
|
341 |
replaceCalendarArrayElems(env, jlangtag, smonths, sMonthsType, |
|
342 |
0, sizeof(sMonthsType)/sizeof(CALTYPE)); |
|
343 |
return smonths; |
|
344 |
} |
|
345 |
||
346 |
/* |
|
347 |
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl |
|
348 |
* Method: getWeekdays |
|
349 |
* Signature: (Ljava/lang/String;[Ljava/lang/String;)[Ljava/lang/String; |
|
350 |
*/ |
|
351 |
JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getWeekdays |
|
352 |
(JNIEnv *env, jclass cls, jstring jlangtag, jobjectArray wdays) { |
|
353 |
replaceCalendarArrayElems(env, jlangtag, wdays, wDaysType, |
|
354 |
1, sizeof(wDaysType)/sizeof(CALTYPE)); |
|
355 |
return wdays; |
|
356 |
} |
|
357 |
||
358 |
/* |
|
359 |
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl |
|
360 |
* Method: getShortWeekdays |
|
361 |
* Signature: (Ljava/lang/String;[Ljava/lang/String;)[Ljava/lang/String; |
|
362 |
*/ |
|
363 |
JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getShortWeekdays |
|
364 |
(JNIEnv *env, jclass cls, jstring jlangtag, jobjectArray swdays) { |
|
365 |
replaceCalendarArrayElems(env, jlangtag, swdays, sWDaysType, |
|
366 |
1, sizeof(sWDaysType)/sizeof(CALTYPE)); |
|
367 |
return swdays; |
|
368 |
} |
|
369 |
||
370 |
/* |
|
371 |
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl |
|
372 |
* Method: getNumberPattern |
|
373 |
* Signature: (ILjava/lang/String;)Ljava/lang/String; |
|
374 |
*/ |
|
375 |
JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getNumberPattern |
|
376 |
(JNIEnv *env, jclass cls, jint numberStyle, jstring jlangtag) { |
|
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
377 |
const jchar *langtag; |
13583 | 378 |
jstring ret; |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
379 |
WCHAR * pattern; |
13583 | 380 |
|
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
381 |
langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
382 |
CHECK_NULL_RETURN(langtag, NULL); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
383 |
pattern = getNumberPattern(langtag, numberStyle); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
384 |
CHECK_NULL_RETURN(pattern, NULL); |
13583 | 385 |
|
386 |
(*env)->ReleaseStringChars(env, jlangtag, langtag); |
|
24121
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
387 |
ret = (*env)->NewString(env, pattern, (jsize)wcslen(pattern)); |
13583 | 388 |
free(pattern); |
389 |
||
390 |
return ret; |
|
391 |
} |
|
392 |
||
393 |
/* |
|
394 |
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl |
|
395 |
* Method: isNativeDigit |
|
396 |
* Signature: (Ljava/lang/String;)Z |
|
397 |
*/ |
|
398 |
JNIEXPORT jboolean JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_isNativeDigit |
|
399 |
(JNIEnv *env, jclass cls, jstring jlangtag) { |
|
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
400 |
DWORD num; |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
401 |
int got; |
13583 | 402 |
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
403 |
CHECK_NULL_RETURN(langtag, JNI_FALSE); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
404 |
got = getLocaleInfoWrapper(langtag, |
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
405 |
LOCALE_IDIGITSUBSTITUTION | LOCALE_RETURN_NUMBER, |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
406 |
(LPWSTR)&num, sizeof(num)); |
13583 | 407 |
(*env)->ReleaseStringChars(env, jlangtag, langtag); |
408 |
||
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
409 |
return got && num == 2; // 2: native digit substitution |
13583 | 410 |
} |
411 |
||
412 |
/* |
|
413 |
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl |
|
414 |
* Method: getCurrencySymbol |
|
415 |
* Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; |
|
416 |
*/ |
|
417 |
JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getCurrencySymbol |
|
418 |
(JNIEnv *env, jclass cls, jstring jlangtag, jstring currencySymbol) { |
|
419 |
WCHAR buf[BUFLEN]; |
|
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
420 |
int got; |
13583 | 421 |
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
422 |
CHECK_NULL_RETURN(langtag, currencySymbol); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
423 |
got = getLocaleInfoWrapper(langtag, LOCALE_SCURRENCY, buf, BUFLEN); |
13583 | 424 |
(*env)->ReleaseStringChars(env, jlangtag, langtag); |
425 |
||
426 |
if (got) { |
|
24121
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
427 |
return (*env)->NewString(env, buf, (jsize)wcslen(buf)); |
13583 | 428 |
} else { |
429 |
return currencySymbol; |
|
430 |
} |
|
431 |
} |
|
432 |
||
433 |
/* |
|
434 |
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl |
|
435 |
* Method: getDecimalSeparator |
|
436 |
* Signature: (Ljava/lang/String;C)C |
|
437 |
*/ |
|
438 |
JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getDecimalSeparator |
|
439 |
(JNIEnv *env, jclass cls, jstring jlangtag, jchar decimalSeparator) { |
|
440 |
WCHAR buf[BUFLEN]; |
|
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
441 |
int got; |
13583 | 442 |
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
443 |
CHECK_NULL_RETURN(langtag, decimalSeparator); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
444 |
got = getLocaleInfoWrapper(langtag, LOCALE_SDECIMAL, buf, BUFLEN); |
13583 | 445 |
(*env)->ReleaseStringChars(env, jlangtag, langtag); |
446 |
||
447 |
if (got) { |
|
448 |
return buf[0]; |
|
449 |
} else { |
|
450 |
return decimalSeparator; |
|
451 |
} |
|
452 |
} |
|
453 |
||
454 |
/* |
|
455 |
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl |
|
456 |
* Method: getGroupingSeparator |
|
457 |
* Signature: (Ljava/lang/String;C)C |
|
458 |
*/ |
|
459 |
JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getGroupingSeparator |
|
460 |
(JNIEnv *env, jclass cls, jstring jlangtag, jchar groupingSeparator) { |
|
461 |
WCHAR buf[BUFLEN]; |
|
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
462 |
int got; |
13583 | 463 |
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
464 |
CHECK_NULL_RETURN(langtag, groupingSeparator); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
465 |
got = getLocaleInfoWrapper(langtag, LOCALE_STHOUSAND, buf, BUFLEN); |
13583 | 466 |
(*env)->ReleaseStringChars(env, jlangtag, langtag); |
467 |
||
468 |
if (got) { |
|
469 |
return buf[0]; |
|
470 |
} else { |
|
471 |
return groupingSeparator; |
|
472 |
} |
|
473 |
} |
|
474 |
||
475 |
/* |
|
476 |
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl |
|
477 |
* Method: getInfinity |
|
478 |
* Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; |
|
479 |
*/ |
|
480 |
JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getInfinity |
|
481 |
(JNIEnv *env, jclass cls, jstring jlangtag, jstring infinity) { |
|
482 |
WCHAR buf[BUFLEN]; |
|
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
483 |
int got; |
13583 | 484 |
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
485 |
CHECK_NULL_RETURN(langtag, infinity); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
486 |
got = getLocaleInfoWrapper(langtag, LOCALE_SPOSINFINITY, buf, BUFLEN); |
13583 | 487 |
(*env)->ReleaseStringChars(env, jlangtag, langtag); |
488 |
||
489 |
if (got) { |
|
24121
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
490 |
return (*env)->NewString(env, buf, (jsize)wcslen(buf)); |
13583 | 491 |
} else { |
492 |
return infinity; |
|
493 |
} |
|
494 |
} |
|
495 |
||
496 |
/* |
|
497 |
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl |
|
498 |
* Method: getInternationalCurrencySymbol |
|
499 |
* Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; |
|
500 |
*/ |
|
501 |
JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getInternationalCurrencySymbol |
|
502 |
(JNIEnv *env, jclass cls, jstring jlangtag, jstring internationalCurrencySymbol) { |
|
503 |
WCHAR buf[BUFLEN]; |
|
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
504 |
int got; |
13583 | 505 |
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
506 |
CHECK_NULL_RETURN(langtag, internationalCurrencySymbol); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
507 |
got = getLocaleInfoWrapper(langtag, LOCALE_SINTLSYMBOL, buf, BUFLEN); |
13583 | 508 |
(*env)->ReleaseStringChars(env, jlangtag, langtag); |
509 |
||
510 |
if (got) { |
|
24121
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
511 |
return (*env)->NewString(env, buf, (jsize)wcslen(buf)); |
13583 | 512 |
} else { |
513 |
return internationalCurrencySymbol; |
|
514 |
} |
|
515 |
} |
|
516 |
||
517 |
/* |
|
518 |
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl |
|
519 |
* Method: getMinusSign |
|
520 |
* Signature: (Ljava/lang/String;C)C |
|
521 |
*/ |
|
522 |
JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getMinusSign |
|
523 |
(JNIEnv *env, jclass cls, jstring jlangtag, jchar minusSign) { |
|
524 |
WCHAR buf[BUFLEN]; |
|
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
525 |
int got; |
13583 | 526 |
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
527 |
CHECK_NULL_RETURN(langtag, minusSign); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
528 |
got = getLocaleInfoWrapper(langtag, LOCALE_SNEGATIVESIGN, buf, BUFLEN); |
13583 | 529 |
(*env)->ReleaseStringChars(env, jlangtag, langtag); |
530 |
||
531 |
if (got) { |
|
532 |
return buf[0]; |
|
533 |
} else { |
|
534 |
return minusSign; |
|
535 |
} |
|
536 |
} |
|
537 |
||
538 |
/* |
|
539 |
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl |
|
540 |
* Method: getMonetaryDecimalSeparator |
|
541 |
* Signature: (Ljava/lang/String;C)C |
|
542 |
*/ |
|
543 |
JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getMonetaryDecimalSeparator |
|
544 |
(JNIEnv *env, jclass cls, jstring jlangtag, jchar monetaryDecimalSeparator) { |
|
545 |
WCHAR buf[BUFLEN]; |
|
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
546 |
int got; |
13583 | 547 |
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
548 |
CHECK_NULL_RETURN(langtag, monetaryDecimalSeparator); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
549 |
got = getLocaleInfoWrapper(langtag, LOCALE_SMONDECIMALSEP, buf, BUFLEN); |
13583 | 550 |
(*env)->ReleaseStringChars(env, jlangtag, langtag); |
551 |
||
552 |
if (got) { |
|
553 |
return buf[0]; |
|
554 |
} else { |
|
555 |
return monetaryDecimalSeparator; |
|
556 |
} |
|
557 |
} |
|
558 |
||
559 |
/* |
|
560 |
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl |
|
561 |
* Method: getNaN |
|
562 |
* Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; |
|
563 |
*/ |
|
564 |
JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getNaN |
|
565 |
(JNIEnv *env, jclass cls, jstring jlangtag, jstring nan) { |
|
566 |
WCHAR buf[BUFLEN]; |
|
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
567 |
int got; |
13583 | 568 |
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
569 |
CHECK_NULL_RETURN(langtag, nan); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
570 |
got = getLocaleInfoWrapper(langtag, LOCALE_SNAN, buf, BUFLEN); |
13583 | 571 |
(*env)->ReleaseStringChars(env, jlangtag, langtag); |
572 |
||
573 |
if (got) { |
|
24121
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
574 |
return (*env)->NewString(env, buf, (jsize)wcslen(buf)); |
13583 | 575 |
} else { |
576 |
return nan; |
|
577 |
} |
|
578 |
} |
|
579 |
||
580 |
/* |
|
581 |
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl |
|
582 |
* Method: getPercent |
|
583 |
* Signature: (Ljava/lang/String;C)C |
|
584 |
*/ |
|
585 |
JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getPercent |
|
586 |
(JNIEnv *env, jclass cls, jstring jlangtag, jchar percent) { |
|
587 |
WCHAR buf[BUFLEN]; |
|
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
588 |
int got; |
13583 | 589 |
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
590 |
CHECK_NULL_RETURN(langtag, percent); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
591 |
got = getLocaleInfoWrapper(langtag, LOCALE_SPERCENT, buf, BUFLEN); |
13583 | 592 |
(*env)->ReleaseStringChars(env, jlangtag, langtag); |
593 |
||
594 |
if (got) { |
|
595 |
return buf[0]; |
|
596 |
} else { |
|
597 |
return percent; |
|
598 |
} |
|
599 |
} |
|
600 |
||
601 |
/* |
|
602 |
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl |
|
603 |
* Method: getPerMill |
|
604 |
* Signature: (Ljava/lang/String;C)C |
|
605 |
*/ |
|
606 |
JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getPerMill |
|
607 |
(JNIEnv *env, jclass cls, jstring jlangtag, jchar perMill) { |
|
608 |
WCHAR buf[BUFLEN]; |
|
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
609 |
const jchar *langtag; |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
610 |
int got; |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
611 |
langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
612 |
CHECK_NULL_RETURN(langtag, perMill); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
613 |
got = getLocaleInfoWrapper(langtag, LOCALE_SPERMILLE, buf, BUFLEN); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
614 |
|
13583 | 615 |
(*env)->ReleaseStringChars(env, jlangtag, langtag); |
616 |
||
617 |
if (got) { |
|
618 |
return buf[0]; |
|
619 |
} else { |
|
620 |
return perMill; |
|
621 |
} |
|
622 |
} |
|
623 |
||
624 |
/* |
|
625 |
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl |
|
626 |
* Method: getZeroDigit |
|
627 |
* Signature: (Ljava/lang/String;C)C |
|
628 |
*/ |
|
629 |
JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getZeroDigit |
|
630 |
(JNIEnv *env, jclass cls, jstring jlangtag, jchar zeroDigit) { |
|
631 |
WCHAR buf[BUFLEN]; |
|
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
632 |
const jchar *langtag; |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
633 |
int got; |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
634 |
langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
635 |
CHECK_NULL_RETURN(langtag, zeroDigit); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
636 |
got = getLocaleInfoWrapper(langtag, LOCALE_SNATIVEDIGITS, buf, BUFLEN); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
637 |
|
13583 | 638 |
(*env)->ReleaseStringChars(env, jlangtag, langtag); |
639 |
||
640 |
if (got) { |
|
641 |
return buf[0]; |
|
642 |
} else { |
|
643 |
return zeroDigit; |
|
644 |
} |
|
645 |
} |
|
646 |
||
647 |
/* |
|
648 |
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl |
|
649 |
* Method: getCalendarDataValue |
|
650 |
* Signature: (Ljava/lang/String;I)I |
|
651 |
*/ |
|
652 |
JNIEXPORT jint JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getCalendarDataValue |
|
653 |
(JNIEnv *env, jclass cls, jstring jlangtag, jint type) { |
|
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
654 |
DWORD num; |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
655 |
const jchar *langtag; |
13583 | 656 |
int got = 0; |
657 |
||
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
658 |
langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
659 |
CHECK_NULL_RETURN(langtag, -1); |
13583 | 660 |
switch (type) { |
661 |
case sun_util_locale_provider_HostLocaleProviderAdapterImpl_CD_FIRSTDAYOFWEEK: |
|
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
662 |
got = getLocaleInfoWrapper(langtag, |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
663 |
LOCALE_IFIRSTDAYOFWEEK | LOCALE_RETURN_NUMBER, |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
664 |
(LPWSTR)&num, sizeof(num)); |
13583 | 665 |
break; |
666 |
} |
|
667 |
||
668 |
(*env)->ReleaseStringChars(env, jlangtag, langtag); |
|
669 |
||
670 |
if (got) { |
|
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
671 |
return num; |
13583 | 672 |
} else { |
673 |
return -1; |
|
674 |
} |
|
675 |
} |
|
676 |
||
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
677 |
/* |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
678 |
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
679 |
* Method: getDisplayString |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
680 |
* Signature: (Ljava/lang/String;ILjava/lang/String;)Ljava/lang/String; |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
681 |
*/ |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
682 |
JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getDisplayString |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
683 |
(JNIEnv *env, jclass cls, jstring jlangtag, jint type, jstring jvalue) { |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
684 |
LCTYPE lcType; |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
685 |
jstring jStr; |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
686 |
const jchar * pjChar; |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
687 |
WCHAR buf[BUFLEN]; |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
688 |
int got = 0; |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
689 |
|
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
690 |
switch (type) { |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
691 |
case sun_util_locale_provider_HostLocaleProviderAdapterImpl_DN_CURRENCY_NAME: |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
692 |
lcType = LOCALE_SNATIVECURRNAME; |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
693 |
jStr = jlangtag; |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
694 |
break; |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
695 |
case sun_util_locale_provider_HostLocaleProviderAdapterImpl_DN_CURRENCY_SYMBOL: |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
696 |
lcType = LOCALE_SCURRENCY; |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
697 |
jStr = jlangtag; |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
698 |
break; |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
699 |
case sun_util_locale_provider_HostLocaleProviderAdapterImpl_DN_LOCALE_LANGUAGE: |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
700 |
lcType = LOCALE_SLOCALIZEDLANGUAGENAME; |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
701 |
jStr = jvalue; |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
702 |
break; |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
703 |
case sun_util_locale_provider_HostLocaleProviderAdapterImpl_DN_LOCALE_REGION: |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
704 |
lcType = LOCALE_SLOCALIZEDCOUNTRYNAME; |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
705 |
jStr = jvalue; |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
706 |
break; |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
707 |
default: |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
708 |
return NULL; |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
709 |
} |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
710 |
|
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
711 |
pjChar = (*env)->GetStringChars(env, jStr, JNI_FALSE); |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
712 |
CHECK_NULL_RETURN(pjChar, NULL); |
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
713 |
got = getLocaleInfoWrapper(pjChar, lcType, buf, BUFLEN); |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
714 |
(*env)->ReleaseStringChars(env, jStr, pjChar); |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
715 |
|
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
716 |
if (got) { |
24121
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
717 |
return (*env)->NewString(env, buf, (jsize)wcslen(buf)); |
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
718 |
} else { |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
719 |
return NULL; |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
720 |
} |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
721 |
} |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
722 |
|
13583 | 723 |
int getLocaleInfoWrapper(const jchar *langtag, LCTYPE type, LPWSTR data, int buflen) { |
724 |
if (pGetLocaleInfoEx) { |
|
16481
8e30386cc014
8008576: Calendar mismatch using Host LocaleProviderAdapter
naoto
parents:
14028
diff
changeset
|
725 |
if (wcscmp(L"und", (LPWSTR)langtag) == 0) { |
8e30386cc014
8008576: Calendar mismatch using Host LocaleProviderAdapter
naoto
parents:
14028
diff
changeset
|
726 |
// defaults to "en" |
8e30386cc014
8008576: Calendar mismatch using Host LocaleProviderAdapter
naoto
parents:
14028
diff
changeset
|
727 |
return pGetLocaleInfoEx(L"en", type, data, buflen); |
8e30386cc014
8008576: Calendar mismatch using Host LocaleProviderAdapter
naoto
parents:
14028
diff
changeset
|
728 |
} else { |
8e30386cc014
8008576: Calendar mismatch using Host LocaleProviderAdapter
naoto
parents:
14028
diff
changeset
|
729 |
return pGetLocaleInfoEx((LPWSTR)langtag, type, data, buflen); |
8e30386cc014
8008576: Calendar mismatch using Host LocaleProviderAdapter
naoto
parents:
14028
diff
changeset
|
730 |
} |
13583 | 731 |
} else { |
732 |
// If we ever wanted to support WinXP, we will need extra module from |
|
733 |
// MS... |
|
734 |
// return GetLocaleInfo(DownlevelLocaleNameToLCID(langtag, 0), type, data, buflen); |
|
735 |
return 0; |
|
736 |
} |
|
737 |
} |
|
738 |
||
739 |
int getCalendarInfoWrapper(const jchar *langtag, CALID id, LPCWSTR reserved, CALTYPE type, LPWSTR data, int buflen, LPDWORD val) { |
|
740 |
if (pGetCalendarInfoEx) { |
|
16481
8e30386cc014
8008576: Calendar mismatch using Host LocaleProviderAdapter
naoto
parents:
14028
diff
changeset
|
741 |
if (wcscmp(L"und", (LPWSTR)langtag) == 0) { |
8e30386cc014
8008576: Calendar mismatch using Host LocaleProviderAdapter
naoto
parents:
14028
diff
changeset
|
742 |
// defaults to "en" |
8e30386cc014
8008576: Calendar mismatch using Host LocaleProviderAdapter
naoto
parents:
14028
diff
changeset
|
743 |
return pGetCalendarInfoEx(L"en", id, reserved, type, data, buflen, val); |
8e30386cc014
8008576: Calendar mismatch using Host LocaleProviderAdapter
naoto
parents:
14028
diff
changeset
|
744 |
} else { |
8e30386cc014
8008576: Calendar mismatch using Host LocaleProviderAdapter
naoto
parents:
14028
diff
changeset
|
745 |
return pGetCalendarInfoEx((LPWSTR)langtag, id, reserved, type, data, buflen, val); |
8e30386cc014
8008576: Calendar mismatch using Host LocaleProviderAdapter
naoto
parents:
14028
diff
changeset
|
746 |
} |
13583 | 747 |
} else { |
748 |
// If we ever wanted to support WinXP, we will need extra module from |
|
749 |
// MS... |
|
750 |
// return GetCalendarInfo(DownlevelLocaleNameToLCID(langtag, 0), ...); |
|
751 |
return 0; |
|
752 |
} |
|
753 |
} |
|
754 |
||
755 |
jint getCalendarID(const jchar *langtag) { |
|
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
756 |
DWORD type; |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
757 |
int got = getLocaleInfoWrapper(langtag, |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
758 |
LOCALE_ICALENDARTYPE | LOCALE_RETURN_NUMBER, |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
759 |
(LPWSTR)&type, sizeof(type)); |
13583 | 760 |
|
761 |
if (got) { |
|
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
762 |
return type; |
13583 | 763 |
} else { |
764 |
return 0; |
|
765 |
} |
|
766 |
} |
|
767 |
||
768 |
void replaceCalendarArrayElems(JNIEnv *env, jstring jlangtag, jobjectArray jarray, CALTYPE* pCalTypes, int offset, int length) { |
|
769 |
WCHAR name[BUFLEN]; |
|
24121
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
770 |
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
771 |
int calid; |
24121
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
772 |
jstring tmp_string; |
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
773 |
|
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
774 |
CHECK_NULL(langtag); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
17169
diff
changeset
|
775 |
calid = getCalendarID(langtag); |
13583 | 776 |
|
777 |
if (calid != -1) { |
|
778 |
int i; |
|
779 |
for (i = 0; i < length; i++) { |
|
780 |
getCalendarInfoWrapper(langtag, calid, NULL, |
|
781 |
pCalTypes[i], name, BUFLEN, NULL); |
|
24121
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
782 |
tmp_string = (*env)->NewString(env, name, (jsize)wcslen(name)); |
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
783 |
if (tmp_string != NULL) { |
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
784 |
(*env)->SetObjectArrayElement(env, jarray, i + offset, tmp_string); |
0de1e14447a8
8035826: [parfait] JNI exception pending in src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
naoto
parents:
22939
diff
changeset
|
785 |
} |
13583 | 786 |
} |
787 |
} |
|
788 |
||
789 |
(*env)->ReleaseStringChars(env, jlangtag, langtag); |
|
790 |
} |
|
791 |
||
792 |
WCHAR * getNumberPattern(const jchar * langtag, const jint numberStyle) { |
|
793 |
WCHAR ret[BUFLEN]; |
|
794 |
WCHAR number[BUFLEN]; |
|
795 |
WCHAR fix[BUFLEN]; |
|
796 |
||
797 |
getFixPart(langtag, numberStyle, TRUE, TRUE, ret); // "+" |
|
798 |
getNumberPart(langtag, numberStyle, number); |
|
799 |
wcscat_s(ret, BUFLEN-wcslen(ret), number); // "+12.34" |
|
800 |
getFixPart(langtag, numberStyle, TRUE, FALSE, fix); |
|
801 |
wcscat_s(ret, BUFLEN-wcslen(ret), fix); // "+12.34$" |
|
802 |
wcscat_s(ret, BUFLEN-wcslen(ret), L";"); // "+12.34$;" |
|
803 |
getFixPart(langtag, numberStyle, FALSE, TRUE, fix); |
|
804 |
wcscat_s(ret, BUFLEN-wcslen(ret), fix); // "+12.34$;(" |
|
805 |
wcscat_s(ret, BUFLEN-wcslen(ret), number); // "+12.34$;(12.34" |
|
806 |
getFixPart(langtag, numberStyle, FALSE, FALSE, fix); |
|
807 |
wcscat_s(ret, BUFLEN-wcslen(ret), fix); // "+12.34$;(12.34$)" |
|
808 |
||
809 |
return _wcsdup(ret); |
|
810 |
} |
|
811 |
||
812 |
void getNumberPart(const jchar * langtag, const jint numberStyle, WCHAR * number) { |
|
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
813 |
DWORD digits = 0; |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
814 |
DWORD leadingZero = 0; |
13583 | 815 |
WCHAR grouping[BUFLEN]; |
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
816 |
int groupingLen; |
13583 | 817 |
WCHAR fractionPattern[BUFLEN]; |
818 |
WCHAR * integerPattern = number; |
|
819 |
WCHAR * pDest; |
|
820 |
||
821 |
// Get info from Windows |
|
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
822 |
switch (numberStyle) { |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
823 |
case sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_CURRENCY: |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
824 |
getLocaleInfoWrapper(langtag, |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
825 |
LOCALE_ICURRDIGITS | LOCALE_RETURN_NUMBER, |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
826 |
(LPWSTR)&digits, sizeof(digits)); |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
827 |
break; |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
828 |
|
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
829 |
case sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_INTEGER: |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
830 |
break; |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
831 |
|
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
832 |
case sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_NUMBER: |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
833 |
case sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_PERCENT: |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
834 |
default: |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
835 |
getLocaleInfoWrapper(langtag, |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
836 |
LOCALE_IDIGITS | LOCALE_RETURN_NUMBER, |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
837 |
(LPWSTR)&digits, sizeof(digits)); |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
838 |
break; |
13583 | 839 |
} |
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
840 |
|
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
841 |
getLocaleInfoWrapper(langtag, |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
842 |
LOCALE_ILZERO | LOCALE_RETURN_NUMBER, |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
843 |
(LPWSTR)&leadingZero, sizeof(leadingZero)); |
13583 | 844 |
groupingLen = getLocaleInfoWrapper(langtag, LOCALE_SGROUPING, grouping, BUFLEN); |
845 |
||
846 |
// fraction pattern |
|
847 |
if (digits > 0) { |
|
848 |
int i; |
|
849 |
for(i = digits; i > 0; i--) { |
|
850 |
fractionPattern[i] = L'0'; |
|
851 |
} |
|
852 |
fractionPattern[0] = L'.'; |
|
853 |
fractionPattern[digits+1] = L'\0'; |
|
854 |
} else { |
|
855 |
fractionPattern[0] = L'\0'; |
|
856 |
} |
|
857 |
||
858 |
// integer pattern |
|
859 |
pDest = integerPattern; |
|
860 |
if (groupingLen > 0) { |
|
861 |
int cur = groupingLen - 1;// subtracting null terminator |
|
862 |
while (--cur >= 0) { |
|
863 |
int repnum; |
|
864 |
||
865 |
if (grouping[cur] == L';') { |
|
866 |
continue; |
|
867 |
} |
|
868 |
||
869 |
repnum = grouping[cur] - 0x30; |
|
870 |
if (repnum > 0) { |
|
871 |
*pDest++ = L'#'; |
|
872 |
*pDest++ = L','; |
|
873 |
while(--repnum > 0) { |
|
874 |
*pDest++ = L'#'; |
|
875 |
} |
|
876 |
} |
|
877 |
} |
|
878 |
} |
|
879 |
||
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
880 |
if (leadingZero != 0) { |
13583 | 881 |
*pDest++ = L'0'; |
882 |
} else { |
|
883 |
*pDest++ = L'#'; |
|
884 |
} |
|
885 |
*pDest = L'\0'; |
|
886 |
||
887 |
wcscat_s(integerPattern, BUFLEN, fractionPattern); |
|
888 |
} |
|
889 |
||
890 |
void getFixPart(const jchar * langtag, const jint numberStyle, BOOL positive, BOOL prefix, WCHAR * ret) { |
|
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
891 |
DWORD pattern = 0; |
13583 | 892 |
int style = numberStyle; |
893 |
int got = 0; |
|
894 |
||
895 |
if (positive) { |
|
896 |
if (style == sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_CURRENCY) { |
|
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
897 |
got = getLocaleInfoWrapper(langtag, |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
898 |
LOCALE_ICURRENCY | LOCALE_RETURN_NUMBER, |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
899 |
(LPWSTR)&pattern, sizeof(pattern)); |
13583 | 900 |
} else if (style == sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_PERCENT) { |
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
901 |
got = getLocaleInfoWrapper(langtag, |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
902 |
LOCALE_IPOSITIVEPERCENT | LOCALE_RETURN_NUMBER, |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
903 |
(LPWSTR)&pattern, sizeof(pattern)); |
13583 | 904 |
} |
905 |
} else { |
|
906 |
if (style == sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_CURRENCY) { |
|
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
907 |
got = getLocaleInfoWrapper(langtag, |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
908 |
LOCALE_INEGCURR | LOCALE_RETURN_NUMBER, |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
909 |
(LPWSTR)&pattern, sizeof(pattern)); |
13583 | 910 |
} else if (style == sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_PERCENT) { |
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
911 |
got = getLocaleInfoWrapper(langtag, |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
912 |
LOCALE_INEGATIVEPERCENT | LOCALE_RETURN_NUMBER, |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
913 |
(LPWSTR)&pattern, sizeof(pattern)); |
13583 | 914 |
} else { |
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
915 |
got = getLocaleInfoWrapper(langtag, |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
916 |
LOCALE_INEGNUMBER | LOCALE_RETURN_NUMBER, |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
16481
diff
changeset
|
917 |
(LPWSTR)&pattern, sizeof(pattern)); |
13583 | 918 |
} |
919 |
} |
|
920 |
||
921 |
if (numberStyle == sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_INTEGER) { |
|
922 |
style = sun_util_locale_provider_HostLocaleProviderAdapterImpl_NF_NUMBER; |
|
923 |
} |
|
924 |
||
925 |
wcscpy(ret, fixes[!prefix][!positive][style][pattern]); |
|
926 |
} |