jdk/test/java/util/Locale/Bug8035133.java
author nishjain
Wed, 03 Aug 2016 09:37:57 +0900
changeset 40114 0194b0ba95c6
permissions -rw-r--r--
8035133: Locale matching: Weight q=0 isn't handled correctly. Reviewed-by: okutsu, peytoia
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
40114
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
     1
/*
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
     4
 *
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
     7
 * published by the Free Software Foundation.
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
     8
 *
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    13
 * accompanied this code).
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    14
 *
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    18
 *
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    21
 * questions.
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    22
 */
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    23
/*
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    24
 * @test
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    25
 * @bug 8035133
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    26
 * @summary Checks that the tags matching the range with quality weight q=0
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    27
 *          e.g. en;q=0 must be elimited and must not be the part of output
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    28
 */
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    29
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    30
import java.util.ArrayList;
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    31
import java.util.Iterator;
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    32
import java.util.List;
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    33
import java.util.Locale;
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    34
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    35
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    36
public class Bug8035133 {
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    37
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    38
    private static boolean err = false;
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    39
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    40
    public static void main(String[] args) {
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    41
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    42
        // checking Locale.lookup with de-ch;q=0
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    43
        checkLookup("en;q=0.1, *-ch;q=0.5, de-ch;q=0",
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    44
                "de-ch, en, fr-ch", "fr-CH");
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    45
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    46
        /* checking Locale.lookup with *;q=0 '*' should be ignored
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    47
         * in lookup
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    48
         */
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    49
        checkLookup("en;q=0.1, *-ch;q=0.5, *;q=0",
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    50
                "de-ch, en, fr-ch", "de-CH");
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    51
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    52
        // checking Locale.filter with fr-ch;q=0 in BASIC_FILTERING
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    53
        checkFilter("en;q=0.1, fr-ch;q=0.0, de-ch;q=0.5",
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    54
                "de-ch, en, fr-ch", "de-CH, en");
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    55
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    56
        // checking Locale.filter with *;q=0 in BASIC_FILTERING
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    57
        checkFilter("de-ch;q=0.6, *;q=0", "de-ch, fr-ch", "");
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    58
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    59
        // checking Locale.filter with *;q=0 in BASIC_FILTERING
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    60
        checkFilter("de-ch;q=0.6, de;q=0", "de-ch", "");
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    61
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    62
        // checking Locale.filter with *;q=0.6, en;q=0 in BASIC_FILTERING
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    63
        checkFilter("*;q=0.6, en;q=0", "de-ch, hi-in, en", "de-CH, hi-IN");
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    64
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    65
        // checking Locale.filter with de-ch;q=0 in EXTENDED_FILTERING
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    66
        checkFilter("en;q=0.1, *-ch;q=0.5, de-ch;q=0",
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    67
                "de-ch, en, fr-ch", "fr-CH, en");
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    68
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    69
        /* checking Locale.filter with *-ch;q=0 in EXTENDED_FILTERING which
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    70
         * must make filter to return "" empty or no match
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    71
         */
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    72
        checkFilter("de-ch;q=0.5, *-ch;q=0", "de-ch, fr-ch", "");
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    73
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    74
        /* checking Locale.filter with *;q=0 in EXTENDED_FILTERING which
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    75
         * must make filter to return "" empty or no match
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    76
         */
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    77
        checkFilter("*-ch;q=0.5, *;q=0", "de-ch, fr-ch", "");
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    78
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    79
        /* checking Locale.filter with *;q=0.6, *-Latn;q=0 in
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    80
         * EXTENDED_FILTERING
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    81
         */
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    82
        checkFilter("*;q=0.6, *-Latn;q=0", "de-ch, hi-in, en-Latn",
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    83
                "de-CH, hi-IN");
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    84
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    85
        if (err) {
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    86
            throw new RuntimeException("[LocaleMatcher method(s) failed]");
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    87
        }
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    88
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    89
    }
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    90
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    91
    private static void checkLookup(String ranges, String tags,
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    92
            String expectedLocale) {
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    93
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    94
        List<Locale.LanguageRange> priorityList = Locale.LanguageRange
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    95
                .parse(ranges);
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    96
        List<Locale> localeList = generateLocales(tags);
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    97
        Locale loc = Locale.lookup(priorityList, localeList);
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    98
        String actualLocale
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
    99
                = loc.toLanguageTag();
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   100
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   101
        if (!actualLocale.equals(expectedLocale)) {
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   102
            System.err.println("Locale.lookup failed with ranges: " + ranges
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   103
                    + " Expected: " + expectedLocale
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   104
                    + " Actual: " + actualLocale);
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   105
            err = true;
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   106
        }
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   107
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   108
    }
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   109
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   110
    private static void checkFilter(String ranges, String tags,
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   111
            String expectedLocales) {
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   112
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   113
        List<Locale.LanguageRange> priorityList = Locale.LanguageRange
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   114
                .parse(ranges);
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   115
        List<Locale> localeList = generateLocales(tags);
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   116
        String actualLocales = getLocalesAsString(
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   117
                Locale.filter(priorityList, localeList));
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   118
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   119
        if (!actualLocales.equals(expectedLocales)) {
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   120
            System.err.println("Locale.filter failed with ranges: " + ranges
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   121
                    + " Expected: " + expectedLocales
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   122
                    + " Actual: " + actualLocales);
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   123
            err = true;
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   124
        }
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   125
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   126
    }
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   127
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   128
    private static List<Locale> generateLocales(String tags) {
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   129
        if (tags == null) {
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   130
            return null;
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   131
        }
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   132
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   133
        List<Locale> localeList = new ArrayList<>();
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   134
        if (tags.equals("")) {
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   135
            return localeList;
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   136
        }
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   137
        String[] t = tags.split(", ");
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   138
        for (String tag : t) {
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   139
            localeList.add(Locale.forLanguageTag(tag));
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   140
        }
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   141
        return localeList;
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   142
    }
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   143
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   144
    private static String getLocalesAsString(List<Locale> locales) {
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   145
        StringBuilder sb = new StringBuilder();
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   146
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   147
        Iterator<Locale> itr = locales.iterator();
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   148
        if (itr.hasNext()) {
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   149
            sb.append(itr.next().toLanguageTag());
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   150
        }
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   151
        while (itr.hasNext()) {
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   152
            sb.append(", ");
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   153
            sb.append(itr.next().toLanguageTag());
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   154
        }
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   155
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   156
        return sb.toString().trim();
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   157
    }
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   158
0194b0ba95c6 8035133: Locale matching: Weight q=0 isn't handled correctly.
nishjain
parents:
diff changeset
   159
}