1 /*
2 * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
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
222 if (names != null) {
223 return names;
224 }
225 names = examineAliases(tznp, locale, alias, aliases);
226 if (names != null) {
227 return names;
228 }
229 }
230 }
231 }
232
233 return null;
234 }
235
236 private static String[] buildZoneStrings(TimeZoneNameProvider tznp,
237 Locale locale, String id) {
238 String[] names = new String[5];
239
240 for (int i = 1; i <= 4; i ++) {
241 names[i] = tznp.getDisplayName(id, i>=3, i%2, locale);
242 if (i >= 3 && names[i] == null) {
243 names[i] = names[i-2];
244 }
245 }
246
247 if (names[1] == null) {
248 // this id seems not localized by this provider
249 names = null;
250 }
251
252 return names;
253 }
254 }
255
256 private static class TimeZoneNameGetter
257 implements LocaleServiceProviderPool.LocalizedObjectGetter<TimeZoneNameProvider,
258 String> {
259 private static final TimeZoneNameGetter INSTANCE =
260 new TimeZoneNameGetter();
261
262 @Override
263 public String getObject(TimeZoneNameProvider timeZoneNameProvider,
264 Locale locale,
265 String requestID,
266 Object... params) {
267 assert params.length == 2;
268 int style = (int) params[0];
269 String tzid = (String) params[1];
270 String value = getName(timeZoneNameProvider, locale, requestID, style, tzid);
|
1 /*
2 * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
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
222 if (names != null) {
223 return names;
224 }
225 names = examineAliases(tznp, locale, alias, aliases);
226 if (names != null) {
227 return names;
228 }
229 }
230 }
231 }
232
233 return null;
234 }
235
236 private static String[] buildZoneStrings(TimeZoneNameProvider tznp,
237 Locale locale, String id) {
238 String[] names = new String[5];
239
240 for (int i = 1; i <= 4; i ++) {
241 names[i] = tznp.getDisplayName(id, i>=3, i%2, locale);
242
243 if (names[i] == null) {
244 switch (i) {
245 case 1:
246 // this id seems not localized by this provider
247 return null;
248 case 2:
249 case 4:
250 // If the display name for SHORT is not supplied,
251 // copy the LONG name.
252 names[i] = names[i-1];
253 break;
254 case 3:
255 // If the display name for DST is not supplied,
256 // copy the "standard" name.
257 names[3] = names[1];
258 break;
259 }
260 }
261 }
262
263 return names;
264 }
265 }
266
267 private static class TimeZoneNameGetter
268 implements LocaleServiceProviderPool.LocalizedObjectGetter<TimeZoneNameProvider,
269 String> {
270 private static final TimeZoneNameGetter INSTANCE =
271 new TimeZoneNameGetter();
272
273 @Override
274 public String getObject(TimeZoneNameProvider timeZoneNameProvider,
275 Locale locale,
276 String requestID,
277 Object... params) {
278 assert params.length == 2;
279 int style = (int) params[0];
280 String tzid = (String) params[1];
281 String value = getName(timeZoneNameProvider, locale, requestID, style, tzid);
|