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
567 if (key.startsWith(CURRENCY_NAME_PREFIX)) {
568 currencyNames.put(key.substring(CURRENCY_NAME_PREFIX.length()), map.get(key));
569 } else if (key.startsWith(CURRENCY_SYMBOL_PREFIX)) {
570 currencyNames.put(key.substring(CURRENCY_SYMBOL_PREFIX.length()), map.get(key));
571 }
572 }
573 return currencyNames;
574 }
575
576 private static Map<String, Object> extractZoneNames(Map<String, Object> map, String id) {
577 Map<String, Object> names = new HashMap<>();
578
579 // Copy over missing time zone ids from JRE for English locale
580 if (id.equals("en")) {
581 Map<String[], String> jreMetaMap = new HashMap<>();
582 jreTimeZoneNames.stream().forEach(e -> {
583 String tzid = (String)e[0];
584 String[] data = (String[])e[1];
585
586 if (map.get(TIMEZONE_ID_PREFIX + tzid) == null &&
587 handlerMetaZones.get(tzid) == null) {
588 // First, check the CLDR meta key
589 Optional<Map.Entry<String, String>> cldrMeta =
590 handlerMetaZones.getData().entrySet().stream()
591 .filter(me ->
592 Arrays.deepEquals(data,
593 (String[])map.get(METAZONE_ID_PREFIX + me.getValue())))
594 .findAny();
595 if (cldrMeta.isPresent()) {
596 names.put(tzid, cldrMeta.get().getValue());
597 } else {
598 // check the JRE meta key, add if there is not.
599 Optional<Map.Entry<String[], String>> jreMeta =
600 jreMetaMap.entrySet().stream()
601 .filter(jm -> Arrays.deepEquals(data, jm.getKey()))
602 .findAny();
603 if (jreMeta.isPresent()) {
604 names.put(tzid, jreMeta.get().getValue());
605 } else {
606 String metaName = "JRE_" + tzid.replaceAll("[/-]", "_");
607 names.put(METAZONE_ID_PREFIX + metaName, data);
|
1 /*
2 * Copyright (c) 2012, 2016, 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
567 if (key.startsWith(CURRENCY_NAME_PREFIX)) {
568 currencyNames.put(key.substring(CURRENCY_NAME_PREFIX.length()), map.get(key));
569 } else if (key.startsWith(CURRENCY_SYMBOL_PREFIX)) {
570 currencyNames.put(key.substring(CURRENCY_SYMBOL_PREFIX.length()), map.get(key));
571 }
572 }
573 return currencyNames;
574 }
575
576 private static Map<String, Object> extractZoneNames(Map<String, Object> map, String id) {
577 Map<String, Object> names = new HashMap<>();
578
579 // Copy over missing time zone ids from JRE for English locale
580 if (id.equals("en")) {
581 Map<String[], String> jreMetaMap = new HashMap<>();
582 jreTimeZoneNames.stream().forEach(e -> {
583 String tzid = (String)e[0];
584 String[] data = (String[])e[1];
585
586 if (map.get(TIMEZONE_ID_PREFIX + tzid) == null &&
587 handlerMetaZones.get(tzid) == null ||
588 handlerMetaZones.get(tzid) != null &&
589 map.get(METAZONE_ID_PREFIX + handlerMetaZones.get(tzid)) == null) {
590 // First, check the CLDR meta key
591 Optional<Map.Entry<String, String>> cldrMeta =
592 handlerMetaZones.getData().entrySet().stream()
593 .filter(me ->
594 Arrays.deepEquals(data,
595 (String[])map.get(METAZONE_ID_PREFIX + me.getValue())))
596 .findAny();
597 if (cldrMeta.isPresent()) {
598 names.put(tzid, cldrMeta.get().getValue());
599 } else {
600 // check the JRE meta key, add if there is not.
601 Optional<Map.Entry<String[], String>> jreMeta =
602 jreMetaMap.entrySet().stream()
603 .filter(jm -> Arrays.deepEquals(data, jm.getKey()))
604 .findAny();
605 if (jreMeta.isPresent()) {
606 names.put(tzid, jreMeta.get().getValue());
607 } else {
608 String metaName = "JRE_" + tzid.replaceAll("[/-]", "_");
609 names.put(METAZONE_ID_PREFIX + metaName, data);
|