--- old/src/java.base/share/classes/sun/util/locale/LocaleEquivalentMaps.java 2016-06-10 11:14:43.660943999 +0530 +++ new/src/java.base/share/classes/sun/util/locale/LocaleEquivalentMaps.java 2016-06-10 11:14:43.508868000 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, 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 @@ -43,12 +43,16 @@ regionVariantEquivMap = new HashMap<>(); // This is an auto-generated file and should not be manually edited. - // LSR Revision: 2013-09-23 + // LSR Revision: 2016-02-10 + singleEquivMap.put("aam", "aas"); + singleEquivMap.put("aas", "aam"); singleEquivMap.put("acn", "xia"); + singleEquivMap.put("adp", "dz"); singleEquivMap.put("adx", "pcr"); singleEquivMap.put("ami", "i-ami"); singleEquivMap.put("art-lojban", "jbo"); singleEquivMap.put("ase", "sgn-us"); + singleEquivMap.put("aue", "ktz"); singleEquivMap.put("ayx", "nun"); singleEquivMap.put("bfi", "sgn-gb"); singleEquivMap.put("bjd", "drl"); @@ -67,12 +71,17 @@ singleEquivMap.put("drl", "bjd"); singleEquivMap.put("dse", "sgn-nl"); singleEquivMap.put("dsl", "sgn-dk"); + singleEquivMap.put("dz", "adp"); + singleEquivMap.put("ema", "uok"); + singleEquivMap.put("en-gb-oed", "en-gb-oxendict"); + singleEquivMap.put("en-gb-oxendict", "en-gb-oed"); singleEquivMap.put("fsl", "sgn-fr"); singleEquivMap.put("gal", "ilw"); singleEquivMap.put("gan", "zh-gan"); singleEquivMap.put("gav", "dev"); singleEquivMap.put("gsg", "sgn-de"); singleEquivMap.put("gss", "sgn-gr"); + singleEquivMap.put("gti", "nyc"); singleEquivMap.put("he", "iw"); singleEquivMap.put("hle", "sca"); singleEquivMap.put("hrr", "jal"); @@ -102,28 +111,46 @@ singleEquivMap.put("kgh", "kml"); singleEquivMap.put("khk", "drh"); singleEquivMap.put("kml", "kgh"); + singleEquivMap.put("koj", "kwv"); + singleEquivMap.put("ktz", "aue"); + singleEquivMap.put("kwq", "yam"); + singleEquivMap.put("kwv", "koj"); + singleEquivMap.put("kxe", "tvd"); singleEquivMap.put("lb", "i-lux"); singleEquivMap.put("lcq", "ppr"); + singleEquivMap.put("lii", "raq"); + singleEquivMap.put("lmm", "rmx"); singleEquivMap.put("lrr", "yma"); singleEquivMap.put("meg", "cir"); singleEquivMap.put("mfs", "sgn-mx"); singleEquivMap.put("mo", "ro"); singleEquivMap.put("mom", "cjr"); + singleEquivMap.put("mtm", "ymt"); singleEquivMap.put("nan", "zh-min-nan"); singleEquivMap.put("nb", "no-bok"); singleEquivMap.put("ncs", "sgn-ni"); + singleEquivMap.put("ngv", "nnx"); singleEquivMap.put("nn", "no-nyn"); + singleEquivMap.put("nnx", "ngv"); singleEquivMap.put("no-bok", "nb"); singleEquivMap.put("no-nyn", "nn"); singleEquivMap.put("nsl", "sgn-no"); singleEquivMap.put("nun", "ayx"); singleEquivMap.put("nv", "i-navajo"); + singleEquivMap.put("nyc", "gti"); singleEquivMap.put("opa", "ibi"); + singleEquivMap.put("oyb", "thx"); singleEquivMap.put("pcr", "adx"); + singleEquivMap.put("phr", "pmu"); + singleEquivMap.put("pmu", "phr"); singleEquivMap.put("ppr", "lcq"); singleEquivMap.put("psr", "sgn-pt"); + singleEquivMap.put("pub", "puz"); + singleEquivMap.put("puz", "pub"); singleEquivMap.put("pwn", "i-pwn"); + singleEquivMap.put("raq", "lii"); singleEquivMap.put("ras", "tie"); + singleEquivMap.put("rmx", "lmm"); singleEquivMap.put("ro", "mo"); singleEquivMap.put("sca", "hle"); singleEquivMap.put("sfb", "sgn-be-fr"); @@ -152,24 +179,35 @@ singleEquivMap.put("sgn-us", "ase"); singleEquivMap.put("sgn-za", "sfs"); singleEquivMap.put("ssp", "sgn-es"); + singleEquivMap.put("suj", "xsj"); singleEquivMap.put("swl", "sgn-se"); + singleEquivMap.put("taj", "tsf"); singleEquivMap.put("tao", "i-tao"); singleEquivMap.put("tay", "i-tay"); + singleEquivMap.put("thx", "oyb"); singleEquivMap.put("tie", "ras"); singleEquivMap.put("tkk", "twm"); singleEquivMap.put("tlh", "i-klingon"); singleEquivMap.put("tlw", "weo"); + singleEquivMap.put("tsf", "taj"); singleEquivMap.put("tsu", "i-tsu"); + singleEquivMap.put("tvd", "kxe"); singleEquivMap.put("twm", "tkk"); + singleEquivMap.put("uok", "ema"); singleEquivMap.put("vgt", "sgn-be-nl"); singleEquivMap.put("weo", "tlw"); singleEquivMap.put("wuu", "zh-wuu"); singleEquivMap.put("xch", "cmk"); singleEquivMap.put("xia", "acn"); + singleEquivMap.put("xsj", "suj"); + singleEquivMap.put("yam", "kwq"); singleEquivMap.put("yi", "ji"); singleEquivMap.put("yma", "lrr"); + singleEquivMap.put("ymt", "mtm"); singleEquivMap.put("yos", "zom"); singleEquivMap.put("yue", "zh-yue"); + singleEquivMap.put("yug", "yuu"); + singleEquivMap.put("yuu", "yug"); singleEquivMap.put("zh-cmn-hans", "cmn-hans"); singleEquivMap.put("zh-cmn-hant", "cmn-hant"); singleEquivMap.put("zh-gan", "gan"); @@ -182,14 +220,18 @@ multiEquivsMap.put("ccq", new String[] {"rki", "ybd"}); multiEquivsMap.put("cmn", new String[] {"zh-guoyu", "zh-cmn"}); multiEquivsMap.put("drw", new String[] {"prs", "tnf"}); + multiEquivsMap.put("gfx", new String[] {"vaj", "mwj", "oun"}); multiEquivsMap.put("hak", new String[] {"i-hak", "zh-hakka"}); multiEquivsMap.put("i-hak", new String[] {"hak", "zh-hakka"}); multiEquivsMap.put("mry", new String[] {"mst", "myt"}); multiEquivsMap.put("mst", new String[] {"mry", "myt"}); + multiEquivsMap.put("mwj", new String[] {"vaj", "gfx", "oun"}); multiEquivsMap.put("myt", new String[] {"mry", "mst"}); + multiEquivsMap.put("oun", new String[] {"vaj", "gfx", "mwj"}); multiEquivsMap.put("prs", new String[] {"drw", "tnf"}); multiEquivsMap.put("rki", new String[] {"ccq", "ybd"}); multiEquivsMap.put("tnf", new String[] {"prs", "drw"}); + multiEquivsMap.put("vaj", new String[] {"gfx", "mwj", "oun"}); multiEquivsMap.put("ybd", new String[] {"rki", "ccq"}); multiEquivsMap.put("zh-cmn", new String[] {"cmn", "zh-guoyu"}); multiEquivsMap.put("zh-guoyu", new String[] {"cmn", "zh-cmn"}); --- old/test/java/util/Locale/tools/EquivMapsGenerator.java 2016-06-10 11:14:44.129177999 +0530 +++ new/test/java/util/Locale/tools/EquivMapsGenerator.java 2016-06-10 11:14:43.961093999 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, 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 @@ -21,7 +21,6 @@ * questions. */ -import java.io.*; import java.nio.charset.*; import java.nio.file.*; import java.util.*; @@ -156,13 +155,10 @@ if (subtags.length == 2) { sortedLanguageMap1.put(subtags[0], subtags[1]); sortedLanguageMap1.put(subtags[1], subtags[0]); - } else if (subtags.length == 3) { - sortedLanguageMap2.put(subtags[0], - new String[]{subtags[1], subtags[2]}); - sortedLanguageMap2.put(subtags[1], - new String[]{subtags[0], subtags[2]}); - sortedLanguageMap2.put(subtags[2], - new String[]{subtags[0], subtags[1]}); + } else if (subtags.length > 2) { + for (int i = 0; i < subtags.length; i++) { + sortedLanguageMap2.put(subtags[i], createLangArray(i, subtags)); + } } else { throw new RuntimeException("New case, need implementation." + " A language subtag \"" + preferred @@ -191,8 +187,9 @@ + sortedLanguageMap2.size()); for (String key : sortedLanguageMap2.keySet()) { String[] s = sortedLanguageMap2.get(key); - System.out.println(" " + key + ": \"" - + s[0] + "\", \"" + s[1] + "\""); + if (s.length >= 2) { + System.out.println(" " + key + ": " + generateValuesString(s) + ""); + } } System.out.println("\n Sorted map for region and variant subtags. Size=" @@ -204,7 +201,31 @@ } System.out.println(); } + + /* create the array of subtags excluding the subtag at index location */ + private static String[] createLangArray(int index, String[] subtags) { + List list = new ArrayList<>(); + for (int i = 0; i < subtags.length; i++) { + if (i != index) { + list.add(subtags[i]); + } + } + return list.toArray(new String[list.size()]); + } + private static String generateValuesString(String[] values) { + String outputStr = ""; + for (int i = 0; i < values.length; i++) { + if (i != values.length - 1) { + outputStr = outputStr + "\"" + values[i] + "\", "; + } else { + outputStr = outputStr + "\"" + values[i] + "\""; + } + + } + return outputStr; + } + private static final String headerText = "final class LocaleEquivalentMaps {\n\n" + " static final Map singleEquivMap;\n" @@ -232,9 +253,11 @@ System.out.println(); for (String key : sortedLanguageMap2.keySet()) { String[] values = sortedLanguageMap2.get(key); - System.out.println(" multiEquivsMap.put(\"" - + key + "\", new String[] {\"" + values[0] + "\", \"" - + values[1] + "\"});"); + + if (values.length >= 2) { + System.out.println(" multiEquivsMap.put(\"" + + key + "\", new String[] {" + generateValuesString(values) + "});"); + } } System.out.println(); for (String key : sortedRegionVariantMap.keySet()) { --- old/test/java/util/Locale/tools/language-subtag-registry.txt 2016-06-10 11:14:44.589408000 +0530 +++ new/test/java/util/Locale/tools/language-subtag-registry.txt 2016-06-10 11:14:44.437332000 +0530 @@ -1,4 +1,4 @@ -File-Date: 2013-09-23 +File-Date: 2016-02-10 %% Type: language Subtag: aa @@ -1214,6 +1214,8 @@ Subtag: aam Description: Aramanik Added: 2009-07-29 +Deprecated: 2015-02-12 +Preferred-Value: aas %% Type: language Subtag: aan @@ -1580,6 +1582,8 @@ Subtag: adp Description: Adap Added: 2009-07-29 +Deprecated: 2015-02-12 +Preferred-Value: dz %% Type: language Subtag: adq @@ -1651,6 +1655,7 @@ %% Type: language Subtag: aee +Description: Northeast Pashai Description: Northeast Pashayi Added: 2009-07-29 %% @@ -1744,6 +1749,7 @@ Type: language Subtag: afi Description: Akrukay +Description: Chini Added: 2009-07-29 %% Type: language @@ -2734,6 +2740,7 @@ %% Type: language Subtag: aot +Description: Atong (India) Description: A'tong Added: 2009-07-29 %% @@ -2933,6 +2940,11 @@ Added: 2009-07-29 %% Type: language +Subtag: aqt +Description: Angaité +Added: 2014-02-28 +%% +Type: language Subtag: aqz Description: Akuntsu Added: 2010-03-11 @@ -3252,7 +3264,7 @@ %% Type: language Subtag: ato -Description: Atong +Description: Atong (Cameroon) Added: 2009-07-29 %% Type: language @@ -3334,6 +3346,8 @@ Subtag: aue Description: =/Kx'au//'ein Added: 2009-07-29 +Deprecated: 2015-02-12 +Preferred-Value: ktz %% Type: language Subtag: auf @@ -4452,6 +4466,7 @@ %% Type: language Subtag: bfc +Description: Panyi Bai Description: Northern Bai Added: 2009-07-29 %% @@ -5463,6 +5478,7 @@ Subtag: bmy Description: Bemba (Democratic Republic of Congo) Added: 2009-07-29 +Deprecated: 2015-02-12 %% Type: language Subtag: bmz @@ -6832,6 +6848,7 @@ Subtag: bxx Description: Borna (Democratic Republic of Congo) Added: 2009-07-29 +Deprecated: 2015-02-12 %% Type: language Subtag: bxz @@ -6959,6 +6976,7 @@ Subtag: byy Description: Buya Added: 2009-07-29 +Deprecated: 2015-02-12 %% Type: language Subtag: byz @@ -7292,6 +7310,12 @@ Added: 2009-07-29 %% Type: language +Subtag: cbq +Description: Tsucuba +Description: Cuba +Added: 2015-02-12 +%% +Type: language Subtag: cbr Description: Cashibo-Cacataibo Added: 2009-07-29 @@ -9296,8 +9320,8 @@ %% Type: language Subtag: dhg -Description: Djangu Description: Dhangu +Description: Djangu Added: 2009-07-29 %% Type: language @@ -10320,6 +10344,7 @@ Subtag: dzd Description: Daza Added: 2009-07-29 +Deprecated: 2015-02-12 %% Type: language Subtag: dze @@ -10613,6 +10638,7 @@ Subtag: emo Description: Emok Added: 2009-07-29 +Deprecated: 2014-02-28 %% Type: language Subtag: emp @@ -10676,6 +10702,11 @@ Added: 2009-07-29 %% Type: language +Subtag: enl +Description: Enlhet +Added: 2014-02-28 +%% +Type: language Subtag: enm Description: Middle English (1100-1500) Added: 2005-10-16 @@ -10717,6 +10748,11 @@ Added: 2009-07-29 %% Type: language +Subtag: enx +Description: Enxet +Added: 2014-02-28 +%% +Type: language Subtag: eot Description: Beti (Côte d'Ivoire) Added: 2009-07-29 @@ -10840,6 +10876,11 @@ Scope: collection %% Type: language +Subtag: esy +Description: Eskayan +Added: 2014-04-06 +%% +Type: language Subtag: etb Description: Etebi Added: 2009-07-29 @@ -11158,6 +11199,7 @@ %% Type: language Subtag: fly +Description: Flaaitaal Description: Tsotsitaal Added: 2009-07-29 %% @@ -11881,6 +11923,11 @@ Added: 2009-07-29 %% Type: language +Subtag: gev +Description: Eviya +Added: 2014-02-28 +%% +Type: language Subtag: gew Description: Gera Added: 2009-07-29 @@ -11914,6 +11961,8 @@ Subtag: gfx Description: Mangetti Dune !Xung Added: 2012-08-12 +Deprecated: 2015-02-12 +Preferred-Value: vaj %% Type: language Subtag: gga @@ -11966,7 +12015,7 @@ Description: Aghu Tharnggalu Added: 2009-07-29 Deprecated: 2013-09-10 -Comments: see ggm, gtu, ikr +Comments: see gtu, ikr %% Type: language Subtag: ggt @@ -12195,6 +12244,12 @@ Macrolanguage: kpe %% Type: language +Subtag: gku +Description: ǂUngkue +Description: =/Ungkue +Added: 2015-02-12 +%% +Type: language Subtag: glc Description: Bon Gula Added: 2009-07-29 @@ -12206,6 +12261,7 @@ %% Type: language Subtag: glh +Description: Northwest Pashai Description: Northwest Pashayi Added: 2009-07-29 %% @@ -12276,6 +12332,11 @@ Scope: collection %% Type: language +Subtag: gmg +Description: Magɨyi +Added: 2014-02-28 +%% +Type: language Subtag: gmh Description: Middle High German (ca. 1050-1500) Added: 2005-10-16 @@ -12376,6 +12437,7 @@ Type: language Subtag: gnk Description: //Gana +Description: ǁGana Added: 2009-07-29 %% Type: language @@ -12765,6 +12827,8 @@ Subtag: gti Description: Gbati-ri Added: 2009-07-29 +Deprecated: 2015-02-12 +Preferred-Value: nyc %% Type: language Subtag: gtu @@ -13003,6 +13067,7 @@ Type: language Subtag: gwj Description: /Gwi +Description: ǀGwi Added: 2009-07-29 %% Type: language @@ -13330,6 +13395,7 @@ Type: language Subtag: hgm Description: Hai//om +Description: Haiǁom Added: 2009-07-29 %% Type: language @@ -13668,6 +13734,7 @@ Type: language Subtag: hnh Description: //Ani +Description: ǁAni Added: 2009-07-29 %% Type: language @@ -13815,6 +13882,7 @@ %% Type: language Subtag: hps +Description: Hawai'i Sign Language (HSL) Description: Hawai'i Pidgin Sign Language Added: 2009-07-29 %% @@ -13946,6 +14014,7 @@ Type: language Subtag: huc Description: =/Hua +Description: ǂHua Added: 2009-07-29 %% Type: language @@ -14452,6 +14521,11 @@ Added: 2013-09-10 %% Type: language +Subtag: iks +Description: Inuit Sign Language +Added: 2015-02-12 +%% +Type: language Subtag: ikt Description: Inuinnaqtun Description: Western Canadian Inuktitut @@ -14544,6 +14618,7 @@ Subtag: ime Description: Imeraguen Added: 2009-07-29 +Deprecated: 2015-02-12 %% Type: language Subtag: imi @@ -15331,6 +15406,11 @@ Added: 2009-07-29 %% Type: language +Subtag: jje +Description: Jejueo +Added: 2015-02-12 +%% +Type: language Subtag: jjr Description: Bankal Added: 2012-08-12 @@ -15471,6 +15551,11 @@ Added: 2009-07-29 %% Type: language +Subtag: jog +Description: Jogi +Added: 2015-05-27 +%% +Type: language Subtag: jor Description: Jorá Added: 2009-07-29 @@ -15789,6 +15874,7 @@ Subtag: kbf Description: Kakauhua Added: 2009-07-29 +Deprecated: 2015-02-12 %% Type: language Subtag: kbg @@ -16890,6 +16976,11 @@ Added: 2009-07-29 %% Type: language +Subtag: kjv +Description: Kaikavian Literary Language +Added: 2015-02-12 +%% +Type: language Subtag: kjx Description: Ramopa Added: 2009-07-29 @@ -17471,6 +17562,8 @@ Subtag: koj Description: Sara Dunjo Added: 2009-07-29 +Deprecated: 2015-02-12 +Preferred-Value: kwv %% Type: language Subtag: kok @@ -18184,6 +18277,7 @@ Type: language Subtag: ktz Description: Ju/'hoan +Description: Juǀʼhoan Added: 2009-07-29 %% Type: language @@ -18203,7 +18297,7 @@ %% Type: language Subtag: kue -Description: Kuman +Description: Kuman (Papua New Guinea) Added: 2009-07-29 %% Type: language @@ -18525,6 +18619,8 @@ Subtag: kwq Description: Kwak Added: 2009-07-29 +Deprecated: 2015-02-12 +Preferred-Value: yam %% Type: language Subtag: kwr @@ -18598,6 +18694,8 @@ Subtag: kxe Description: Kakihum Added: 2009-07-29 +Deprecated: 2015-02-12 +Preferred-Value: tvd %% Type: language Subtag: kxf @@ -19070,7 +19168,7 @@ %% Type: language Subtag: lay -Description: Lama (Myanmar) +Description: Lama Bai Added: 2009-07-29 %% Type: language @@ -19352,6 +19450,8 @@ Subtag: leg Description: Lengua Added: 2009-07-29 +Deprecated: 2014-02-28 +Comments: see enl, enx %% Type: language Subtag: leh @@ -19624,6 +19724,8 @@ Subtag: lii Description: Lingkhim Added: 2009-07-29 +Deprecated: 2015-02-12 +Preferred-Value: raq %% Type: language Subtag: lij @@ -19987,6 +20089,8 @@ Subtag: lmm Description: Lamam Added: 2009-07-29 +Deprecated: 2014-02-28 +Preferred-Value: rmx %% Type: language Subtag: lmn @@ -21596,6 +21700,7 @@ Subtag: mhh Description: Maskoy Pidgin Added: 2009-07-29 +Deprecated: 2014-02-28 %% Type: language Subtag: mhi @@ -23496,6 +23601,8 @@ Subtag: mwj Description: Maligo Added: 2009-07-29 +Deprecated: 2015-02-12 +Preferred-Value: vaj %% Type: language Subtag: mwk @@ -24052,6 +24159,7 @@ %% Type: language Subtag: naq +Description: Khoekhoe Description: Nama (Namibia) Added: 2009-07-29 %% @@ -24067,6 +24175,7 @@ %% Type: language Subtag: nat +Description: Ca̱hungwa̱rya̱ Description: Hungworo Added: 2009-07-29 %% @@ -24632,6 +24741,7 @@ Type: language Subtag: ngh Description: N/u +Description: Nǀu Added: 2009-07-29 %% Type: language @@ -25340,6 +25450,7 @@ Type: language Subtag: nmn Description: !Xóõ +Description: ǃXóõ Added: 2009-07-29 %% Type: language @@ -25385,6 +25496,7 @@ Type: language Subtag: nmw Description: Nimoa +Description: Rifao Added: 2009-07-29 %% Type: language @@ -25516,6 +25628,8 @@ Subtag: nnx Description: Ngong Added: 2009-07-29 +Deprecated: 2015-02-12 +Preferred-Value: ngv %% Type: language Subtag: nny @@ -25758,6 +25872,12 @@ Added: 2009-07-29 %% Type: language +Subtag: nrf +Description: Jèrriais +Description: Guernésiais +Added: 2015-02-12 +%% +Type: language Subtag: nrg Description: Narango Added: 2009-07-29 @@ -26267,6 +26387,11 @@ Added: 2009-07-29 %% Type: language +Subtag: nxo +Description: Ndambomo +Added: 2015-02-12 +%% +Type: language Subtag: nxq Description: Naxi Added: 2011-08-16 @@ -26788,6 +26913,11 @@ Added: 2009-07-29 %% Type: language +Subtag: olt +Description: Old Lithuanian +Added: 2014-02-28 +%% +Type: language Subtag: oma Description: Omaha-Ponca Added: 2009-07-29 @@ -27264,6 +27394,8 @@ Subtag: oun Description: !O!ung Added: 2009-07-29 +Deprecated: 2015-02-12 +Preferred-Value: vaj %% Type: language Subtag: owi @@ -27507,7 +27639,7 @@ %% Type: language Subtag: pby -Description: Pyu +Description: Pyu (Papua New Guinea) Added: 2009-07-29 %% Type: language @@ -27763,6 +27895,11 @@ Macrolanguage: ar %% Type: language +Subtag: pgd +Description: Gāndhārī +Added: 2015-02-12 +%% +Type: language Subtag: pgg Description: Pangwali Added: 2009-07-29 @@ -28157,6 +28294,7 @@ %% Type: language Subtag: pls +Description: San Marcos Tlacoyalco Popoloca Description: San Marcos Tlalcoyalco Popoloca Added: 2009-07-29 %% @@ -28285,6 +28423,8 @@ Subtag: pmu Description: Mirpur Panjabi Added: 2009-07-29 +Deprecated: 2015-02-12 +Preferred-Value: phr Macrolanguage: lah %% Type: language @@ -28779,11 +28919,13 @@ %% Type: language Subtag: psh +Description: Southwest Pashai Description: Southwest Pashayi Added: 2009-07-29 %% Type: language Subtag: psi +Description: Southeast Pashai Description: Southeast Pashayi Added: 2009-07-29 %% @@ -28879,6 +29021,11 @@ Added: 2009-07-29 %% Type: language +Subtag: ptq +Description: Pattapu +Added: 2014-04-06 +%% +Type: language Subtag: ptr Description: Piamatsina Added: 2009-07-29 @@ -29012,6 +29159,8 @@ Subtag: puz Description: Purum Naga Added: 2009-07-29 +Deprecated: 2014-02-28 +Preferred-Value: pub %% Type: language Subtag: pwa @@ -30114,6 +30263,11 @@ Added: 2009-07-29 %% Type: language +Subtag: rts +Description: Yurats +Added: 2015-02-12 +%% +Type: language Subtag: rtw Description: Rathawi Added: 2009-07-29 @@ -30317,6 +30471,8 @@ Subtag: sap Description: Sanapaná Added: 2009-07-29 +Deprecated: 2014-02-28 +Comments: see aqt, spn %% Type: language Subtag: saq @@ -30395,6 +30551,7 @@ %% Type: language Subtag: sbf +Description: Chabu Description: Shabo Added: 2009-07-29 %% @@ -30926,6 +31083,7 @@ Subtag: sgo Description: Songa Added: 2009-07-29 +Deprecated: 2015-02-12 %% Type: language Subtag: sgp @@ -31385,6 +31543,7 @@ %% Type: language Subtag: skr +Description: Saraiki Description: Seraiki Added: 2009-07-29 Macrolanguage: lah @@ -31940,6 +32099,11 @@ Added: 2009-07-29 %% Type: language +Subtag: spn +Description: Sanapaná +Added: 2014-02-28 +%% +Type: language Subtag: spo Description: Spokane Added: 2009-07-29 @@ -32804,6 +32968,11 @@ Added: 2009-07-29 %% Type: language +Subtag: syx +Description: Samay +Added: 2015-02-12 +%% +Type: language Subtag: syy Description: Al-Sayyid Bedouin Sign Language Added: 2009-07-29 @@ -33694,6 +33863,8 @@ Subtag: thx Description: The Added: 2009-07-29 +Deprecated: 2015-02-12 +Preferred-Value: oyb %% Type: language Subtag: thy @@ -33963,6 +34134,11 @@ Added: 2009-07-29 %% Type: language +Subtag: tkv +Description: Mur Pano +Added: 2014-02-28 +%% +Type: language Subtag: tkw Description: Teanu Added: 2009-07-29 @@ -34796,6 +34972,8 @@ Subtag: tsf Description: Southwestern Tamang Added: 2009-07-29 +Deprecated: 2015-02-12 +Preferred-Value: taj %% Type: language Subtag: tsg @@ -35340,6 +35518,11 @@ Added: 2009-07-29 %% Type: language +Subtag: txj +Description: Tarjumo +Added: 2015-02-12 +%% +Type: language Subtag: txm Description: Tomini Added: 2009-07-29 @@ -35902,6 +36085,8 @@ Subtag: uok Description: Uokha Added: 2009-07-29 +Deprecated: 2015-02-12 +Preferred-Value: ema %% Type: language Subtag: upi @@ -36177,7 +36362,10 @@ %% Type: language Subtag: vaj -Description: Vasekela Bushman +Description: Sekele +Description: Northwestern !Kung +Description: Northwestern ǃKung +Description: Vasekele Added: 2009-07-29 %% Type: language @@ -37778,6 +37966,11 @@ Added: 2009-07-29 %% Type: language +Subtag: xaj +Description: Ararandewára +Added: 2014-02-28 +%% +Type: language Subtag: xal Description: Kalmyk Description: Oirat @@ -37786,6 +37979,7 @@ Type: language Subtag: xam Description: /Xam +Description: ǀXam Added: 2009-07-29 %% Type: language @@ -38037,6 +38231,7 @@ Type: language Subtag: xeg Description: //Xegwi +Description: ǁXegwi Added: 2009-07-29 %% Type: language @@ -38116,6 +38311,7 @@ %% Type: language Subtag: xgm +Description: Dharumbal Description: Guwinmal Added: 2013-09-10 %% @@ -38219,6 +38415,11 @@ Added: 2009-07-29 %% Type: language +Subtag: xis +Description: Kisan +Added: 2014-02-28 +%% +Type: language Subtag: xiv Description: Indus Valley Language Added: 2009-07-29 @@ -38890,6 +39091,8 @@ Subtag: xsj Description: Subi Added: 2009-07-29 +Deprecated: 2015-02-12 +Preferred-Value: suj %% Type: language Subtag: xsl @@ -39539,6 +39742,7 @@ Subtag: yds Description: Yiddish Sign Language Added: 2009-07-29 +Deprecated: 2015-02-12 %% Type: language Subtag: yea @@ -39638,6 +39842,11 @@ Added: 2009-07-29 %% Type: language +Subtag: ygs +Description: Yolŋu Sign Language +Added: 2014-02-28 +%% +Type: language Subtag: ygu Description: Yugul Added: 2013-09-10 @@ -39664,6 +39873,11 @@ Added: 2009-07-29 %% Type: language +Subtag: yhs +Description: Yan-nhaŋu Sign Language +Added: 2015-04-17 +%% +Type: language Subtag: yia Description: Yinggarda Added: 2009-07-29 @@ -39979,6 +40193,8 @@ Subtag: ymt Description: Mator-Taygi-Karagas Added: 2009-07-29 +Deprecated: 2015-02-12 +Preferred-Value: mtm %% Type: language Subtag: ymx @@ -40014,6 +40230,7 @@ Subtag: ynh Description: Yangho Added: 2009-07-29 +Deprecated: 2015-02-12 %% Type: language Subtag: ynk @@ -40313,6 +40530,7 @@ Type: language Subtag: yue Description: Yue Chinese +Description: Cantonese Added: 2009-07-29 Macrolanguage: zh %% @@ -40380,6 +40598,8 @@ Subtag: yuu Description: Yugh Added: 2009-07-29 +Deprecated: 2014-02-28 +Preferred-Value: yug %% Type: language Subtag: yuw @@ -42215,6 +42435,7 @@ %% Type: extlang Subtag: hps +Description: Hawai'i Sign Language (HSL) Description: Hawai'i Pidgin Sign Language Added: 2009-07-29 Preferred-Value: hps @@ -42250,6 +42471,13 @@ Prefix: sgn %% Type: extlang +Subtag: iks +Description: Inuit Sign Language +Added: 2015-02-12 +Preferred-Value: iks +Prefix: sgn +%% +Type: extlang Subtag: ils Description: International Sign Added: 2009-07-29 @@ -43154,7 +43382,21 @@ Subtag: yds Description: Yiddish Sign Language Added: 2009-07-29 -Preferred-Value: yds +Deprecated: 2015-02-12 +Prefix: sgn +%% +Type: extlang +Subtag: ygs +Description: Yolŋu Sign Language +Added: 2014-02-28 +Preferred-Value: ygs +Prefix: sgn +%% +Type: extlang +Subtag: yhs +Description: Yan-nhaŋu Sign Language +Added: 2015-04-17 +Preferred-Value: yhs Prefix: sgn %% Type: extlang @@ -43167,6 +43409,7 @@ Type: extlang Subtag: yue Description: Yue Chinese +Description: Cantonese Added: 2009-07-29 Preferred-Value: yue Prefix: zh @@ -43211,6 +43454,11 @@ Macrolanguage: ms %% Type: script +Subtag: Adlm +Description: Adlam +Added: 2014-12-11 +%% +Type: script Subtag: Afak Description: Afaka Added: 2011-01-07 @@ -43221,11 +43469,22 @@ Added: 2012-11-01 %% Type: script +Subtag: Ahom +Description: Ahom +Description: Tai Ahom +Added: 2013-12-02 +%% +Type: script Subtag: Arab Description: Arabic Added: 2005-10-16 %% Type: script +Subtag: Aran +Description: Arabic (Nastaliq variant) +Added: 2014-12-11 +%% +Type: script Subtag: Armi Description: Imperial Aramaic Added: 2007-12-05 @@ -43266,6 +43525,11 @@ Added: 2005-10-16 %% Type: script +Subtag: Bhks +Description: Bhaiksuki +Added: 2015-07-24 +%% +Type: script Subtag: Blis Description: Blissymbols Added: 2005-10-16 @@ -43431,6 +43695,11 @@ Added: 2005-10-16 %% Type: script +Subtag: Hanb +Description: Han with Bopomofo (alias for Han + Bopomofo) +Added: 2016-02-08 +%% +Type: script Subtag: Hang Description: Hangul Description: Hangŭl @@ -43462,6 +43731,11 @@ Added: 2005-10-16 %% Type: script +Subtag: Hatr +Description: Hatran +Added: 2013-12-02 +%% +Type: script Subtag: Hebr Description: Hebrew Added: 2005-10-16 @@ -43506,6 +43780,11 @@ Added: 2005-10-16 %% Type: script +Subtag: Jamo +Description: Jamo (alias for Jamo subset of Hangul) +Added: 2016-02-08 +%% +Type: script Subtag: Java Description: Javanese Added: 2005-10-16 @@ -43546,6 +43825,16 @@ Added: 2011-08-16 %% Type: script +Subtag: Kitl +Description: Khitan large script +Added: 2014-12-11 +%% +Type: script +Subtag: Kits +Description: Khitan small script +Added: 2014-12-11 +%% +Type: script Subtag: Knda Description: Kannada Added: 2005-10-16 @@ -43592,6 +43881,11 @@ Added: 2005-10-16 %% Type: script +Subtag: Leke +Description: Leke +Added: 2015-07-24 +%% +Type: script Subtag: Lepc Description: Lepcha Description: Róng @@ -43650,13 +43944,18 @@ Added: 2007-07-28 %% Type: script +Subtag: Marc +Description: Marchen +Added: 2014-12-11 +%% +Type: script Subtag: Maya Description: Mayan hieroglyphs Added: 2005-10-16 %% Type: script Subtag: Mend -Description: Mende +Description: Mende Kikakui Added: 2010-04-10 %% Type: script @@ -43675,6 +43974,12 @@ Added: 2005-10-16 %% Type: script +Subtag: Modi +Description: Modi +Description: Moḍī +Added: 2013-12-02 +%% +Type: script Subtag: Mong Description: Mongolian Added: 2005-10-16 @@ -43701,6 +44006,11 @@ Added: 2007-01-26 %% Type: script +Subtag: Mult +Description: Multani +Added: 2013-12-02 +%% +Type: script Subtag: Mymr Description: Myanmar Description: Burmese @@ -43718,6 +44028,14 @@ Added: 2010-04-10 %% Type: script +Subtag: Newa +Description: Newa +Description: Newar +Description: Newari +Description: Nepāla lipi +Added: 2016-01-04 +%% +Type: script Subtag: Nkgb Description: Nakhi Geba Description: 'Na-'Khi ²Ggŏ-¹baw @@ -43760,6 +44078,11 @@ Added: 2005-10-16 %% Type: script +Subtag: Osge +Description: Osage +Added: 2014-12-11 +%% +Type: script Subtag: Osma Description: Osmanya Added: 2005-10-16 @@ -43770,6 +44093,11 @@ Added: 2010-04-10 %% Type: script +Subtag: Pauc +Description: Pau Cin Hau +Added: 2013-12-02 +%% +Type: script Subtag: Perm Description: Old Permic Added: 2005-10-16 @@ -43800,6 +44128,11 @@ Added: 2005-10-16 %% Type: script +Subtag: Piqd +Description: Klingon (KLI pIqaD) +Added: 2016-01-04 +%% +Type: script Subtag: Plrd Description: Miao Description: Pollard @@ -43870,6 +44203,13 @@ Added: 2011-01-07 %% Type: script +Subtag: Sidd +Description: Siddham +Description: Siddhaṃ +Description: Siddhamātṛkā +Added: 2013-12-02 +%% +Type: script Subtag: Sind Description: Khudawadi Description: Sindhi @@ -44048,6 +44388,11 @@ Added: 2007-12-05 %% Type: script +Subtag: Zsye +Description: Symbols (Emoji variant) +Added: 2016-01-04 +%% +Type: script Subtag: Zsym Description: Symbols Added: 2007-12-05 @@ -44360,6 +44705,7 @@ %% Type: region Subtag: CV +Description: Cabo Verde Description: Cape Verde Added: 2005-10-16 %% @@ -45647,6 +45993,15 @@ Prefix: de %% Type: variant +Subtag: abl1943 +Description: Orthographic formulation of 1943 - Official in Brazil + (Formulário Ortográfico de 1943 - Oficial no Brasil) +Added: 2015-05-06 +Prefix: pt-BR +Comments: Denotes conventions established by the Academia Brasileira de + Letras in 1943 and generally used in Brazil until 2009 +%% +Type: variant Subtag: alalc97 Description: ALA-LC Romanization, 1997 edition Added: 2009-12-09 @@ -45665,6 +46020,16 @@ continuum in Eastern Suriname and Western French Guiana %% Type: variant +Subtag: ao1990 +Description: Portuguese Language Orthographic Agreement of 1990 (Acordo + Ortográfico da Língua Portuguesa de 1990) +Added: 2015-05-06 +Prefix: pt +Prefix: gl +Comments: Portuguese orthography conventions established in 1990 but + not brought into effect until 2009 +%% +Type: variant Subtag: arevela Description: Eastern Armenian Added: 2006-09-18 @@ -45698,6 +46063,27 @@ Jaŋalif (Janalif). %% Type: variant +Subtag: balanka +Description: The Balanka dialect of Anii +Added: 2014-02-15 +Prefix: blo +Comments: Balanka is one of 19 Anii dialects. +%% +Type: variant +Subtag: barla +Description: The Barlavento dialect group of Kabuverdianu +Prefix: kea +Comments: Barlavento is one of the two main dialect groups of + Kabuverdianu. +Added: 2013-12-10 +%% +Type: variant +Subtag: basiceng +Description: Basic English +Added: 2015-12-29 +Prefix: en +%% +Type: variant Subtag: bauddha Description: Buddhist Hybrid Sanskrit Added: 2010-07-28 @@ -45723,9 +46109,9 @@ Description: Slovene in Bohorič alphabet Added: 2012-06-27 Prefix: sl -Comments: The subtag represents the alphabet codified by Adam Bohorič in - 1584 and used from the first printed Slovene book and up to the mid- - 19th century. +Comments: The subtag represents the alphabet codified by Adam Bohorič + in 1584 and used from the first printed Slovene book and up to the + mid-19th century. %% Type: variant Subtag: boont @@ -45735,6 +46121,24 @@ Comments: Jargon embedded in American English %% Type: variant +Subtag: colb1945 +Description: Portuguese-Brazilian Orthographic Convention of 1945 + (Convenção Ortográfica Luso-Brasileira de 1945) +Added: 2015-05-06 +Prefix: pt +Comments: Portuguese orthography conventions established in 1945, + generally in effect until 2009. This reform was not ratified in + Brazil. +%% +Type: variant +Subtag: cornu +Description: Cornu-English +Description: Cornish English +Description: Anglo-Cornish +Added: 2015-12-07 +Prefix: en +%% +Type: variant Subtag: dajnko Description: Slovene in Dajnko alphabet Added: 2012-06-27 @@ -45744,6 +46148,14 @@ Slovenia). %% Type: variant +Subtag: ekavsk +Description: Serbian with Ekavian pronunciation +Prefix: sr +Prefix: sr-Latn +Prefix: sr-Cyrl +Added: 2013-12-02 +%% +Type: variant Subtag: emodeng Description: Early Modern English (1500-1700) Added: 2012-02-05 @@ -45789,6 +46201,14 @@ including modern usage. %% Type: variant +Subtag: ijekavsk +Description: Serbian with Ijekavian pronunciation +Prefix: sr +Prefix: sr-Latn +Prefix: sr-Cyrl +Added: 2013-12-02 +%% +Type: variant Subtag: itihasa Description: Epic Sanskrit Added: 2010-07-28 @@ -45816,6 +46236,14 @@ Prefix: kw %% Type: variant +Subtag: kociewie +Description: The Kociewie dialect of Polish +Added: 2014-11-27 +Prefix: pl +Comments: The dialect of Kociewie is spoken in the region around + Starogard Gdański, Tczew and Świecie in northern Poland. +%% +Type: variant Subtag: kscor Description: Standard Cornish orthography of Revived Cornish Description: Kernowek Standard @@ -45876,6 +46304,12 @@ Prefix: sl %% Type: variant +Subtag: newfound +Description: Newfoundland English +Added: 2015-11-25 +Prefix: en-CA +%% +Type: variant Subtag: njiva Description: The Gniva dialect of Resian Description: The Njiva dialect of Resian @@ -45906,6 +46340,12 @@ dialects of Resian %% Type: variant +Subtag: oxendict +Description: Oxford English Dictionary spelling +Added: 2015-04-17 +Prefix: en +%% +Type: variant Subtag: pamaka Description: Pamaka dialect Added: 2009-09-05 @@ -45980,6 +46420,11 @@ Comments: English Liverpudlian dialect known as 'Scouse' %% Type: variant +Subtag: simple +Description: Simplified form +Added: 2015-12-29 +%% +Type: variant Subtag: solba Description: The Stolvizza dialect of Resian Description: The Solbica dialect of Resian @@ -45989,6 +46434,14 @@ local dialects of Resian %% Type: variant +Subtag: sotav +Description: The Sotavento dialect group of Kabuverdianu +Prefix: kea +Comments: Sotavento is one of the two main dialect groups of + Kabuverdianu. +Added: 2013-12-10 +%% +Type: variant Subtag: surmiran Description: Surmiran idiom of Romansh Added: 2010-06-29 @@ -46041,6 +46494,16 @@ Prefix: sco %% Type: variant +Subtag: unifon +Description: Unifon phonetic alphabet +Added: 2013-10-02 +Prefix: en +Prefix: hup +Prefix: kyh +Prefix: tol +Prefix: yur +%% +Type: variant Subtag: vaidika Description: Vedic Sanskrit Added: 2010-07-28 @@ -46081,11 +46544,15 @@ Tag: cel-gaulish Description: Gaulish Added: 2001-05-25 +Deprecated: 2015-03-29 +Comments: see xcg, xga, xtg %% Type: grandfathered Tag: en-GB-oed Description: English, Oxford English Dictionary spelling Added: 2003-07-09 +Deprecated: 2015-04-17 +Preferred-Value: en-GB-oxendict %% Type: grandfathered Tag: i-ami @@ -46110,6 +46577,7 @@ Tag: i-enochian Description: Enochian Added: 2002-07-03 +Deprecated: 2015-03-29 %% Type: grandfathered Tag: i-hak @@ -46226,6 +46694,7 @@ Description: Min, Fuzhou, Hokkien, Amoy, or Taiwanese Added: 1999-12-18 Deprecated: 2009-07-29 +Comments: see cdo, cpx, czo, mnp, nan %% Type: grandfathered Tag: zh-min-nan --- /dev/null 2016-06-10 11:07:20.941226000 +0530 +++ new/test/java/util/Locale/Bug8040211.java 2016-06-10 11:14:45.569898000 +0530 @@ -0,0 +1,353 @@ +/* + * Copyright (c) 2016, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8040211 + * @summary Checks the IANA language subtag registry data updation + * (LSR Revision: 2016-02-10) with Locale and Locale.LanguageRange + * class methods. + * @run main Bug8040211 + */ + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.Locale; +import java.util.List; +import java.util.Locale.LanguageRange; +import java.util.Locale.FilteringMode; +import static java.util.Locale.FilteringMode.EXTENDED_FILTERING; + +public class Bug8040211 { + + static boolean err = false; + + public static void main(String[] args) { + testLanguageRange(); + testLocale(); + + if (err) { + throw new RuntimeException("Failed."); + } + } + + private static void testLanguageRange() { + System.out.println("Test LanguageRange class parse method..."); + test_parse(); + } + + private static void testLocale() { + System.out.println("Test Locale class methods..."); + test_filter(); + test_filterTags(); + test_lookup(); + test_lookupTag(); + } + + private static void test_parse() { + boolean error = false; + String str = "Accept-Language: aam, adp, aue, ema, en-gb-oed," + + " gti, koj, kwq, kxe, lii, lmm, mtm, ngv, oyb, phr, pub," + + " suj, taj;q=0.9, yug;q=0.5, gfx;q=0.4"; + ArrayList expected = new ArrayList<>(); + expected.add(new LanguageRange("aam", 1.0)); + expected.add(new LanguageRange("aas", 1.0)); + expected.add(new LanguageRange("adp", 1.0)); + expected.add(new LanguageRange("dz", 1.0)); + expected.add(new LanguageRange("aue", 1.0)); + expected.add(new LanguageRange("ktz", 1.0)); + expected.add(new LanguageRange("ema", 1.0)); + expected.add(new LanguageRange("uok", 1.0)); + expected.add(new LanguageRange("en-gb-oed", 1.0)); + expected.add(new LanguageRange("en-gb-oxendict", 1.0)); + expected.add(new LanguageRange("gti", 1.0)); + expected.add(new LanguageRange("nyc", 1.0)); + expected.add(new LanguageRange("koj", 1.0)); + expected.add(new LanguageRange("kwv", 1.0)); + expected.add(new LanguageRange("kwq", 1.0)); + expected.add(new LanguageRange("yam", 1.0)); + expected.add(new LanguageRange("kxe", 1.0)); + expected.add(new LanguageRange("tvd", 1.0)); + expected.add(new LanguageRange("lii", 1.0)); + expected.add(new LanguageRange("raq", 1.0)); + expected.add(new LanguageRange("lmm", 1.0)); + expected.add(new LanguageRange("rmx", 1.0)); + expected.add(new LanguageRange("mtm", 1.0)); + expected.add(new LanguageRange("ymt", 1.0)); + expected.add(new LanguageRange("ngv", 1.0)); + expected.add(new LanguageRange("nnx", 1.0)); + expected.add(new LanguageRange("oyb", 1.0)); + expected.add(new LanguageRange("thx", 1.0)); + expected.add(new LanguageRange("phr", 1.0)); + expected.add(new LanguageRange("pmu", 1.0)); + expected.add(new LanguageRange("pub", 1.0)); + expected.add(new LanguageRange("puz", 1.0)); + expected.add(new LanguageRange("suj", 1.0)); + expected.add(new LanguageRange("xsj", 1.0)); + expected.add(new LanguageRange("taj", 0.9)); + expected.add(new LanguageRange("tsf", 0.9)); + expected.add(new LanguageRange("yug", 0.5)); + expected.add(new LanguageRange("yuu", 0.5)); + expected.add(new LanguageRange("gfx", 0.4)); + expected.add(new LanguageRange("oun", 0.4)); + expected.add(new LanguageRange("mwj", 0.4)); + expected.add(new LanguageRange("vaj", 0.4)); + List got = LanguageRange.parse(str); + if (!areEqual(expected, got)) { + error = true; + System.err.println(" language parse() test failed."); + } + + if (error) { + err = true; + System.err.println(" test_parse() failed."); + } else { + System.out.println(" test_parse() passed."); + } + + } + + private static boolean areEqual(List expected, + List got) { + boolean error = false; + + int expectedSize = expected.size(); + int actualSize = got.size(); + + if (expectedSize != actualSize) { + error = true; + + System.err.println(" Expected size=" + expectedSize); + for (LanguageRange lr : expected) { + System.err.println(" range=" + lr.getRange() + + ", weight=" + lr.getWeight()); + } + + System.out.println(" Actual size=" + actualSize); + for (LanguageRange lr : got) { + System.err.println(" range=" + lr.getRange() + + ", weight=" + lr.getWeight()); + } + } else { + for (int i = 0; i < expectedSize; i++) { + LanguageRange lr1 = expected.get(i); + LanguageRange lr2 = got.get(i); + + if (!lr1.getRange().equals(lr2.getRange()) + || lr1.getWeight() != lr2.getWeight()) { + error = true; + System.err.println(" " + i + ": Expected: range=" + lr1.getRange() + + ", weight=" + lr1.getWeight()); + System.err.println(" " + i + ": Actual: range=" + lr2.getRange() + + ", weight=" + lr2.getWeight()); + } + } + } + + return !error; + } + + private static void test_filter() { + boolean error = false; + + String ranges = "mtm-RU, en-gb-oed"; + String tags = "de-DE, en, mtm-RU, ymt-RU, en-gb-oxendict, ja-JP"; + FilteringMode mode = EXTENDED_FILTERING; + + List priorityList = LanguageRange.parse(ranges); + List tagList = generateLocales(tags); + String actualLocales + = showLocales(Locale.filter(priorityList, tagList, mode)); + String expectedLocales = "mtm-RU, ymt-RU, en-GB-oxendict"; + + if (!expectedLocales.equals(actualLocales)) { + error = true; + showErrorMessage("#1 filter(" + mode + ")", + ranges, tags, expectedLocales, actualLocales); + } + + ranges = "phr-*-IN, ja-JP"; + tags = "en, pmu-Guru-IN, ja-Latn-JP, iw"; + mode = EXTENDED_FILTERING; + + priorityList = LanguageRange.parse(ranges); + tagList = generateLocales(tags); + actualLocales = showLocales(Locale.filter(priorityList, tagList, mode)); + expectedLocales = "pmu-Guru-IN, ja-Latn-JP"; + + if (!expectedLocales.equals(actualLocales)) { + error = true; + showErrorMessage("#2 filter(" + mode + ")", + ranges, tags, expectedLocales, actualLocales); + } + + if (error) { + err = true; + System.out.println(" test_filter() failed."); + } else { + System.out.println(" test_filter() passed."); + } + } + + private static void test_filterTags() { + boolean error = false; + + String ranges = "gti;q=0.2, gfx"; + String tags = "de-DE, gti, he, nyc, mwj, vaj"; + + List priorityList = LanguageRange.parse(ranges); + List tagList = generateLanguageTags(tags); + String actualTags + = showLanguageTags(Locale.filterTags(priorityList, tagList)); + String expectedTags = "mwj, vaj, gti, nyc"; + + if (!expectedTags.equals(actualTags)) { + error = true; + showErrorMessage("filterTags()", + ranges, tags, expectedTags, actualTags); + } + + if (error) { + err = true; + System.out.println(" test_filterTags() failed."); + } else { + System.out.println(" test_filterTags() passed."); + } + } + + private static void test_lookup() { + boolean error = false; + + String ranges = "en;q=0.2, yam, rmx;q=0.9"; + String tags = "de-DE, en, kwq, lmm"; + List priorityList = LanguageRange.parse(ranges); + List localeList = generateLocales(tags); + String actualLocale + = Locale.lookup(priorityList, localeList).toLanguageTag(); + String expectedLocale = "kwq"; + + if (!expectedLocale.equals(actualLocale)) { + error = true; + showErrorMessage("lookup()", ranges, tags, expectedLocale, actualLocale); + } + + if (error) { + err = true; + System.out.println(" test_lookup() failed."); + } else { + System.out.println(" test_lookup() passed."); + } + } + + private static void test_lookupTag() { + boolean error = false; + + String ranges = "en, tsf;q=0.2"; + String tags = "es, ja-JP, taj"; + List priorityList = LanguageRange.parse(ranges); + List tagList = generateLanguageTags(tags); + String actualTag = Locale.lookupTag(priorityList, tagList); + String expectedTag = "taj"; + + if (!expectedTag.equals(actualTag)) { + error = true; + showErrorMessage("lookupTag()", ranges, tags, expectedTag, actualTag); + } + + if (error) { + err = true; + System.out.println(" test_lookupTag() failed."); + } else { + System.out.println(" test_lookupTag() passed."); + } + } + + private static List generateLocales(String tags) { + if (tags == null) { + return null; + } + + List localeList = new ArrayList<>(); + if (tags.equals("")) { + return localeList; + } + String[] t = tags.split(", "); + for (String tag : t) { + localeList.add(Locale.forLanguageTag(tag)); + } + return localeList; + } + + private static List generateLanguageTags(String tags) { + List tagList = new ArrayList<>(); + String[] t = tags.split(", "); + for (String tag : t) { + tagList.add(tag); + } + return tagList; + } + + private static String showLanguageTags(List tags) { + StringBuilder sb = new StringBuilder(); + + Iterator itr = tags.iterator(); + if (itr.hasNext()) { + sb.append(itr.next()); + } + while (itr.hasNext()) { + sb.append(", "); + sb.append(itr.next()); + } + + return sb.toString().trim(); + } + + private static String showLocales(List locales) { + StringBuilder sb = new StringBuilder(); + + java.util.Iterator itr = locales.iterator(); + if (itr.hasNext()) { + sb.append(itr.next().toLanguageTag()); + } + while (itr.hasNext()) { + sb.append(", "); + sb.append(itr.next().toLanguageTag()); + } + + return sb.toString().trim(); + } + + private static void showErrorMessage(String methodName, + String priorityList, + String tags, + String expectedTags, + String actualTags) { + System.out.println("\nIncorrect " + methodName + " result."); + System.out.println(" Priority list : " + priorityList); + System.out.println(" Language tags : " + tags); + System.out.println(" Expected value : " + expectedTags); + System.out.println(" Actual value : " + actualTags); + } + +} +