Hi,
Jimmy, I totally agree with you on RI's compiling "2 |" to "0.0#" case.
And I also found RI had such strange behavior
when there was no pattern control symbol follows the limit value. E.g. if we
try to compile "2#|1|3#" on RI, the output is
"2.0#|2.0#|13.0#". It's so unreasonable to get such a result. In Harmony,
this pattern is illegal since there is no control
symbol follows the limit value. I think Harmony is more reasonable on such
cases. Any suggestion?
在08-4-22,Jimmy,Jing Lv <[EMAIL PROTECTED]> 写道:
>
> Hi,
>
> Thanks Jim. It make sense to me that "|", "#" and "<" should be
> reserved as pattern control symbols.
> BTW, I've read the JIRA, it seems there's another problem that a
> pattern of "2|" passes in RI but not in Harmony. It seems RI's
> behaviour is strange here. I don't think compile "2|" to "0.0#" is
> reasonable, though the basic rule for the difference of RI and Harmony
> is that we should follow spec, if the spec is not clear, we should
> follow RI. But if RI's behaviour is not reasonable, take it to
> mailing-list. I think we should not follow RI here("2|" to "0.0#") as
> its behaviour is not reasonable here. What's your idea about this
> difference?
>
> 2008/4/22 Jim Yu <[EMAIL PROTECTED]>:
> > Hi, all,
> > I looked at this JIRA[1]. As the reporter said, Harmony and RI have
> > different pattern parsers implementations
> > of ChoiceFormat class. Since Spec doesn't have any rules for pattern
> except
> > a single example
> > "-1#is negative| 0#is zero or fraction | 1#is one |1.0<is 1+ |2#is two
> |2<is
> > more than 2."
> > So we have some differences in pattern parsing.
> > Test
>
> >
> > ---------------------------------------------------------------------------------------
> >
> > import java.text.*;
> >
> > public class bug9411 {
> > public static void main(String[] args) {
> > try {
> > System.out.println(new ChoiceFormat("2#ok #ab").toPattern());
> > } catch (Exception e) {
> > e.printStackTrace();
> > }
> > try {
> > System.out.println(new ChoiceFormat("2#ok <ab").toPattern());
> > } catch (Exception e) {
> > e.printStackTrace();
> > }
> > }
> > }
> >
> > Output
> ---------------------------------------------------------------------
> >
> > RI
> > java.lang.IllegalArgumentException
> > at
> > java.text.ChoiceFormat.applyPattern(ChoiceFormat.java:197)
> > at
> > java.text.ChoiceFormat.<init>(ChoiceFormat.java:294)
> > at bug9411.main(bug9411.java:12)
> > java.lang.IllegalArgumentException
> > at
> > java.text.ChoiceFormat.applyPattern(ChoiceFormat.java:197)
> > at
> > java.text.ChoiceFormat.<init>(ChoiceFormat.java:294)
> > at bug9411.main(bug9411.java:17)
> > Harmony
> > 2.0#ok #ab
> > 2.0#ok <ab
> >
> > From the output, RI treats "#" and "<" as reserved symbols. So it is
> > illegal in RI that reserved symbols are used in formats
> > directly. But in Harmony, these symbols are not reserved. It is legal
> in
> > Harmony to use them directly. I agree with the reporter's
> > view point that symbols "|", "#" and "<" should be reserved as pattern
> > control symbols because of their influence on pattern parse algorithm.
> > If user wants to use such symbols in formats, we'd better put them in
> quotes
> > to avoid misunderstandings. And according to my regression
> > test cases, RI behaves just like what I said. Now that spec doesn't
> have
> > specific rules about it, I think we should follow RI's behavior.
> > I've submitted my patch[1]. Any objection? If no, I will ask classlib
> > commiter to apply it: )
> >
> > [1] https://issues.apache.org/jira/browse/HARMONY-1110
> >
> > --
> > Best Regards,
> > Jim Yu (虞俊杰)
> >
> > China Software Development Lab, IBM
> >
>
>
>
> --
>
> Best Regards!
>
> Jimmy, Jing Lv
> China Software Development Lab, IBM
>
--
Best Regards,
Jim Yu (虞俊杰)
China Software Development Lab, IBM