Search in sources :

Example 6 with StandardPlural

use of android.icu.impl.StandardPlural in project j2objc by google.

the class PluralRanges method add.

/**
 * Internal method for building. If the start or end are null, it means everything of that type.
 *
 * @param rangeStart
 *            plural category for the start of the range
 * @param rangeEnd
 *            plural category for the end of the range
 * @param result
 *            the resulting plural category
 * @deprecated This API is ICU internal only.
 * @hide draft / provisional / internal are hidden on Android
 */
@Deprecated
public void add(StandardPlural rangeStart, StandardPlural rangeEnd, StandardPlural result) {
    if (isFrozen) {
        throw new UnsupportedOperationException();
    }
    explicit[result.ordinal()] = true;
    if (rangeStart == null) {
        for (StandardPlural rs : StandardPlural.values()) {
            if (rangeEnd == null) {
                for (StandardPlural re : StandardPlural.values()) {
                    matrix.setIfNew(rs, re, result);
                }
            } else {
                explicit[rangeEnd.ordinal()] = true;
                matrix.setIfNew(rs, rangeEnd, result);
            }
        }
    } else if (rangeEnd == null) {
        explicit[rangeStart.ordinal()] = true;
        for (StandardPlural re : StandardPlural.values()) {
            matrix.setIfNew(rangeStart, re, result);
        }
    } else {
        explicit[rangeStart.ordinal()] = true;
        explicit[rangeEnd.ordinal()] = true;
        matrix.setIfNew(rangeStart, rangeEnd, result);
    }
}
Also used : StandardPlural(android.icu.impl.StandardPlural)

Example 7 with StandardPlural

use of android.icu.impl.StandardPlural in project j2objc by google.

the class PluralRangesTest method TestBasic.

@Test
public void TestBasic() {
    PluralRanges a = new PluralRanges();
    a.add(StandardPlural.ONE, StandardPlural.OTHER, StandardPlural.ONE);
    StandardPlural actual = a.get(StandardPlural.ONE, StandardPlural.OTHER);
    assertEquals("range", StandardPlural.ONE, actual);
    a.freeze();
    try {
        a.add(StandardPlural.ONE, StandardPlural.ONE, StandardPlural.ONE);
        errln("Failed to cause exception on frozen instance");
    } catch (UnsupportedOperationException e) {
    }
}
Also used : StandardPlural(android.icu.impl.StandardPlural) PluralRanges(android.icu.text.PluralRanges) Test(org.junit.Test)

Aggregations

StandardPlural (android.icu.impl.StandardPlural)7 PluralRanges (android.icu.text.PluralRanges)2 Currency (android.icu.util.Currency)2 MeasureUnit (android.icu.util.MeasureUnit)2 Test (org.junit.Test)2 DontCareFieldPosition (android.icu.impl.DontCareFieldPosition)1 CurrencyAmount (android.icu.util.CurrencyAmount)1 ULocale (android.icu.util.ULocale)1