12ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller/* GENERATED SOURCE. DO NOT MODIFY. */
2f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert// © 2016 and later: Unicode, Inc. and others.
3f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert// License & terms of use: http://www.unicode.org/copyright.html#License
42ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller/*
52ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller *******************************************************************************
698d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert * Copyright (C) 2008-2015, Google, International Business Machines Corporation and
798d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert * others. All Rights Reserved.
82ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller *******************************************************************************
92ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */
102ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerpackage android.icu.text;
112ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
122ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport java.util.Arrays;
132ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport java.util.EnumSet;
142ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
1598d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubertimport android.icu.impl.StandardPlural;
162ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport android.icu.util.Freezable;
172ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport android.icu.util.Output;
182ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
192ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller/**
202ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Utility class for returning the plural category for a range of numbers, such as 1–5, so that appropriate messages can
212ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * be chosen. The rules for determining this value vary widely across locales.
22f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert *
232ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @author markdavis
242ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @deprecated This API is ICU internal only.
25836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller * @hide Only a subset of ICU is exposed in Android
26836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller * @hide draft / provisional / internal are hidden on Android
272ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */
282ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller@Deprecated
292ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerpublic final class PluralRanges implements Freezable<PluralRanges>, Comparable<PluralRanges> {
302ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
312ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    private volatile boolean isFrozen;
322ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    private Matrix matrix = new Matrix();
3398d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert    private boolean[] explicit = new boolean[StandardPlural.COUNT];
342ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
352ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
362ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * Constructor
37f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert     *
382ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @deprecated This API is ICU internal only.
39836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller     * @hide draft / provisional / internal are hidden on Android
402ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
412ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    @Deprecated
422ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public PluralRanges() {
432ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
442ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
452ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
462ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * Internal class for mapping from two StandardPluralCategories values to another.
472ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
482ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    private static final class Matrix implements Comparable<Matrix>, Cloneable {
4998d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert        private byte[] data = new byte[StandardPlural.COUNT * StandardPlural.COUNT];
502ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        {
512ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            for (int i = 0; i < data.length; ++i) {
522ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                data[i] = -1;
532ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            }
542ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        }
552ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
562ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        Matrix() {
572ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        }
582ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
592ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        /**
602ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller         * Internal method for setting.
612ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller         */
622ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        @SuppressWarnings("unused")
6398d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert        void set(StandardPlural start, StandardPlural end, StandardPlural result) {
6498d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert            data[start.ordinal() * StandardPlural.COUNT + end.ordinal()] = result == null ? (byte) -1
652ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                    : (byte) result.ordinal();
662ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        }
672ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
682ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        /**
692ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller         * Internal method for setting; throws exception if already set.
702ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller         */
7198d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert        void setIfNew(StandardPlural start, StandardPlural end,
7298d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert                StandardPlural result) {
7398d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert            byte old = data[start.ordinal() * StandardPlural.COUNT + end.ordinal()];
742ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            if (old >= 0) {
752ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                throw new IllegalArgumentException("Previously set value for <" + start + ", " + end + ", "
7698d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert                        + StandardPlural.VALUES.get(old) + ">");
772ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            }
7898d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert            data[start.ordinal() * StandardPlural.COUNT + end.ordinal()] = result == null ? (byte) -1
792ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                    : (byte) result.ordinal();
802ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        }
812ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
822ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        /**
832ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller         * Internal method for getting.
842ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller         */
8598d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert        StandardPlural get(StandardPlural start, StandardPlural end) {
8698d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert            byte result = data[start.ordinal() * StandardPlural.COUNT + end.ordinal()];
8798d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert            return result < 0 ? null : StandardPlural.VALUES.get(result);
882ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        }
892ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
902ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        /**
912ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller         * Internal method to see if <*,end> values are all the same.
922ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller         */
932ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        @SuppressWarnings("unused")
9498d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert        StandardPlural endSame(StandardPlural end) {
9598d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert            StandardPlural first = null;
9698d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert            for (StandardPlural start : StandardPlural.VALUES) {
9798d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert                StandardPlural item = get(start, end);
982ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                if (item == null) {
992ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                    continue;
1002ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                }
1012ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                if (first == null) {
1022ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                    first = item;
1032ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                    continue;
1042ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                }
1052ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                if (first != item) {
1062ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                    return null;
1072ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                }
1082ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            }
1092ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            return first;
1102ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        }
1112ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
1122ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        /**
1132ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller         * Internal method to see if <start,*> values are all the same.
1142ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller         */
1152ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        @SuppressWarnings("unused")
11698d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert        StandardPlural startSame(StandardPlural start,
11798d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert                EnumSet<StandardPlural> endDone, Output<Boolean> emit) {
1182ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            emit.value = false;
11998d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert            StandardPlural first = null;
12098d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert            for (StandardPlural end : StandardPlural.VALUES) {
12198d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert                StandardPlural item = get(start, end);
1222ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                if (item == null) {
1232ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                    continue;
1242ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                }
1252ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                if (first == null) {
1262ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                    first = item;
1272ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                    continue;
1282ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                }
1292ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                if (first != item) {
1302ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                    return null;
1312ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                }
1322ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                // only emit if we didn't cover with the 'end' values
1332ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                if (!endDone.contains(end)) {
1342ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                    emit.value = true;
1352ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                }
1362ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            }
1372ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            return first;
1382ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        }
1392ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
1402ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        @Override
1412ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        public int hashCode() {
1422ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            int result = 0;
1432ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            for (int i = 0; i < data.length; ++i) {
1442ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                result = result * 37 + data[i];
1452ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            }
1462ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            return result;
1472ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        }
1482ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
1492ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        @Override
1502ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        public boolean equals(Object other) {
1512ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            if (!(other instanceof Matrix)) {
1522ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                return false;
1532ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            }
1542ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            return 0 == compareTo((Matrix) other);
1552ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        }
1562ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
157f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert        @Override
1582ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        public int compareTo(Matrix o) {
1592ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            for (int i = 0; i < data.length; ++i) {
1602ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                int diff = data[i] - o.data[i];
1612ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                if (diff != 0) {
1622ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                    return diff;
1632ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                }
1642ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            }
1652ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            return 0;
1662ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        }
1672ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
1682ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        @Override
1692ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        public Matrix clone() {
1702ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            Matrix result = new Matrix();
1712ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            result.data = data.clone();
1722ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            return result;
1732ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        }
174f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert
1752ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        @Override
1762ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        public String toString() {
1772ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            StringBuilder result = new StringBuilder();
17898d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert            for (StandardPlural i : StandardPlural.values()) {
17998d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert                for (StandardPlural j : StandardPlural.values()) {
18098d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert                    StandardPlural x = get(i, j);
1812ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                    if (x != null) {
1822ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                        result.append(i + " & " + j + " → " + x + ";\n");
1832ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                    }
1842ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                }
1852ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            }
1862ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            return result.toString();
1872ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        }
1882ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
1892ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
1902ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
1912ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * Internal method for building. If the start or end are null, it means everything of that type.
192f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert     *
1932ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @param rangeStart
1942ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *            plural category for the start of the range
1952ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @param rangeEnd
1962ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *            plural category for the end of the range
1972ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @param result
1982ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *            the resulting plural category
1992ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @deprecated This API is ICU internal only.
200836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller     * @hide draft / provisional / internal are hidden on Android
2012ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
2022ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    @Deprecated
20398d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert    public void add(StandardPlural rangeStart, StandardPlural rangeEnd,
20498d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert            StandardPlural result) {
2052ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        if (isFrozen) {
2062ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            throw new UnsupportedOperationException();
2072ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        }
2082ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        explicit[result.ordinal()] = true;
2092ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        if (rangeStart == null) {
21098d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert            for (StandardPlural rs : StandardPlural.values()) {
2112ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                if (rangeEnd == null) {
21298d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert                    for (StandardPlural re : StandardPlural.values()) {
2132ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                        matrix.setIfNew(rs, re, result);
2142ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                    }
2152ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                } else {
2162ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                    explicit[rangeEnd.ordinal()] = true;
2172ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                    matrix.setIfNew(rs, rangeEnd, result);
2182ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                }
2192ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            }
2202ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        } else if (rangeEnd == null) {
2212ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            explicit[rangeStart.ordinal()] = true;
22298d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert            for (StandardPlural re : StandardPlural.values()) {
2232ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                matrix.setIfNew(rangeStart, re, result);
2242ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            }
2252ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        } else {
2262ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            explicit[rangeStart.ordinal()] = true;
2272ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            explicit[rangeEnd.ordinal()] = true;
2282ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            matrix.setIfNew(rangeStart, rangeEnd, result);
2292ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        }
2302ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
2312ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
2322ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
2332ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * Returns the appropriate plural category for a range from start to end. If there is no available data, then
2342ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * 'end' is returned as an implicit value. (Such an implicit value can be tested for with {@link #isExplicit}.)
235f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert     *
2362ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @param start
2372ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *            plural category for the start of the range
2382ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @param end
2392ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *            plural category for the end of the range
2402ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @return the resulting plural category, or 'end' if there is no data.
2412ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @deprecated This API is ICU internal only.
242836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller     * @hide draft / provisional / internal are hidden on Android
2432ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
2442ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    @Deprecated
24598d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert    public StandardPlural get(StandardPlural start, StandardPlural end) {
24698d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert        StandardPlural result = matrix.get(start, end);
2472ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return result == null ? end : result;
2482ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
2492ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
2502ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
2512ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * Returns whether the appropriate plural category for a range from start to end
2522ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * is explicitly in the data (vs given an implicit value). See also {@link #get}.
253f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert     *
2542ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @param start
2552ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *            plural category for the start of the range
2562ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @param end
2572ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *            plural category for the end of the range
2582ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @return whether the value for (start,end) is explicit or not.
2592ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @deprecated This API is ICU internal only.
260836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller     * @hide draft / provisional / internal are hidden on Android
2612ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
2622ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    @Deprecated
26398d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert    public boolean isExplicit(StandardPlural start, StandardPlural end) {
2642ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return matrix.get(start, end) != null;
2652ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
2662ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
2672ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
2682ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * Internal method to determines whether the StandardPluralCategories was explicitly used in any add statement.
269f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert     *
2702ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @param count
2712ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *            plural category to test
2722ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @return true if set
2732ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @deprecated This API is ICU internal only.
274836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller     * @hide draft / provisional / internal are hidden on Android
2752ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
2762ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    @Deprecated
27798d264ec1d3841aef62c0e0293c929c23c08c5c5Fredrik Roubert    public boolean isExplicitlySet(StandardPlural count) {
2782ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return explicit[count.ordinal()];
2792ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
2802ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
2812ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
2822ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * {@inheritDoc}
2832ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @deprecated This API is ICU internal only.
284836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller     * @hide draft / provisional / internal are hidden on Android
2852ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
2862ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    @Deprecated
2872ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    @Override
2882ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public boolean equals(Object other) {
2892ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        if (this == other) {
2902ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            return true;
2912ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        }
2922ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        if (!(other instanceof PluralRanges)) {
2932ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            return false;
2942ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        }
2952ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        PluralRanges otherPR = (PluralRanges)other;
2962ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return matrix.equals(otherPR.matrix) && Arrays.equals(explicit, otherPR.explicit);
2972ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
2982ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
2992ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
3002ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * {@inheritDoc}
3012ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @deprecated This API is ICU internal only.
302836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller     * @hide draft / provisional / internal are hidden on Android
3032ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
3042ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    @Override
3052ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    @Deprecated
3062ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public int hashCode() {
3072ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return matrix.hashCode();
3082ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
3092ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
3102ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
3112ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * {@inheritDoc}
3122ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @deprecated This API is ICU internal only.
313836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller     * @hide draft / provisional / internal are hidden on Android
3142ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
315f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert    @Override
3162ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    @Deprecated
3172ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public int compareTo(PluralRanges that) {
3182ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return matrix.compareTo(that.matrix);
3192ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
3202ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
3212ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
3222ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * {@inheritDoc}
3232ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @deprecated This API is ICU internal only.
324836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller     * @hide draft / provisional / internal are hidden on Android
3252ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
326f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert    @Override
3272ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    @Deprecated
3282ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public boolean isFrozen() {
3292ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return isFrozen;
3302ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
3312ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
3322ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
3332ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * {@inheritDoc}
3342ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @deprecated This API is ICU internal only.
335836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller     * @hide draft / provisional / internal are hidden on Android
3362ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
337f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert    @Override
3382ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    @Deprecated
3392ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public PluralRanges freeze() {
3402ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        isFrozen = true;
3412ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return this;
3422ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
3432ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
3442ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
3452ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * {@inheritDoc}
3462ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @deprecated This API is ICU internal only.
347836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller     * @hide draft / provisional / internal are hidden on Android
3482ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
349f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert    @Override
3502ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    @Deprecated
3512ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public PluralRanges cloneAsThawed() {
3522ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        PluralRanges result = new PluralRanges();
3532ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        result.explicit = explicit.clone();
3542ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        result.matrix = matrix.clone();
3552ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return result;
3562ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
3572ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
3582ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
3592ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * {@inheritDoc}
3602ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @deprecated This API is ICU internal only.
361836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller     * @hide draft / provisional / internal are hidden on Android
3622ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
3632ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    @Override
3642ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    @Deprecated
3652ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public String toString() {
3662ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return matrix.toString();
3672ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
3682ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller}