On Thu, 7 Sep 2023 17:18:33 GMT, Justin Lu <[email protected]> wrote:
>> src/java.base/share/classes/java/text/ChoiceFormat.java line 136:
>>
>>> 134: * Limit Relation Format
>>> 135: * <i>Limit:</i>
>>> 136: * {@code String} that can be parsed as a {@code double} /
>>> "∞" ({@code U+221E}) / "-∞" (-{@code U+221E}).
>>
>> Could the first choice be more specific? Also, do `SubPattern`s need to be
>> sorted with `Limit`s?
>
>> 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
Please let me know if you think this is too specific.
I think the updated one is better.
For the second part, I meant:
jshell> new ChoiceFormat("0#def|-1#abc|xyz")
| Exception java.lang.IllegalArgumentException: Incorrect order of intervals,
must be in ascending order
This should be excluded from the pattern syntax
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15392#discussion_r1319041104