< prev index next >
make/jdk/src/classes/build/tools/cldrconverter/ResourceBundleGenerator.java
Print this page
rev 49575 : imported patch 8181157
*** 1,7 ****
/*
! * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 209,223 ****
if (useJava) {
Object value = map.get(key);
if (value == null) {
CLDRConverter.warning("null value for " + key);
} else if (value instanceof String) {
! if (type == BundleType.TIMEZONE ||
! ((String)value).startsWith(META_VALUE_PREFIX)) {
! out.printf(" { \"%s\", %s },\n", key, CLDRConverter.saveConvert((String) value, useJava));
} else {
! out.printf(" { \"%s\", \"%s\" },\n", key, CLDRConverter.saveConvert((String) value, useJava));
}
} else if (value instanceof String[]) {
String[] values = (String[]) value;
out.println(" { \"" + key + "\",\n new String[] {");
for (String s : values) {
--- 209,225 ----
if (useJava) {
Object value = map.get(key);
if (value == null) {
CLDRConverter.warning("null value for " + key);
} else if (value instanceof String) {
! String valStr = (String)value;
! if (type == BundleType.TIMEZONE &&
! !key.startsWith(CLDRConverter.EXEMPLAR_CITY_PREFIX) ||
! valStr.startsWith(META_VALUE_PREFIX)) {
! out.printf(" { \"%s\", %s },\n", key, CLDRConverter.saveConvert(valStr, useJava));
} else {
! out.printf(" { \"%s\", \"%s\" },\n", key, CLDRConverter.saveConvert(valStr, useJava));
}
} else if (value instanceof String[]) {
String[] values = (String[]) value;
out.println(" { \"" + key + "\",\n new String[] {");
for (String s : values) {
*** 306,324 ****
out.printf(" }\n\n");
// end of static initializer block.
! // Short TZ names for delayed initialization
if (CLDRConverter.isBaseModule) {
! out.printf(" private static class TZShortIDMapHolder {\n");
! out.printf(" static final Map<String, String> tzShortIDMap = new HashMap<>();\n");
out.printf(" static {\n");
CLDRConverter.handlerTimeZone.getData().entrySet().stream()
.forEach(e -> {
! out.printf(" tzShortIDMap.put(\"%s\", \"%s\");\n", e.getKey(),
! ((String)e.getValue()));
});
out.printf(" }\n }\n\n");
}
out.printf(" @Override\n" +
--- 308,331 ----
out.printf(" }\n\n");
// end of static initializer block.
! // Canonical TZ names for delayed initialization
if (CLDRConverter.isBaseModule) {
! out.printf(" private static class TZCanonicalIDMapHolder {\n");
! out.printf(" static final Map<String, String> tzCanonicalIDMap = new HashMap<>(600);\n");
out.printf(" static {\n");
CLDRConverter.handlerTimeZone.getData().entrySet().stream()
.forEach(e -> {
! String[] ids = ((String)e.getValue()).split("\\s");
! out.printf(" tzCanonicalIDMap.put(\"%s\", \"%s\");\n", e.getKey(),
! ids[0]);
! for (int i = 1; i < ids.length; i++) {
! out.printf(" tzCanonicalIDMap.put(\"%s\", \"%s\");\n", ids[i],
! ids[0]);
! }
});
out.printf(" }\n }\n\n");
}
out.printf(" @Override\n" +
*** 331,342 ****
" return resourceNameToLocales.getOrDefault(category, \"\");\n" +
" }\n\n");
if (CLDRConverter.isBaseModule) {
out.printf(" @Override\n" +
! " public Map<String, String> tzShortIDs() {\n" +
! " return TZShortIDMapHolder.tzShortIDMap;\n" +
" }\n\n");
out.printf(" public Map<Locale, String[]> parentLocales() {\n" +
" return parentLocalesMap;\n" +
" }\n}");
} else {
--- 338,349 ----
" return resourceNameToLocales.getOrDefault(category, \"\");\n" +
" }\n\n");
if (CLDRConverter.isBaseModule) {
out.printf(" @Override\n" +
! " public Map<String, String> tzCanonicalIDs() {\n" +
! " return TZCanonicalIDMapHolder.tzCanonicalIDMap;\n" +
" }\n\n");
out.printf(" public Map<Locale, String[]> parentLocales() {\n" +
" return parentLocalesMap;\n" +
" }\n}");
} else {
< prev index next >