/// <summary> /// Return tif rhs is equal to this. /// </summary> /// /// <param name="rhs">the PluralRules to compare to.</param> /// <returns>true if this and rhs are equal.</returns> /// @draft ICU 3.8 /// @provisional This API might change or be removed in a future release. public bool Equals(PluralRules rhs) { if (rhs == null) { return(false); } if (rhs == this) { return(true); } if (!rhs.GetKeywords().Equals(keywords)) { return(false); } int limit = Math.Max(GetRepeatLimit(), rhs.GetRepeatLimit()); for (int i = 0; i < limit; ++i) { if (!Select(i).Equals(rhs.Select(i))) { return(false); } } return(true); }
/// <summary> /// Formats a plural message for a given number. /// </summary> /// /// <param name="number">a number for which the plural message should be formatted. Ifno pattern has been applied to this <c>PluralFormat</c>object yet, the formatted number will be returned.</param> /// <returns>the string containing the formatted plural message.</returns> /// @draft ICU 3.8 /// @provisional This API might change or be removed in a future release. public String Format(long number) { // If no pattern was applied, return the formatted number. if (parsedValues == null) { return(numberFormat.Format(number)); } // Get appropriate format pattern. String selectedRule = pluralRules.Select(number); String selectedPattern = (String)ILOG.J2CsMapping.Collections.Collections.Get(parsedValues, selectedRule); if (selectedPattern == null) // Fallback to others. { selectedPattern = (String)ILOG.J2CsMapping.Collections.Collections.Get(parsedValues, IBM.ICU.Text.PluralRules.KEYWORD_OTHER); } // Get formatted number and insert it into String. // Will replace all '#' which are not inside curly braces by the // formatted number. return(InsertFormattedNumber(number, selectedPattern)); }