Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/util/PluggableLocale/providersrc/TimeZoneNameProviderImpl.java
47311 views
/*1* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/22/*23*24*/2526package com.bar;2728import java.util.*;29import java.util.spi.*;3031import com.foobar.Utils;3233public class TimeZoneNameProviderImpl extends TimeZoneNameProvider {34static Locale[] avail = {new Locale("ja", "JP", "osaka"),35new Locale("ja", "JP", "kyoto"),36new Locale("xx"),37Locale.JAPAN};3839static String[][] zoneOsaka = {40{"GMT",41"\u30b0_\u30ea_\u30cb_\u30c3_\u30b8_\u6a19_\u6e96_\u6642_\u3084_\u3002",42"G_M_T_\u3084_\u3002",43"\u30b0_\u30ea_\u30cb_\u30c3_\u30b8_\u6a19_\u6e96_\u6642_\u3084_\u3002",44"G_M_T_\u3084_\u3002"},45{"JST",46"\u3084_\u307e_\u3068_\u6a19_\u6e96_\u6642_\u3084_\u3002",47"J_S_T_\u3084_\u3002",48"\u3084_\u307e_\u3068_\u6a19_\u6e96_\u6642_\u3084_\u3002",49"J_S_T_\u3084_\u3002"},50{"America/Los_Angeles",51"\u592a_\u5e73_\u6d0b_\u6a19_\u6e96_\u6642_\u3084_\u3002",52"P_S_T_\u3084_\u3002",53"\u592a_\u5e73_\u6d0b_\u590f_\u6642_\u9593_\u3084_\u3002",54"P_D_T_\u3084_\u3002"},55{"SystemV/PST8",56"\u592a_\u5e73_\u6d0b_\u6a19_\u6e96_\u6642_\u3084_\u3002",57"P_S_T_\u3084_\u3002",58"\u592a_\u5e73_\u6d0b_\u590f_\u6642_\u9593_\u3084_\u3002",59"P_D_T_\u3084_\u3002"},60{"SystemV/PST8PDT",61"\u592a_\u5e73_\u6d0b_\u6a19_\u6e96_\u6642_\u3084_\u3002",62"P_S_T_\u3084_\u3002",63"\u592a_\u5e73_\u6d0b_\u590f_\u6642_\u9593_\u3084_\u3002",64"P_D_T_\u3084_\u3002"},65{"PST8PDT",66"\u592a_\u5e73_\u6d0b_\u6a19_\u6e96_\u6642_\u3084_\u3002",67"P_S_T_\u3084_\u3002",68"\u592a_\u5e73_\u6d0b_\u590f_\u6642_\u9593_\u3084_\u3002",69"P_D_T_\u3084_\u3002"},70};7172static String[][] zoneKyoto = {73{"GMT",74"\u30b0_\u30ea_\u30cb_\u30c3_\u30b8_\u6a19_\u6e96_\u6642_\u3069_\u3059_\u3002",75"G_M_T_\u3069_\u3059_\u3002",76"\u30b0_\u30ea_\u30cb_\u30c3_\u30b8_\u6a19_\u6e96_\u6642_\u3069_\u3059_\u3002",77"G_M_T_\u3069_\u3059_\u3002"},78{"America/Los_Angeles",79"\u592a_\u5e73_\u6d0b_\u6a19_\u6e96_\u6642_\u3069_\u3059_\u3002",80"P_S_T_\u3069_\u3059_\u3002",81"\u592a_\u5e73_\u6d0b_\u590f_\u6642_\u9593_\u3069_\u3059_\u3002",82"P_D_T_\u3069_\u3059_\u3002"},83{"SystemV/PST8",84"\u592a_\u5e73_\u6d0b_\u6a19_\u6e96_\u6642_\u3069_\u3059_\u3002",85"P_S_T_\u3069_\u3059_\u3002",86"\u592a_\u5e73_\u6d0b_\u590f_\u6642_\u9593_\u3069_\u3059_\u3002",87"P_D_T_\u3069_\u3059_\u3002"},88{"SystemV/PST8PDT",89"\u592a_\u5e73_\u6d0b_\u6a19_\u6e96_\u6642_\u3069_\u3059_\u3002",90"P_S_T_\u3069_\u3059_\u3002",91"\u592a_\u5e73_\u6d0b_\u590f_\u6642_\u9593_\u3069_\u3059_\u3002",92"P_D_T_\u3069_\u3059_\u3002"},93{"PST8PDT",94"\u592a_\u5e73_\u6d0b_\u6a19_\u6e96_\u6642_\u3069_\u3059_\u3002",95"P_S_T_\u3069_\u3059_\u3002",96"\u592a_\u5e73_\u6d0b_\u590f_\u6642_\u9593_\u3069_\u3059_\u3002",97"P_D_T_\u3069_\u3059_\u3002"},98};99100static String[][] zoneXX = {101{"GMT",102"\u30b0_\u30ea_\u30cb_\u30c3_\u30b8_\u6a19_\u6e96_\u6642\u3070\u3064\u3070\u3064\u3002",103"G_M_T_\u3070\u3064\u3070\u3064\u3002",104"\u30b0_\u30ea_\u30cb_\u30c3_\u30b8_\u6a19_\u6e96_\u6642\u3070\u3064\u3070\u3064\u3002",105"G_M_T_\u3070\u3064\u3070\u3064\u3002"},106{"America/Los_Angeles",107"\u592a_\u5e73_\u6d0b_\u6a19_\u6e96_\u6642_\u3070\u3064\u3070\u3064\u3002",108"P_S_T_\u3070\u3064\u3070\u3064\u3002",109"\u592a_\u5e73_\u6d0b_\u590f_\u6642_\u9593_\u3070\u3064\u3070\u3064\u3002",110"P_D_T_\u3070\u3064\u3070\u3064\u3002"}};111112static String[][] zoneJaJP = {113{"GMT",114"\u30b0_\u30ea_\u30cb_\u30c3_\u30b8_\u6a19_\u6e96_\u6642_\u3067_\u3059_\u3002",115"G_M_T_\u3067_\u3059_\u3002",116"\u30b0_\u30ea_\u30cb_\u30c3_\u30b8_\u6a19_\u6e96_\u6642_\u3067_\u3059_\u3002",117"G_M_T_\u3067_\u3059_\u3002"},118{"America/Los_Angeles",119"\u30b0_\u30ea_\u30cb_\u30c3_\u30b8_\u6a19_\u6e96_\u6642_\u3067_\u3059_\u3002",120"P_S_T_\u3067_\u3059_\u3002",121"\u592a_\u5e73_\u6d0b_\u590f_\u6642_\u9593_\u3067_\u3059_\u3002",122"P_D_T_\u3067_\u3059_\u3002"}};123124static String[][][] names = {zoneOsaka, zoneKyoto, zoneXX, zoneJaJP};125126public Locale[] getAvailableLocales() {127return avail;128}129130public String getDisplayName(String id, boolean dst, int style, Locale language) {131if (!Utils.supportsLocale(Arrays.asList(avail), language)) {132throw new IllegalArgumentException("locale is not one of available locales: "+language);133}134135for (int i = 0; i < avail.length; i ++) {136if (Utils.supportsLocale(avail[i], language)) {137String[][] namesForALocale = names[i];138for (int j = 0; j < namesForALocale.length; j++) {139String[] array = namesForALocale[j];140if (id.equals(array[0])) {141String ret = array[(style==TimeZone.LONG?0:1)+(dst?2:0)+1];142return ret;143}144}145}146}147return null;148}149}150151152