/*
*******************************************************************************
- * Copyright (C) 2008-2014, International Business Machines Corporation and *
- * others. All Rights Reserved. *
+ * Copyright (C) 2008-2015, International Business Machines Corporation and
+ * others. All Rights Reserved.
*******************************************************************************
*/
package com.ibm.icu.impl;
import com.ibm.icu.text.PluralRanges;
import com.ibm.icu.text.PluralRules;
import com.ibm.icu.text.PluralRules.PluralType;
-import com.ibm.icu.text.PluralRules.StandardPluralCategories;
import com.ibm.icu.util.ULocale;
import com.ibm.icu.util.UResourceBundle;
pr = new PluralRanges();
} else {
pr.add(
- StandardPluralCategories.valueOf(row[0]),
- StandardPluralCategories.valueOf(row[1]),
- StandardPluralCategories.valueOf(row[2]));
+ StandardPlural.fromString(row[0]),
+ StandardPlural.fromString(row[1]),
+ StandardPlural.fromString(row[2]));
}
}
// do last one
--- /dev/null
+/*
+ *******************************************************************************
+ * Copyright (C) 2015, International Business Machines Corporation and
+ * others. All Rights Reserved.
+ *******************************************************************************
+ */
+package com.ibm.icu.impl;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Standard CLDR plural form/category constants.
+ * See http://www.unicode.org/reports/tr35/tr35-numbers.html#Language_Plural_Rules
+ */
+public enum StandardPlural {
+ ZERO("zero"),
+ ONE("one"),
+ TWO("two"),
+ FEW("few"),
+ MANY("many"),
+ OTHER("other");
+
+ /**
+ * Numeric index of OTHER, same as OTHER.ordinal().
+ */
+ public static final int OTHER_INDEX = OTHER.ordinal();
+
+ /**
+ * Unmodifiable List of all standard plural form constants.
+ * List version of {@link #values()}.
+ */
+ public static final List<StandardPlural> VALUES =
+ Collections.unmodifiableList(Arrays.asList(values()));
+
+ /**
+ * Number of standard plural forms/categories.
+ */
+ public static final int COUNT = VALUES.size();
+
+ private final String keyword;
+
+ private StandardPlural(String kw) {
+ keyword = kw;
+ }
+
+ /**
+ * @return the lowercase CLDR keyword string for the plural form
+ */
+ public final String getKeyword() {
+ return keyword;
+ }
+
+ /**
+ * @param keyword for example "few" or "other"
+ * @return the plural form corresponding to the keyword, or null
+ */
+ public static final StandardPlural orNullFromString(CharSequence keyword) {
+ switch (keyword.length()) {
+ case 3:
+ if ("one".contentEquals(keyword)) {
+ return ONE;
+ } else if ("two".contentEquals(keyword)) {
+ return TWO;
+ } else if ("few".contentEquals(keyword)) {
+ return FEW;
+ }
+ break;
+ case 4:
+ if ("many".contentEquals(keyword)) {
+ return MANY;
+ } else if ("zero".contentEquals(keyword)) {
+ return ZERO;
+ }
+ break;
+ case 5:
+ if ("other".contentEquals(keyword)) {
+ return OTHER;
+ }
+ break;
+ default:
+ break;
+ }
+ return null;
+ }
+
+ /**
+ * @param keyword for example "few" or "other"
+ * @return the plural form corresponding to the keyword, or OTHER
+ */
+ public static final StandardPlural orOtherFromString(CharSequence keyword) {
+ StandardPlural p = orNullFromString(keyword);
+ return p != null ? p : OTHER;
+ }
+
+ /**
+ * @param keyword for example "few" or "other"
+ * @return the plural form corresponding to the keyword
+ * @throws IllegalArgumentException if the keyword is not a plural form
+ */
+ public static final StandardPlural fromString(CharSequence keyword) {
+ StandardPlural p = orNullFromString(keyword);
+ if (p != null) {
+ return p;
+ } else {
+ throw new IllegalArgumentException(keyword.toString());
+ }
+ }
+
+ /**
+ * @param keyword for example "few" or "other"
+ * @return the index of the plural form corresponding to the keyword, or a negative value
+ */
+ public static final int indexOrNegativeFromString(CharSequence keyword) {
+ StandardPlural p = orNullFromString(keyword);
+ return p != null ? p.ordinal() : -1;
+ }
+
+ /**
+ * @param keyword for example "few" or "other"
+ * @return the index of the plural form corresponding to the keyword, or OTHER_INDEX
+ */
+ public static final int indexOrOtherIndexFromString(CharSequence keyword) {
+ StandardPlural p = orNullFromString(keyword);
+ return p != null ? p.ordinal() : OTHER.ordinal();
+ }
+
+ /**
+ * @param keyword for example "few" or "other"
+ * @return the index of the plural form corresponding to the keyword
+ * @throws IllegalArgumentException if the keyword is not a plural form
+ */
+ public static final int indexFromString(CharSequence keyword) {
+ StandardPlural p = orNullFromString(keyword);
+ if (p != null) {
+ return p.ordinal();
+ } else {
+ throw new IllegalArgumentException(keyword.toString());
+ }
+ }
+}
\ No newline at end of file
import com.ibm.icu.impl.ICUResourceBundle;
import com.ibm.icu.impl.SimpleCache;
import com.ibm.icu.impl.SimplePatternFormatter;
+import com.ibm.icu.impl.StandardPlural;
import com.ibm.icu.impl.UResource;
import com.ibm.icu.math.BigDecimal;
import com.ibm.icu.text.PluralRules.Factory;
-import com.ibm.icu.text.PluralRules.StandardPluralCategories;
import com.ibm.icu.util.Currency;
import com.ibm.icu.util.CurrencyAmount;
import com.ibm.icu.util.ICUException;
highFpos.getCountVisibleFractionDigits(), highFpos.getFractionDigits()));
final PluralRanges pluralRanges = Factory.getDefaultFactory().getPluralRanges(getLocale());
- StandardPluralCategories resolvedCategory = pluralRanges.get(
- StandardPluralCategories.valueOf(keywordLow), StandardPluralCategories.valueOf(keywordHigh));
+ StandardPlural resolvedPlural = pluralRanges.get(
+ StandardPlural.fromString(keywordLow),
+ StandardPlural.fromString(keywordHigh));
SimplePatternFormatter rangeFormatter = getRangeFormat(getLocale(), formatWidth);
String formattedNumber = rangeFormatter.format(lowFormatted, highFormatted);
Currency currencyUnit = (Currency) unit;
StringBuilder result = new StringBuilder();
- appendReplacingCurrency(currencyFormat.getPrefix(lowDouble >= 0), currencyUnit, resolvedCategory, result);
+ appendReplacingCurrency(currencyFormat.getPrefix(lowDouble >= 0), currencyUnit, resolvedPlural, result);
result.append(formattedNumber);
- appendReplacingCurrency(currencyFormat.getSuffix(highDouble >= 0), currencyUnit, resolvedCategory, result);
+ appendReplacingCurrency(currencyFormat.getSuffix(highDouble >= 0), currencyUnit, resolvedPlural, result);
return result.toString();
// StringBuffer buffer = new StringBuffer();
// CurrencyAmount currencyLow = (CurrencyAmount) lowValue;
// currencyFormat.format(currencyHigh, buffer2, pos2);
} else {
SimplePatternFormatter formatter =
- getPluralFormatter(lowValue.getUnit(), formatWidth, resolvedCategory.ordinal());
+ getPluralFormatter(lowValue.getUnit(), formatWidth, resolvedPlural.ordinal());
return formatter.format(formattedNumber);
}
}
- private void appendReplacingCurrency(String affix, Currency unit, StandardPluralCategories resolvedCategory, StringBuilder result) {
+ private void appendReplacingCurrency(String affix, Currency unit, StandardPlural resolvedPlural, StringBuilder result) {
String replacement = "¤";
int pos = affix.indexOf(replacement);
if (pos < 0) {
} else {
result.append(unit.getName(currencyFormat.nf.getLocale(ULocale.ACTUAL_LOCALE),
currentStyle == NumberFormat.CURRENCYSTYLE ? Currency.SYMBOL_NAME : Currency.PLURAL_LONG_NAME,
- resolvedCategory.toString(), null));
+ resolvedPlural.getKeyword(), null));
}
result.append(affix.substring(pos+replacement.length()));
}
// The key must be one of the plural form strings. For example:
// one{"{0} hr"}
// other{"{0} hrs"}
- setFormatterIfAbsent(StandardPluralCategories.getIndex(key), value, 0);
+ setFormatterIfAbsent(StandardPlural.indexFromString(key), value, 0);
}
}
}
}
private SimplePatternFormatter getPluralFormatter(MeasureUnit unit, FormatWidth width, int index) {
- if (index != StandardPluralCategories.OTHER_INDEX) {
+ if (index != StandardPlural.OTHER_INDEX) {
SimplePatternFormatter pattern = getFormatterOrNull(unit, width, index);
if (pattern != null) {
return pattern;
}
}
- return getFormatter(unit, width, StandardPluralCategories.OTHER_INDEX);
+ return getFormatter(unit, width, StandardPlural.OTHER_INDEX);
}
private SimplePatternFormatter getPerFormatter(FormatWidth width) {
}
SimplePatternFormatter perPattern = getPerFormatter(formatWidth);
SimplePatternFormatter pattern =
- getPluralFormatter(perUnit, formatWidth, StandardPluralCategories.one.ordinal());
+ getPluralFormatter(perUnit, formatWidth, StandardPlural.ONE.ordinal());
String perUnitString = pattern.getPatternWithNoPlaceholders().trim();
perPattern.formatAndAppend(appendTo, offsets, formatted, perUnitString);
return offsets[0];
StringBuffer formattedNumber = nf.format(n, new StringBuffer(), fpos);
String keyword = rules.select(new PluralRules.FixedDecimal(n.doubleValue(), fpos.getCountVisibleFractionDigits(), fpos.getFractionDigits()));
- int pluralForm = StandardPluralCategories.getIndexOrOtherIndex(keyword);
+ int pluralForm = StandardPlural.indexOrOtherIndexFromString(keyword);
SimplePatternFormatter formatter = getPluralFormatter(unit, formatWidth, pluralForm);
int[] offsets = new int[1];
formatter.formatAndAppend(appendTo, offsets, formattedNumber);
* TODO: Maybe store more sparsely in general, with pointers rather than potentially-empty objects.
*/
private static final class MeasureFormatData {
- static final int PER_UNIT_INDEX = StandardPluralCategories.COUNT;
+ static final int PER_UNIT_INDEX = StandardPlural.COUNT;
static final int PATTERN_COUNT = PER_UNIT_INDEX + 1;
boolean hasPerFormatter(FormatWidth width) {
/*
*******************************************************************************
- * Copyright (C) 2008-2014, Google, International Business Machines Corporation and *
- * others. All Rights Reserved. *
+ * Copyright (C) 2008-2015, Google, International Business Machines Corporation and
+ * others. All Rights Reserved.
*******************************************************************************
*/
package com.ibm.icu.text;
import java.util.Arrays;
import java.util.EnumSet;
-import com.ibm.icu.text.PluralRules.StandardPluralCategories;
+import com.ibm.icu.impl.StandardPlural;
import com.ibm.icu.util.Freezable;
import com.ibm.icu.util.Output;
private volatile boolean isFrozen;
private Matrix matrix = new Matrix();
- private boolean[] explicit = new boolean[StandardPluralCategories.COUNT];
+ private boolean[] explicit = new boolean[StandardPlural.COUNT];
/**
* Constructor
* Internal class for mapping from two StandardPluralCategories values to another.
*/
private static final class Matrix implements Comparable<Matrix>, Cloneable {
- private byte[] data = new byte[StandardPluralCategories.COUNT * StandardPluralCategories.COUNT];
+ private byte[] data = new byte[StandardPlural.COUNT * StandardPlural.COUNT];
{
for (int i = 0; i < data.length; ++i) {
data[i] = -1;
* Internal method for setting.
*/
@SuppressWarnings("unused")
- void set(StandardPluralCategories start, StandardPluralCategories end, StandardPluralCategories result) {
- data[start.ordinal() * StandardPluralCategories.COUNT + end.ordinal()] = result == null ? (byte) -1
+ void set(StandardPlural start, StandardPlural end, StandardPlural result) {
+ data[start.ordinal() * StandardPlural.COUNT + end.ordinal()] = result == null ? (byte) -1
: (byte) result.ordinal();
}
/**
* Internal method for setting; throws exception if already set.
*/
- void setIfNew(StandardPluralCategories start, StandardPluralCategories end,
- StandardPluralCategories result) {
- byte old = data[start.ordinal() * StandardPluralCategories.COUNT + end.ordinal()];
+ void setIfNew(StandardPlural start, StandardPlural end,
+ StandardPlural result) {
+ byte old = data[start.ordinal() * StandardPlural.COUNT + end.ordinal()];
if (old >= 0) {
throw new IllegalArgumentException("Previously set value for <" + start + ", " + end + ", "
- + StandardPluralCategories.VALUES.get(old) + ">");
+ + StandardPlural.VALUES.get(old) + ">");
}
- data[start.ordinal() * StandardPluralCategories.COUNT + end.ordinal()] = result == null ? (byte) -1
+ data[start.ordinal() * StandardPlural.COUNT + end.ordinal()] = result == null ? (byte) -1
: (byte) result.ordinal();
}
/**
* Internal method for getting.
*/
- StandardPluralCategories get(StandardPluralCategories start, StandardPluralCategories end) {
- byte result = data[start.ordinal() * StandardPluralCategories.COUNT + end.ordinal()];
- return result < 0 ? null : StandardPluralCategories.VALUES.get(result);
+ StandardPlural get(StandardPlural start, StandardPlural end) {
+ byte result = data[start.ordinal() * StandardPlural.COUNT + end.ordinal()];
+ return result < 0 ? null : StandardPlural.VALUES.get(result);
}
/**
* Internal method to see if <*,end> values are all the same.
*/
@SuppressWarnings("unused")
- StandardPluralCategories endSame(StandardPluralCategories end) {
- StandardPluralCategories first = null;
- for (StandardPluralCategories start : StandardPluralCategories.VALUES) {
- StandardPluralCategories item = get(start, end);
+ StandardPlural endSame(StandardPlural end) {
+ StandardPlural first = null;
+ for (StandardPlural start : StandardPlural.VALUES) {
+ StandardPlural item = get(start, end);
if (item == null) {
continue;
}
* Internal method to see if <start,*> values are all the same.
*/
@SuppressWarnings("unused")
- StandardPluralCategories startSame(StandardPluralCategories start,
- EnumSet<StandardPluralCategories> endDone, Output<Boolean> emit) {
+ StandardPlural startSame(StandardPlural start,
+ EnumSet<StandardPlural> endDone, Output<Boolean> emit) {
emit.value = false;
- StandardPluralCategories first = null;
- for (StandardPluralCategories end : StandardPluralCategories.VALUES) {
- StandardPluralCategories item = get(start, end);
+ StandardPlural first = null;
+ for (StandardPlural end : StandardPlural.VALUES) {
+ StandardPlural item = get(start, end);
if (item == null) {
continue;
}
@Override
public String toString() {
StringBuilder result = new StringBuilder();
- for (StandardPluralCategories i : StandardPluralCategories.values()) {
- for (StandardPluralCategories j : StandardPluralCategories.values()) {
- StandardPluralCategories x = get(i, j);
+ for (StandardPlural i : StandardPlural.values()) {
+ for (StandardPlural j : StandardPlural.values()) {
+ StandardPlural x = get(i, j);
if (x != null) {
result.append(i + " & " + j + " → " + x + ";\n");
}
* @deprecated This API is ICU internal only.
*/
@Deprecated
- public void add(StandardPluralCategories rangeStart, StandardPluralCategories rangeEnd,
- StandardPluralCategories result) {
+ public void add(StandardPlural rangeStart, StandardPlural rangeEnd,
+ StandardPlural result) {
if (isFrozen) {
throw new UnsupportedOperationException();
}
explicit[result.ordinal()] = true;
if (rangeStart == null) {
- for (StandardPluralCategories rs : StandardPluralCategories.values()) {
+ for (StandardPlural rs : StandardPlural.values()) {
if (rangeEnd == null) {
- for (StandardPluralCategories re : StandardPluralCategories.values()) {
+ for (StandardPlural re : StandardPlural.values()) {
matrix.setIfNew(rs, re, result);
}
} else {
}
} else if (rangeEnd == null) {
explicit[rangeStart.ordinal()] = true;
- for (StandardPluralCategories re : StandardPluralCategories.values()) {
+ for (StandardPlural re : StandardPlural.values()) {
matrix.setIfNew(rangeStart, re, result);
}
} else {
* @deprecated This API is ICU internal only.
*/
@Deprecated
- public StandardPluralCategories get(StandardPluralCategories start, StandardPluralCategories end) {
- StandardPluralCategories result = matrix.get(start, end);
+ public StandardPlural get(StandardPlural start, StandardPlural end) {
+ StandardPlural result = matrix.get(start, end);
return result == null ? end : result;
}
* @deprecated This API is ICU internal only.
*/
@Deprecated
- public boolean isExplicit(StandardPluralCategories start, StandardPluralCategories end) {
+ public boolean isExplicit(StandardPlural start, StandardPlural end) {
return matrix.get(start, end) != null;
}
* @deprecated This API is ICU internal only.
*/
@Deprecated
- public boolean isExplicitlySet(StandardPluralCategories count) {
+ public boolean isExplicitlySet(StandardPlural count) {
return explicit[count.ordinal()];
}
import java.io.Serializable;
import java.text.ParseException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
}
}
- /**
- * @internal
- * @deprecated This API is ICU internal only.
- */
- @Deprecated
- public enum StandardPluralCategories {
- // TODO: An enum name is more commonly singular, e.g., StandardPluralCategory.
- // TODO: Consider changing it to StandardPluralForm(s) which is shorter, and easier to say.
- // We use "plural category" and "plural form" interchangeably in
- // http://www.unicode.org/reports/tr35/tr35-numbers.html#Language_Plural_Rules
- // Maybe even just StandardPlural?!
- // TODO: Make the constants uppercase, and change code that relies on lowercase names,
- // such as by calling .valueOf(String).
- // TODO: Move this into its own file, in impl package?
- /**
- * @internal
- * @deprecated This API is ICU internal only.
- */
- @Deprecated
- zero,
- /**
- * @internal
- * @deprecated This API is ICU internal only.
- */
- @Deprecated
- one,
- /**
- * @internal
- * @deprecated This API is ICU internal only.
- */
- @Deprecated
- two,
- /**
- * @internal
- * @deprecated This API is ICU internal only.
- */
- @Deprecated
- few,
- /**
- * @internal
- * @deprecated This API is ICU internal only.
- */
- @Deprecated
- many,
- /**
- * @internal
- * @deprecated This API is ICU internal only.
- */
- @Deprecated
- other;
-
- /**
- * @internal
- * @deprecated This API is ICU internal only.
- */
- @Deprecated
- public static final int OTHER_INDEX = other.ordinal();
-
- /**
- * @internal
- * @deprecated This API is ICU internal only.
- */
- @Deprecated
- public static final List<StandardPluralCategories> VALUES =
- Collections.unmodifiableList(Arrays.asList(values()));
-
- /**
- * @internal
- * @deprecated This API is ICU internal only.
- */
- @Deprecated
- public static final int COUNT = VALUES.size();
-
- /**
- * @internal
- * @deprecated This API is ICU internal only.
- */
- @Deprecated
- public static final StandardPluralCategories getCategoryOrNull(CharSequence keyword) {
- switch (keyword.length()) {
- case 3:
- if ("one".contentEquals(keyword)) {
- return one;
- } else if ("two".contentEquals(keyword)) {
- return two;
- } else if ("few".contentEquals(keyword)) {
- return few;
- }
- break;
- case 4:
- if ("many".contentEquals(keyword)) {
- return many;
- } else if ("zero".contentEquals(keyword)) {
- return zero;
- }
- break;
- case 5:
- if ("other".contentEquals(keyword)) {
- return other;
- }
- break;
- default:
- break;
- }
- return null;
- }
-
- /**
- * @internal
- * @deprecated This API is ICU internal only.
- */
- @Deprecated
- public static final StandardPluralCategories getCategoryOrOther(CharSequence keyword) {
- StandardPluralCategories cat = getCategoryOrNull(keyword);
- return cat != null ? cat : other;
- }
-
- /**
- * @internal
- * @deprecated This API is ICU internal only.
- */
- @Deprecated
- public static final StandardPluralCategories getCategory(CharSequence keyword) {
- StandardPluralCategories cat = getCategoryOrNull(keyword);
- if (cat != null) {
- return cat;
- } else {
- throw new IllegalArgumentException(keyword.toString());
- }
- }
-
- /**
- * @internal
- * @deprecated This API is ICU internal only.
- */
- @Deprecated
- public static final int getIndexOrNegative(CharSequence keyword) {
- StandardPluralCategories cat = getCategoryOrNull(keyword);
- return cat != null ? cat.ordinal() : -1;
- }
-
- /**
- * @internal
- * @deprecated This API is ICU internal only.
- */
- @Deprecated
- public static final int getIndexOrOtherIndex(CharSequence keyword) {
- StandardPluralCategories cat = getCategoryOrNull(keyword);
- return cat != null ? cat.ordinal() : other.ordinal();
- }
-
- /**
- * @internal
- * @deprecated This API is ICU internal only.
- */
- @Deprecated
- public static final int getIndex(CharSequence keyword) {
- StandardPluralCategories cat = getCategoryOrNull(keyword);
- if (cat != null) {
- return cat.ordinal();
- } else {
- throw new IllegalArgumentException(keyword.toString());
- }
- }
- }
-
@SuppressWarnings("unused")
private boolean addConditional(Set<FixedDecimal> toAddTo, Set<FixedDecimal> others, double trial) {
boolean added;
package com.ibm.icu.text;
import com.ibm.icu.impl.SimplePatternFormatter;
-import com.ibm.icu.text.PluralRules.StandardPluralCategories;
+import com.ibm.icu.impl.StandardPlural;
/**
* QuantityFormatter represents an unknown quantity of something and formats a known quantity
*/
class QuantityFormatter {
private final SimplePatternFormatter[] templates =
- new SimplePatternFormatter[StandardPluralCategories.COUNT];
+ new SimplePatternFormatter[StandardPlural.COUNT];
public QuantityFormatter() {}
* if template has more than just the {0} placeholder.
*/
public void addIfAbsent(CharSequence variant, String template) {
- int idx = StandardPluralCategories.getIndex(variant);
+ int idx = StandardPlural.indexFromString(variant);
if (templates[idx] != null) {
return;
}
* @return true if this object has at least the "other" variant
*/
public boolean isValid() {
- return templates[StandardPluralCategories.OTHER_INDEX] != null;
+ return templates[StandardPlural.OTHER_INDEX] != null;
}
/**
*/
public SimplePatternFormatter getByVariant(CharSequence variant) {
assert isValid();
- int idx = StandardPluralCategories.getIndexOrOtherIndex(variant);
+ int idx = StandardPlural.indexOrOtherIndexFromString(variant);
SimplePatternFormatter template = templates[idx];
- return (template == null && idx != StandardPluralCategories.OTHER_INDEX) ?
- templates[StandardPluralCategories.OTHER_INDEX] : template;
+ return (template == null && idx != StandardPlural.OTHER_INDEX) ?
+ templates[StandardPlural.OTHER_INDEX] : template;
}
}
/*
*******************************************************************************
- * Copyright (C) 2008-2014, International Business Machines Corporation and *
- * others. All Rights Reserved. *
+ * Copyright (C) 2008-2015, International Business Machines Corporation and
+ * others. All Rights Reserved.
*******************************************************************************
*/
package com.ibm.icu.dev.test.format;
import java.util.Arrays;
import com.ibm.icu.dev.test.TestFmwk;
+import com.ibm.icu.impl.StandardPlural;
import com.ibm.icu.text.MeasureFormat;
import com.ibm.icu.text.MeasureFormat.FormatWidth;
import com.ibm.icu.text.PluralRanges;
import com.ibm.icu.text.PluralRules.Factory;
-import com.ibm.icu.text.PluralRules.StandardPluralCategories;
import com.ibm.icu.util.Currency;
import com.ibm.icu.util.Measure;
import com.ibm.icu.util.MeasureUnit;
};
for (String[] test : tests) {
final ULocale locale = new ULocale(test[0]);
- final StandardPluralCategories start = StandardPluralCategories.valueOf(test[1]);
- final StandardPluralCategories end = StandardPluralCategories.valueOf(test[2]);
- final StandardPluralCategories expected = StandardPluralCategories.valueOf(test[3]);
+ final StandardPlural start = StandardPlural.fromString(test[1]);
+ final StandardPlural end = StandardPlural.fromString(test[2]);
+ final StandardPlural expected = StandardPlural.fromString(test[3]);
final PluralRanges pluralRanges = Factory.getDefaultFactory().getPluralRanges(locale);
- StandardPluralCategories actual = pluralRanges.get(start, end);
+ StandardPlural actual = pluralRanges.get(start, end);
assertEquals("Deriving range category", expected, actual);
}
}
public void TestBasic() {
PluralRanges a = new PluralRanges();
- a.add(StandardPluralCategories.one, StandardPluralCategories.other, StandardPluralCategories.one);
- StandardPluralCategories actual = a.get(StandardPluralCategories.one, StandardPluralCategories.other);
- assertEquals("range", StandardPluralCategories.one, actual);
+ 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(StandardPluralCategories.one, StandardPluralCategories.one, StandardPluralCategories.one);
+ a.add(StandardPlural.ONE, StandardPlural.ONE, StandardPlural.ONE);
errln("Failed to cause exception on frozen instance");
} catch (UnsupportedOperationException e) {
}