author | naoto |
Tue, 12 Dec 2017 10:21:58 -0800 | |
changeset 48251 | 57148c79bd75 |
parent 47216 | 71c04702a3d5 |
child 51276 | 04183bf08bff |
permissions | -rw-r--r-- |
13583 | 1 |
/* |
48251
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2012, 2017, 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 |
package sun.util.locale.provider; |
|
27 |
||
14502
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
28 |
import static java.util.Calendar.*; |
13583 | 29 |
import java.util.Locale; |
30 |
import java.util.Map; |
|
31 |
import java.util.spi.CalendarDataProvider; |
|
14502
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
32 |
import java.util.spi.CalendarNameProvider; |
13583 | 33 |
|
34 |
/** |
|
35 |
* {@code CalendarDataUtility} is a utility class for calling the |
|
36 |
* {@link CalendarDataProvider} methods. |
|
37 |
* |
|
38 |
* @author Masayoshi Okutsu |
|
39 |
* @author Naoto Sato |
|
40 |
*/ |
|
41 |
public class CalendarDataUtility { |
|
32649
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
25859
diff
changeset
|
42 |
public static final String FIRST_DAY_OF_WEEK = "firstDayOfWeek"; |
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
25859
diff
changeset
|
43 |
public static final String MINIMAL_DAYS_IN_FIRST_WEEK = "minimalDaysInFirstWeek"; |
13583 | 44 |
|
45 |
// No instantiation |
|
46 |
private CalendarDataUtility() { |
|
47 |
} |
|
48 |
||
14502
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
49 |
public static int retrieveFirstDayOfWeek(Locale locale) { |
48251
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
50 |
// Look for the Unicode Extension in the locale parameter |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
51 |
if (locale.hasExtensions()) { |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
52 |
String fw = locale.getUnicodeLocaleType("fw"); |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
53 |
if (fw != null) { |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
54 |
switch (fw.toLowerCase(Locale.ROOT)) { |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
55 |
case "mon": |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
56 |
return MONDAY; |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
57 |
case "tue": |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
58 |
return TUESDAY; |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
59 |
case "wed": |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
60 |
return WEDNESDAY; |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
61 |
case "thu": |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
62 |
return THURSDAY; |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
63 |
case "fri": |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
64 |
return FRIDAY; |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
65 |
case "sat": |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
66 |
return SATURDAY; |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
67 |
case "sun": |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
68 |
return SUNDAY; |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
69 |
} |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
70 |
} |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
71 |
} |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
72 |
|
14502
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
73 |
LocaleServiceProviderPool pool = |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
74 |
LocaleServiceProviderPool.getPool(CalendarDataProvider.class); |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
75 |
Integer value = pool.getLocalizedObject(CalendarWeekParameterGetter.INSTANCE, |
48251
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
76 |
findRegionOverride(locale), |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
77 |
true, FIRST_DAY_OF_WEEK); |
14502
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
78 |
return (value != null && (value >= SUNDAY && value <= SATURDAY)) ? value : SUNDAY; |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
79 |
} |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
80 |
|
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
81 |
public static int retrieveMinimalDaysInFirstWeek(Locale locale) { |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
82 |
LocaleServiceProviderPool pool = |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
83 |
LocaleServiceProviderPool.getPool(CalendarDataProvider.class); |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
84 |
Integer value = pool.getLocalizedObject(CalendarWeekParameterGetter.INSTANCE, |
48251
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
85 |
findRegionOverride(locale), |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
86 |
true, MINIMAL_DAYS_IN_FIRST_WEEK); |
14502
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
87 |
return (value != null && (value >= 1 && value <= 7)) ? value : 1; |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
88 |
} |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
89 |
|
13583 | 90 |
public static String retrieveFieldValueName(String id, int field, int value, int style, Locale locale) { |
91 |
LocaleServiceProviderPool pool = |
|
14502
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
92 |
LocaleServiceProviderPool.getPool(CalendarNameProvider.class); |
15281
dd43cb9be0e1
8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
14765
diff
changeset
|
93 |
return pool.getLocalizedObject(CalendarFieldValueNameGetter.INSTANCE, locale, normalizeCalendarType(id), |
15658 | 94 |
field, value, style, false); |
95 |
} |
|
96 |
||
16852 | 97 |
public static String retrieveJavaTimeFieldValueName(String id, int field, int value, int style, Locale locale) { |
15658 | 98 |
LocaleServiceProviderPool pool = |
99 |
LocaleServiceProviderPool.getPool(CalendarNameProvider.class); |
|
100 |
String name; |
|
101 |
name = pool.getLocalizedObject(CalendarFieldValueNameGetter.INSTANCE, locale, normalizeCalendarType(id), |
|
102 |
field, value, style, true); |
|
103 |
if (name == null) { |
|
104 |
name = pool.getLocalizedObject(CalendarFieldValueNameGetter.INSTANCE, locale, normalizeCalendarType(id), |
|
105 |
field, value, style, false); |
|
106 |
} |
|
107 |
return name; |
|
13583 | 108 |
} |
109 |
||
110 |
public static Map<String, Integer> retrieveFieldValueNames(String id, int field, int style, Locale locale) { |
|
111 |
LocaleServiceProviderPool pool = |
|
14502
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
112 |
LocaleServiceProviderPool.getPool(CalendarNameProvider.class); |
15281
dd43cb9be0e1
8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
14765
diff
changeset
|
113 |
return pool.getLocalizedObject(CalendarFieldValueNamesMapGetter.INSTANCE, locale, |
15658 | 114 |
normalizeCalendarType(id), field, style, false); |
15281
dd43cb9be0e1
8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
14765
diff
changeset
|
115 |
} |
dd43cb9be0e1
8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
14765
diff
changeset
|
116 |
|
16852 | 117 |
public static Map<String, Integer> retrieveJavaTimeFieldValueNames(String id, int field, int style, Locale locale) { |
15658 | 118 |
LocaleServiceProviderPool pool = |
119 |
LocaleServiceProviderPool.getPool(CalendarNameProvider.class); |
|
120 |
Map<String, Integer> map; |
|
121 |
map = pool.getLocalizedObject(CalendarFieldValueNamesMapGetter.INSTANCE, locale, |
|
122 |
normalizeCalendarType(id), field, style, true); |
|
123 |
if (map == null) { |
|
124 |
map = pool.getLocalizedObject(CalendarFieldValueNamesMapGetter.INSTANCE, locale, |
|
125 |
normalizeCalendarType(id), field, style, false); |
|
126 |
} |
|
127 |
return map; |
|
128 |
} |
|
129 |
||
48251
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
130 |
/** |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
131 |
* Utility to look for a region override extension. |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
132 |
* If no region override is found, returns the original locale. |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
133 |
*/ |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
134 |
public static Locale findRegionOverride(Locale l) { |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
135 |
String rg = l.getUnicodeLocaleType("rg"); |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
136 |
Locale override = l; |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
137 |
|
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
138 |
if (rg != null && rg.length() == 6) { |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
139 |
// UN M.49 code should not be allowed here |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
140 |
// cannot use regex here, as it could be a recursive call |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
141 |
rg = rg.toUpperCase(Locale.ROOT); |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
142 |
if (rg.charAt(0) >= 0x0041 && |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
143 |
rg.charAt(0) <= 0x005A && |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
144 |
rg.charAt(1) >= 0x0041 && |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
145 |
rg.charAt(1) <= 0x005A && |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
146 |
rg.substring(2).equals("ZZZZ")) { |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
147 |
override = new Locale.Builder().setLocale(l) |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
148 |
.setRegion(rg.substring(0, 2)) |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
149 |
.build(); |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
150 |
} |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
151 |
} |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
152 |
|
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
153 |
return override; |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
154 |
} |
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
155 |
|
15658 | 156 |
static String normalizeCalendarType(String requestID) { |
15281
dd43cb9be0e1
8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
14765
diff
changeset
|
157 |
String type; |
dd43cb9be0e1
8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
14765
diff
changeset
|
158 |
if (requestID.equals("gregorian") || requestID.equals("iso8601")) { |
dd43cb9be0e1
8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
14765
diff
changeset
|
159 |
type = "gregory"; |
dd43cb9be0e1
8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
14765
diff
changeset
|
160 |
} else if (requestID.startsWith("islamic")) { |
dd43cb9be0e1
8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
14765
diff
changeset
|
161 |
type = "islamic"; |
dd43cb9be0e1
8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
14765
diff
changeset
|
162 |
} else { |
dd43cb9be0e1
8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
14765
diff
changeset
|
163 |
type = requestID; |
dd43cb9be0e1
8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
14765
diff
changeset
|
164 |
} |
dd43cb9be0e1
8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
14765
diff
changeset
|
165 |
return type; |
13583 | 166 |
} |
167 |
||
168 |
/** |
|
169 |
* Obtains a localized field value string from a CalendarDataProvider |
|
170 |
* implementation. |
|
171 |
*/ |
|
172 |
private static class CalendarFieldValueNameGetter |
|
14502
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
173 |
implements LocaleServiceProviderPool.LocalizedObjectGetter<CalendarNameProvider, |
13583 | 174 |
String> { |
175 |
private static final CalendarFieldValueNameGetter INSTANCE = |
|
176 |
new CalendarFieldValueNameGetter(); |
|
177 |
||
178 |
@Override |
|
14502
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
179 |
public String getObject(CalendarNameProvider calendarNameProvider, |
13583 | 180 |
Locale locale, |
181 |
String requestID, // calendarType |
|
182 |
Object... params) { |
|
15658 | 183 |
assert params.length == 4; |
13583 | 184 |
int field = (int) params[0]; |
185 |
int value = (int) params[1]; |
|
186 |
int style = (int) params[2]; |
|
16852 | 187 |
boolean javatime = (boolean) params[3]; |
15658 | 188 |
|
16852 | 189 |
// If javatime is true, resources from CLDR have precedence over JRE |
15658 | 190 |
// native resources. |
16852 | 191 |
if (javatime && calendarNameProvider instanceof CalendarNameProviderImpl) { |
15658 | 192 |
String name; |
193 |
name = ((CalendarNameProviderImpl)calendarNameProvider) |
|
16852 | 194 |
.getJavaTimeDisplayName(requestID, field, value, style, locale); |
15658 | 195 |
return name; |
196 |
} |
|
14502
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
197 |
return calendarNameProvider.getDisplayName(requestID, field, value, style, locale); |
13583 | 198 |
} |
199 |
} |
|
200 |
||
201 |
/** |
|
202 |
* Obtains a localized field-value pairs from a CalendarDataProvider |
|
203 |
* implementation. |
|
204 |
*/ |
|
205 |
private static class CalendarFieldValueNamesMapGetter |
|
14502
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
206 |
implements LocaleServiceProviderPool.LocalizedObjectGetter<CalendarNameProvider, |
13583 | 207 |
Map<String, Integer>> { |
208 |
private static final CalendarFieldValueNamesMapGetter INSTANCE = |
|
209 |
new CalendarFieldValueNamesMapGetter(); |
|
210 |
||
211 |
@Override |
|
14502
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
212 |
public Map<String, Integer> getObject(CalendarNameProvider calendarNameProvider, |
13583 | 213 |
Locale locale, |
214 |
String requestID, // calendarType |
|
215 |
Object... params) { |
|
15658 | 216 |
assert params.length == 3; |
13583 | 217 |
int field = (int) params[0]; |
218 |
int style = (int) params[1]; |
|
16852 | 219 |
boolean javatime = (boolean) params[2]; |
15658 | 220 |
|
16852 | 221 |
// If javatime is true, resources from CLDR have precedence over JRE |
15658 | 222 |
// native resources. |
16852 | 223 |
if (javatime && calendarNameProvider instanceof CalendarNameProviderImpl) { |
15658 | 224 |
Map<String, Integer> map; |
225 |
map = ((CalendarNameProviderImpl)calendarNameProvider) |
|
16852 | 226 |
.getJavaTimeDisplayNames(requestID, field, style, locale); |
15658 | 227 |
return map; |
228 |
} |
|
14502
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
229 |
return calendarNameProvider.getDisplayNames(requestID, field, style, locale); |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
230 |
} |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
231 |
} |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
232 |
|
48251
57148c79bd75
8176841: Additional Unicode Language-Tag Extensions
naoto
parents:
47216
diff
changeset
|
233 |
private static class CalendarWeekParameterGetter |
14502
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
234 |
implements LocaleServiceProviderPool.LocalizedObjectGetter<CalendarDataProvider, |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
235 |
Integer> { |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
236 |
private static final CalendarWeekParameterGetter INSTANCE = |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
237 |
new CalendarWeekParameterGetter(); |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
238 |
|
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
239 |
@Override |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
240 |
public Integer getObject(CalendarDataProvider calendarDataProvider, |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
241 |
Locale locale, |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
242 |
String requestID, // resource key |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
243 |
Object... params) { |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
244 |
assert params.length == 0; |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
245 |
int value; |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
246 |
switch (requestID) { |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
247 |
case FIRST_DAY_OF_WEEK: |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
248 |
value = calendarDataProvider.getFirstDayOfWeek(locale); |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
249 |
break; |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
250 |
case MINIMAL_DAYS_IN_FIRST_WEEK: |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
251 |
value = calendarDataProvider.getMinimalDaysInFirstWeek(locale); |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
252 |
break; |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
253 |
default: |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
254 |
throw new InternalError("invalid requestID: " + requestID); |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
255 |
} |
d63fed06fed4
8000986: Split java.util.spi.CalendarDataProvider into week parameters and field names portions
okutsu
parents:
13583
diff
changeset
|
256 |
return (value != 0) ? value : null; |
13583 | 257 |
} |
258 |
} |
|
259 |
} |