ChoiceFormat.setChoices confusion about format parameter type and documentation
- by polygenelubricants
From the java.text.ChoiceFormat API:
setChoices(double[] limits, String[] formats): Set the choices to be used in formatting.
Parameters:
limits - contains [...]
formats - are the formats you want to use for each limit. They can be either Format objects or Strings. When formatting with object Y, if the object is a NumberFormat, then ((NumberFormat) Y).format(X) is called. Otherwise Y.toString() is called.
I'm having difficulties understanding the documentation for the formats parameter: how can you possibly pass a Format/NumberFormat object to setChoices if it's declared String[] formats?
Note that interestingly, the getters counterpart of setChoices are declared as follows:
double[] getLimits()
Object[] getFormats() -- not String[]!!!
Is this a bug in the API? Should the setter have been declared setChoices(double[], Object[]) instead, or am I not understanding how to use setChoices correctly?