1 /*
2 * Copyright (c) 2012, 2015, 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
554 @Override
555 public String getDisplayScript(String scriptCode, Locale locale) {
556 LocaleNameProvider lnp = getImpl(locale);
557 assert lnp != null;
558 return lnp.getDisplayScript(scriptCode, locale);
559 }
560
561 @Override
562 public String getDisplayCountry(String countryCode, Locale locale) {
563 LocaleNameProvider lnp = getImpl(locale);
564 assert lnp != null;
565 return lnp.getDisplayCountry(countryCode, locale);
566 }
567
568 @Override
569 public String getDisplayVariant(String variant, Locale locale) {
570 LocaleNameProvider lnp = getImpl(locale);
571 assert lnp != null;
572 return lnp.getDisplayVariant(variant, locale);
573 }
574 }
575
576 static class TimeZoneNameProviderDelegate extends TimeZoneNameProvider
577 implements Delegate<TimeZoneNameProvider> {
578 private final ConcurrentMap<Locale, TimeZoneNameProvider> map = new ConcurrentHashMap<>();
579
580 @Override
581 public void addImpl(TimeZoneNameProvider impl) {
582 for (Locale l : impl.getAvailableLocales()) {
583 map.putIfAbsent(l, impl);
584 }
585 }
586
587 @Override
588 public TimeZoneNameProvider getImpl(Locale locale) {
589 return SPILocaleProviderAdapter.getImpl(map, locale);
590 }
591
592 @Override
593 public Locale[] getAvailableLocales() {
|
1 /*
2 * Copyright (c) 2012, 2017, 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
554 @Override
555 public String getDisplayScript(String scriptCode, Locale locale) {
556 LocaleNameProvider lnp = getImpl(locale);
557 assert lnp != null;
558 return lnp.getDisplayScript(scriptCode, locale);
559 }
560
561 @Override
562 public String getDisplayCountry(String countryCode, Locale locale) {
563 LocaleNameProvider lnp = getImpl(locale);
564 assert lnp != null;
565 return lnp.getDisplayCountry(countryCode, locale);
566 }
567
568 @Override
569 public String getDisplayVariant(String variant, Locale locale) {
570 LocaleNameProvider lnp = getImpl(locale);
571 assert lnp != null;
572 return lnp.getDisplayVariant(variant, locale);
573 }
574
575 @Override
576 public String getDisplayUnicodeExtensionKey(String key, Locale locale) {
577 LocaleNameProvider lnp = getImpl(locale);
578 assert lnp != null;
579 return lnp.getDisplayUnicodeExtensionKey(key, locale);
580 }
581
582 @Override
583 public String getDisplayUnicodeExtensionType(String extType, String key, Locale locale) {
584 LocaleNameProvider lnp = getImpl(locale);
585 assert lnp != null;
586 return lnp.getDisplayUnicodeExtensionType(extType, key, locale);
587 }
588 }
589
590 static class TimeZoneNameProviderDelegate extends TimeZoneNameProvider
591 implements Delegate<TimeZoneNameProvider> {
592 private final ConcurrentMap<Locale, TimeZoneNameProvider> map = new ConcurrentHashMap<>();
593
594 @Override
595 public void addImpl(TimeZoneNameProvider impl) {
596 for (Locale l : impl.getAvailableLocales()) {
597 map.putIfAbsent(l, impl);
598 }
599 }
600
601 @Override
602 public TimeZoneNameProvider getImpl(Locale locale) {
603 return SPILocaleProviderAdapter.getImpl(map, locale);
604 }
605
606 @Override
607 public Locale[] getAvailableLocales() {
|