< prev index next >
test/jdk/java/util/Locale/LSRDataTest.java
Print this page
rev 58690 : [mq]: 8242010
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2020, 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.
@@ -21,11 +21,11 @@
* questions.
*/
/*
* @test
- * @bug 8204938
+ * @bug 8204938 8242010
* @summary Checks the IANA language subtag registry data update
* with Locale.LanguageRange parse method.
* @run main LSRDataTest
*/
import java.io.IOException;
@@ -98,33 +98,50 @@
// load LSR data from the file
private static void loadLSRData(Path path) throws IOException {
String type = null;
String tag = null;
- String preferred;
+ String preferred = null;
+ String prefix = null;
for (String line : Files.readAllLines(path, Charset.forName("UTF-8"))) {
line = line.toLowerCase(Locale.ROOT);
int index = line.indexOf(' ') + 1;
if (line.startsWith("type:")) {
type = line.substring(index);
} else if (line.startsWith("tag:") || line.startsWith("subtag:")) {
tag = line.substring(index);
- } else if (line.startsWith("preferred-value:") && !type.equals("extlang")) {
+ } else if (line.startsWith("preferred-value:")) {
preferred = line.substring(index);
- processDataAndGenerateMaps(type, tag, preferred);
+ } else if (line.startsWith("prefix:")) {
+ prefix = line.substring(index);
} else if (line.equals("%%")) {
+ processDataAndGenerateMaps(type, tag, preferred, prefix);
type = null;
tag = null;
+ preferred = null;
+ prefix = null;
}
}
+
+ // Last entry
+ processDataAndGenerateMaps(type, tag, preferred, prefix);
}
private static void processDataAndGenerateMaps(String type,
String tag,
- String preferred) {
- StringBuilder sb;
+ String preferred,
+ String prefix) {
+
+ if (type == null || tag == null || preferred == null) {
+ return;
+ }
+
+ if (type.equals("extlang") && prefix != null) {
+ tag = prefix + "-" + tag;
+ }
+
if (type.equals("region") || type.equals("variant")) {
if (!regionVariantEquivMap.containsKey(preferred)) {
String tPref = HYPHEN + preferred;
String tTag = HYPHEN + tag;
regionVariantEquivMap.put(tPref, tTag);
@@ -132,11 +149,11 @@
} else {
throw new RuntimeException("New case, need implementation."
+ " A region/variant subtag \"" + preferred
+ "\" is registered for more than one subtags.");
}
- } else { // language, grandfathered, and redundant
+ } else { // language, extlang, grandfathered, and redundant
if (!singleLangEquivMap.containsKey(preferred)
&& !multiLangEquivsMap.containsKey(preferred)) {
// new entry add it into single equiv map
singleLangEquivMap.put(preferred, tag);
singleLangEquivMap.put(tag, preferred);
< prev index next >