See Also: ChoiceFormat Members
Returns a fixed string based on a numeric value. The class can be used in conjunction with the Java.Text.MessageFormat class to handle plurals in messages. ChoiceFormat enables users to attach a format to a range of numbers. The choice is specified with an ascending list of doubles, where each item specifies a half-open interval up to the next item as in the following: X matches j if and only if limit[j] <= X .
If there is no match, then either the first or last index is used. The first or last index is used depending on whether the number is too low or too high. The length of the format array must be the same as the length of the limits array.
java Example
double[] limits = {1, 2, 3, 4, 5, 6, 7}; String[] fmts = {"Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat"}; double[] limits2 = {0, 1, ChoiceFormat.nextDouble(1)}; String[] fmts2 = {"no files", "one file", "many files"};
ChoiceFormat.nextDouble(double) allows to get the double following the one passed to the method. This is used to create half open intervals.
ChoiceFormat objects also may be converted to and from patterns. The conversion can be done programmatically, as in the example above, or by using a pattern like the following:
java Example
"1#Sun|2#Mon|3#Tue|4#Wed|5#Thur|6#Fri|7#Sat" "0#are no files|1#is one file|1<are many files"
where: