On Wed, 6 Sep 2023 23:04:59 GMT, Naoto Sato <na...@openjdk.org> wrote:
> Could the first choice be more specific? Updated with a more syntactical definition. Please let me know if you think this is _too_ specific. > Also, do SubPatterns need to be sorted with Limits? If I am interpreting the question right, you're asking if a subPattern **needs** a limit to be valid. If that's the question, the answer is yes, `ChoiceFormat` is designed to have an equal amount of limits and formats (whether from the arrays, or the String pattern). But please let me know if I misinterpreted the question. subpattern "xyz" where both _limit_ and _relation_ are omitted jshell> var a = new ChoiceFormat("0#abc|xyz") a ==> java.text.ChoiceFormat@17863 jshell> a.getLimits() $21 ==> double[1] { 0.0 } jshell> a.getFormats() $22 ==> String[1] { "abc" } subpattern "#xyz" where _limit_ is omitted jshell> var b = new ChoiceFormat("0#abc|#xyz") | Exception java.lang.IllegalArgumentException: Each interval must contain a number before a format > src/java.base/share/classes/java/text/ChoiceFormat.java line 152: > >> 150: * >> 151: * System.out.println("Format with -INF : " + >> fmt.format(Double.NEGATIVE_INFINITY)); >> 152: * // ... > > Commenting out (with ellipsis) would not print the result below I felt it was redundant to have both the long lines of println and output, so I commented out the println(s) except for the ones of interest, which are `Double.NEGATIVE_INFINITY`, `Double.POSITIVE_INFINITY`, and `Double.NaN`. However, you're right that commenting it out would not print the below result. I have updated it so that the println and output lines are combined, to provide a more concise example. > src/java.base/share/classes/java/text/ChoiceFormat.java line 407: > >> 405: >> 406: /** >> 407: * Get the formats of this ChoiceFormat. > > Same here Fixed, as well as in the other instance, I have also updated https://cr.openjdk.org/~jlu/api/java.base/java/text/ChoiceFormat.html to reflect the changes. Thanks for the review ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15392#discussion_r1318912438 PR Review Comment: https://git.openjdk.org/jdk/pull/15392#discussion_r1318912460 PR Review Comment: https://git.openjdk.org/jdk/pull/15392#discussion_r1318912398