U_NAMESPACE_BEGIN
class Hashtable;
-class FixedDecimal;
-class VisibleDigitsWithExponent;
+class IFixedDecimal;
class RuleChain;
class PluralRuleParser;
class PluralKeywordEnumeration;
class AndConstraint;
class SharedPluralRules;
+namespace number {
+class FormattedNumber;
+}
+
/**
* Defines rules for mapping non-negative numeric values onto a small set of
* keywords. Rules are constructed from a text description, consisting
* Examples are in the following table:
* </p>
* <table border='1' style="border-collapse:collapse">
- * <tbody>
* <tr>
* <th>n</th>
* <th>i</th>
* <td align="right">23</td>
* <td>2</td>
* </tr>
- * </tbody>
* </table>
* <p>
* The difference between 'in' and 'within' is that 'in' only includes integers in the specified range, while 'within'
#endif /* U_HIDE_INTERNAL_API */
/**
- * Given a number, returns the keyword of the first rule that applies to
- * the number. This function can be used with isKeyword* functions to
- * determine the keyword for default plural rules.
+ * Given an integer, returns the keyword of the first rule
+ * that applies to the number. This function can be used with
+ * isKeyword* functions to determine the keyword for default plural rules.
*
* @param number The number for which the rule has to be determined.
* @return The keyword of the selected rule.
UnicodeString select(int32_t number) const;
/**
- * Given a number, returns the keyword of the first rule that applies to
- * the number. This function can be used with isKeyword* functions to
- * determine the keyword for default plural rules.
+ * Given a floating-point number, returns the keyword of the first rule
+ * that applies to the number. This function can be used with
+ * isKeyword* functions to determine the keyword for default plural rules.
*
* @param number The number for which the rule has to be determined.
* @return The keyword of the selected rule.
*/
UnicodeString select(double number) const;
-#ifndef U_HIDE_INTERNAL_API
+#ifndef U_HIDE_DRAFT_API
/**
- * Given a number and a format, returns the keyword of the first applicable
- * rule for this PluralRules object.
- * Note: This internal preview interface may be removed in the future if
- * an architecturally cleaner solution reaches stable status.
- * @param obj The numeric object for which the rule should be determined.
- * @param fmt The NumberFormat specifying how the number will be formatted
- * (this can affect the plural form, e.g. "1 dollar" vs "1.0 dollars").
- * @param status Input/output parameter. If at entry this indicates a
- * failure status, the method returns immediately; otherwise
- * this is set to indicate the outcome of the call.
- * @return The keyword of the selected rule. Undefined in the case of an error.
- * @internal ICU 59 technology preview, may be removed in the future
+ * Given a formatted number, returns the keyword of the first rule
+ * that applies to the number. This function can be used with
+ * isKeyword* functions to determine the keyword for default plural rules.
+ *
+ * A FormattedNumber allows you to specify an exponent or trailing zeros,
+ * which can affect the plural category. To get a FormattedNumber, see
+ * NumberFormatter.
+ *
+ * @param number The number for which the rule has to be determined.
+ * @param status Set if an error occurs while selecting plural keyword.
+ * This could happen if the FormattedNumber is invalid.
+ * @return The keyword of the selected rule.
+ * @draft ICU 64
*/
- UnicodeString select(const Formattable& obj, const NumberFormat& fmt, UErrorCode& status) const;
+ UnicodeString select(const number::FormattedNumber& number, UErrorCode& status) const;
+#endif /* U_HIDE_DRAFT_API */
+#ifndef U_HIDE_INTERNAL_API
/**
* @internal
*/
- UnicodeString select(const FixedDecimal &number) const;
- /**
- * @internal
- */
- UnicodeString select(const VisibleDigitsWithExponent &number) const;
+ UnicodeString select(const IFixedDecimal &number) const;
#endif /* U_HIDE_INTERNAL_API */
/**
/**
* Deprecated Function, does not produce useful results.
*
- * Orginally intended to return all the values for which select() would return the keyword.
+ * Originally intended to return all the values for which select() would return the keyword.
* If the keyword is unknown, returns no values, but this is not an error. If
* the number of values is unlimited, returns no values and -1 as the
* count.
UnicodeString getRuleFromResource(const Locale& locale, UPluralType type, UErrorCode& status);
RuleChain *rulesForKeyword(const UnicodeString &keyword) const;
+ /**
+ * An internal status variable used to indicate that the object is in an 'invalid' state.
+ * Used by copy constructor, the assignment operator and the clone method.
+ */
+ UErrorCode mInternalStatus;
+
friend class PluralRuleParser;
};