blob: fc01788df8706db8416796f7b9295df81240d5b1 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright (c) 2007 Sun Microsystems, Inc. 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.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 */
23/*
24 *
25 */
26
27package com.bar;
28
29import java.util.*;
30import java.util.spi.*;
31
32import com.foobar.Utils;
33
34public class TimeZoneNameProviderImpl extends TimeZoneNameProvider {
35 static Locale[] avail = {new Locale("ja", "JP", "osaka"),
36 new Locale("ja", "JP", "kyoto"),
37 new Locale("xx"),
38 Locale.JAPAN};
39
40 static String[][] zoneOsaka = {
41 {"GMT",
42 "\u30b0_\u30ea_\u30cb_\u30c3_\u30b8_\u6a19_\u6e96_\u6642_\u3084_\u3002",
43 "G_M_T_\u3084_\u3002",
44 "\u30b0_\u30ea_\u30cb_\u30c3_\u30b8_\u6a19_\u6e96_\u6642_\u3084_\u3002",
45 "G_M_T_\u3084_\u3002"},
46 {"JST",
47 "\u3084_\u307e_\u3068_\u6a19_\u6e96_\u6642_\u3084_\u3002",
48 "J_S_T_\u3084_\u3002",
49 "\u3084_\u307e_\u3068_\u6a19_\u6e96_\u6642_\u3084_\u3002",
50 "J_S_T_\u3084_\u3002"},
51 {"America/Los_Angeles",
52 "\u592a_\u5e73_\u6d0b_\u6a19_\u6e96_\u6642_\u3084_\u3002",
53 "P_S_T_\u3084_\u3002",
54 "\u592a_\u5e73_\u6d0b_\u590f_\u6642_\u9593_\u3084_\u3002",
55 "P_D_T_\u3084_\u3002"},
56 {"SystemV/PST8",
57 "\u592a_\u5e73_\u6d0b_\u6a19_\u6e96_\u6642_\u3084_\u3002",
58 "P_S_T_\u3084_\u3002",
59 "\u592a_\u5e73_\u6d0b_\u590f_\u6642_\u9593_\u3084_\u3002",
60 "P_D_T_\u3084_\u3002"},
61 {"SystemV/PST8PDT",
62 "\u592a_\u5e73_\u6d0b_\u6a19_\u6e96_\u6642_\u3084_\u3002",
63 "P_S_T_\u3084_\u3002",
64 "\u592a_\u5e73_\u6d0b_\u590f_\u6642_\u9593_\u3084_\u3002",
65 "P_D_T_\u3084_\u3002"},
66 {"PST8PDT",
67 "\u592a_\u5e73_\u6d0b_\u6a19_\u6e96_\u6642_\u3084_\u3002",
68 "P_S_T_\u3084_\u3002",
69 "\u592a_\u5e73_\u6d0b_\u590f_\u6642_\u9593_\u3084_\u3002",
70 "P_D_T_\u3084_\u3002"},
71 };
72
73 static String[][] zoneKyoto = {
74 {"GMT",
75 "\u30b0_\u30ea_\u30cb_\u30c3_\u30b8_\u6a19_\u6e96_\u6642_\u3069_\u3059_\u3002",
76 "G_M_T_\u3069_\u3059_\u3002",
77 "\u30b0_\u30ea_\u30cb_\u30c3_\u30b8_\u6a19_\u6e96_\u6642_\u3069_\u3059_\u3002",
78 "G_M_T_\u3069_\u3059_\u3002"},
79 {"America/Los_Angeles",
80 "\u592a_\u5e73_\u6d0b_\u6a19_\u6e96_\u6642_\u3069_\u3059_\u3002",
81 "P_S_T_\u3069_\u3059_\u3002",
82 "\u592a_\u5e73_\u6d0b_\u590f_\u6642_\u9593_\u3069_\u3059_\u3002",
83 "P_D_T_\u3069_\u3059_\u3002"},
84 {"SystemV/PST8",
85 "\u592a_\u5e73_\u6d0b_\u6a19_\u6e96_\u6642_\u3069_\u3059_\u3002",
86 "P_S_T_\u3069_\u3059_\u3002",
87 "\u592a_\u5e73_\u6d0b_\u590f_\u6642_\u9593_\u3069_\u3059_\u3002",
88 "P_D_T_\u3069_\u3059_\u3002"},
89 {"SystemV/PST8PDT",
90 "\u592a_\u5e73_\u6d0b_\u6a19_\u6e96_\u6642_\u3069_\u3059_\u3002",
91 "P_S_T_\u3069_\u3059_\u3002",
92 "\u592a_\u5e73_\u6d0b_\u590f_\u6642_\u9593_\u3069_\u3059_\u3002",
93 "P_D_T_\u3069_\u3059_\u3002"},
94 {"PST8PDT",
95 "\u592a_\u5e73_\u6d0b_\u6a19_\u6e96_\u6642_\u3069_\u3059_\u3002",
96 "P_S_T_\u3069_\u3059_\u3002",
97 "\u592a_\u5e73_\u6d0b_\u590f_\u6642_\u9593_\u3069_\u3059_\u3002",
98 "P_D_T_\u3069_\u3059_\u3002"},
99 };
100
101 static String[][] zoneXX = {
102 {"GMT",
103 "\u30b0_\u30ea_\u30cb_\u30c3_\u30b8_\u6a19_\u6e96_\u6642\u3070\u3064\u3070\u3064\u3002",
104 "G_M_T_\u3070\u3064\u3070\u3064\u3002",
105 "\u30b0_\u30ea_\u30cb_\u30c3_\u30b8_\u6a19_\u6e96_\u6642\u3070\u3064\u3070\u3064\u3002",
106 "G_M_T_\u3070\u3064\u3070\u3064\u3002"},
107 {"America/Los_Angeles",
108 "\u592a_\u5e73_\u6d0b_\u6a19_\u6e96_\u6642_\u3070\u3064\u3070\u3064\u3002",
109 "P_S_T_\u3070\u3064\u3070\u3064\u3002",
110 "\u592a_\u5e73_\u6d0b_\u590f_\u6642_\u9593_\u3070\u3064\u3070\u3064\u3002",
111 "P_D_T_\u3070\u3064\u3070\u3064\u3002"}};
112
113 static String[][] zoneJaJP = {
114 {"GMT",
115 "\u30b0_\u30ea_\u30cb_\u30c3_\u30b8_\u6a19_\u6e96_\u6642_\u3067_\u3059_\u3002",
116 "G_M_T_\u3067_\u3059_\u3002",
117 "\u30b0_\u30ea_\u30cb_\u30c3_\u30b8_\u6a19_\u6e96_\u6642_\u3067_\u3059_\u3002",
118 "G_M_T_\u3067_\u3059_\u3002"},
119 {"America/Los_Angeles",
120 "\u30b0_\u30ea_\u30cb_\u30c3_\u30b8_\u6a19_\u6e96_\u6642_\u3067_\u3059_\u3002",
121 "P_S_T_\u3067_\u3059_\u3002",
122 "\u592a_\u5e73_\u6d0b_\u590f_\u6642_\u9593_\u3067_\u3059_\u3002",
123 "P_D_T_\u3067_\u3059_\u3002"}};
124
125 static String[][][] names = {zoneOsaka, zoneKyoto, zoneXX, zoneJaJP};
126
127 public Locale[] getAvailableLocales() {
128 return avail;
129 }
130
131 public String getDisplayName(String id, boolean dst, int style, Locale language) {
132 if (!Utils.supportsLocale(Arrays.asList(avail), language)) {
133 throw new IllegalArgumentException("locale is not one of available locales: "+language);
134 }
135
136 for (int i = 0; i < avail.length; i ++) {
137 if (Utils.supportsLocale(avail[i], language)) {
138 String[][] namesForALocale = names[i];
139 for (int j = 0; j < namesForALocale.length; j++) {
140 String[] array = namesForALocale[j];
141 if (id.equals(array[0])) {
142 String ret = array[(style==TimeZone.LONG?0:1)+(dst?2:0)+1];
143 return ret;
144 }
145 }
146 }
147 }
148 return null;
149 }
150}