]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_2_1-src/src/com/ibm/icu/dev/test/serializable/FormatTests.java
icu4jsrc
[Dictionary.git] / jars / icu4j-4_2_1-src / src / com / ibm / icu / dev / test / serializable / FormatTests.java
1 //##header\r
2 /*\r
3  *******************************************************************************\r
4  * Copyright (C) 1996-2009, International Business Machines Corporation and    *\r
5  * others. All Rights Reserved.                                                *\r
6  *******************************************************************************\r
7  *\r
8  */\r
9 \r
10 package com.ibm.icu.dev.test.serializable;\r
11 \r
12 import java.text.AttributedCharacterIterator;\r
13 import java.util.Date;\r
14 import java.util.HashMap;\r
15 import java.util.Locale;\r
16 \r
17 import com.ibm.icu.impl.DateNumberFormat;\r
18 import com.ibm.icu.text.ChineseDateFormat;\r
19 import com.ibm.icu.text.ChineseDateFormatSymbols;\r
20 import com.ibm.icu.text.DateFormat;\r
21 import com.ibm.icu.text.DateFormatSymbols;\r
22 import com.ibm.icu.text.DateIntervalFormat;\r
23 import com.ibm.icu.text.DateIntervalInfo;\r
24 import com.ibm.icu.text.DecimalFormat;\r
25 import com.ibm.icu.text.CurrencyPluralInfo;\r
26 import com.ibm.icu.text.DecimalFormatSymbols;\r
27 import com.ibm.icu.text.DurationFormat;\r
28 import com.ibm.icu.text.MessageFormat;\r
29 import com.ibm.icu.text.NumberFormat;\r
30 import com.ibm.icu.text.PluralFormat;\r
31 import com.ibm.icu.text.PluralRules;\r
32 import com.ibm.icu.text.RuleBasedNumberFormat;\r
33 import com.ibm.icu.text.SimpleDateFormat;\r
34 import com.ibm.icu.text.TimeUnitFormat;\r
35 import com.ibm.icu.util.Calendar;\r
36 import com.ibm.icu.util.DateInterval;\r
37 import com.ibm.icu.util.GregorianCalendar;\r
38 import com.ibm.icu.util.TimeUnit;\r
39 import com.ibm.icu.util.TimeUnitAmount;\r
40 import com.ibm.icu.util.ULocale;\r
41 \r
42 /**\r
43  * @author emader\r
44  *\r
45  * TODO To change the template for this generated type comment go to\r
46  * Window - Preferences - Java - Code Style - Code Templates\r
47  */\r
48 public class FormatTests\r
49 {\r
50     /*\r
51      * The serialized form of a normally created DateFormatSymbols object\r
52      * will have locale-specific data in it that might change from one version\r
53      * of ICU4J to another. To guard against this, we store the following canned\r
54      * data into the test objects we create.\r
55      */\r
56     static HashMap cannedMonthNames      = new HashMap();\r
57     static HashMap cannedShortMonthNames = new HashMap();\r
58 \r
59     static String en_CA_MonthNames[] = {\r
60         "January", \r
61         "February", \r
62         "March", \r
63         "April", \r
64         "May", \r
65         "June", \r
66         "July", \r
67         "August", \r
68         "September", \r
69         "October", \r
70         "November", \r
71         "December", \r
72     };\r
73 \r
74     static String fr_CA_MonthNames[] = {\r
75         "janvier", \r
76         "f\u00E9vrier", \r
77         "mars", \r
78         "avril", \r
79         "mai", \r
80         "juin", \r
81         "juillet", \r
82         "ao\u00FBt", \r
83         "septembre", \r
84         "octobre", \r
85         "novembre", \r
86         "d\u00E9cembre", \r
87     };\r
88 \r
89     static String zh_Hans_CN_MonthNames[] = {\r
90         "\u4E00\u6708", \r
91         "\u4E8C\u6708", \r
92         "\u4E09\u6708", \r
93         "\u56DB\u6708", \r
94         "\u4E94\u6708", \r
95         "\u516D\u6708", \r
96         "\u4E03\u6708", \r
97         "\u516B\u6708", \r
98         "\u4E5D\u6708", \r
99         "\u5341\u6708", \r
100         "\u5341\u4E00\u6708", \r
101         "\u5341\u4E8C\u6708", \r
102     };\r
103 \r
104     static String zh_CN_MonthNames[] = {\r
105         "\u4E00\u6708", \r
106         "\u4E8C\u6708", \r
107         "\u4E09\u6708", \r
108         "\u56DB\u6708", \r
109         "\u4E94\u6708", \r
110         "\u516D\u6708", \r
111         "\u4E03\u6708", \r
112         "\u516B\u6708", \r
113         "\u4E5D\u6708", \r
114         "\u5341\u6708", \r
115         "\u5341\u4E00\u6708", \r
116         "\u5341\u4E8C\u6708", \r
117     };\r
118 \r
119     static String zh_MonthNames[] = {\r
120         "\u4E00\u6708", \r
121         "\u4E8C\u6708", \r
122         "\u4E09\u6708", \r
123         "\u56DB\u6708", \r
124         "\u4E94\u6708", \r
125         "\u516D\u6708", \r
126         "\u4E03\u6708", \r
127         "\u516B\u6708", \r
128         "\u4E5D\u6708", \r
129         "\u5341\u6708", \r
130         "\u5341\u4E00\u6708", \r
131         "\u5341\u4E8C\u6708", \r
132     };\r
133 \r
134     static String en_MonthNames[] = {\r
135         "January", \r
136         "February", \r
137         "March", \r
138         "April", \r
139         "May", \r
140         "June", \r
141         "July", \r
142         "August", \r
143         "September", \r
144         "October", \r
145         "November", \r
146         "December", \r
147     };\r
148 \r
149     static String fr_FR_MonthNames[] = {\r
150         "janvier", \r
151         "f\u00E9vrier", \r
152         "mars", \r
153         "avril", \r
154         "mai", \r
155         "juin", \r
156         "juillet", \r
157         "ao\u00FBt", \r
158         "septembre", \r
159         "octobre", \r
160         "novembre", \r
161         "d\u00E9cembre", \r
162     };\r
163 \r
164     static String fr_MonthNames[] = {\r
165         "janvier", \r
166         "f\u00E9vrier", \r
167         "mars", \r
168         "avril", \r
169         "mai", \r
170         "juin", \r
171         "juillet", \r
172         "ao\u00FBt", \r
173         "septembre", \r
174         "octobre", \r
175         "novembre", \r
176         "d\u00E9cembre", \r
177     };\r
178 \r
179     static String de_MonthNames[] = {\r
180         "Januar", \r
181         "Februar", \r
182         "M\u00E4rz", \r
183         "April", \r
184         "Mai", \r
185         "Juni", \r
186         "Juli", \r
187         "August", \r
188         "September", \r
189         "Oktober", \r
190         "November", \r
191         "Dezember", \r
192     };\r
193 \r
194     static String de_DE_MonthNames[] = {\r
195         "Januar", \r
196         "Februar", \r
197         "M\u00E4rz", \r
198         "April", \r
199         "Mai", \r
200         "Juni", \r
201         "Juli", \r
202         "August", \r
203         "September", \r
204         "Oktober", \r
205         "November", \r
206         "Dezember", \r
207     };\r
208 \r
209     static String it_MonthNames[] = {\r
210         "gennaio", \r
211         "febbraio", \r
212         "marzo", \r
213         "aprile", \r
214         "maggio", \r
215         "giugno", \r
216         "luglio", \r
217         "agosto", \r
218         "settembre", \r
219         "ottobre", \r
220         "novembre", \r
221         "dicembre", \r
222     };\r
223 \r
224     static String it_IT_MonthNames[] = {\r
225         "gennaio", \r
226         "febbraio", \r
227         "marzo", \r
228         "aprile", \r
229         "maggio", \r
230         "giugno", \r
231         "luglio", \r
232         "agosto", \r
233         "settembre", \r
234         "ottobre", \r
235         "novembre", \r
236         "dicembre", \r
237     };\r
238 \r
239     static String ja_JP_MonthNames[] = {\r
240         "1\u6708", \r
241         "2\u6708", \r
242         "3\u6708", \r
243         "4\u6708", \r
244         "5\u6708", \r
245         "6\u6708", \r
246         "7\u6708", \r
247         "8\u6708", \r
248         "9\u6708", \r
249         "10\u6708", \r
250         "11\u6708", \r
251         "12\u6708", \r
252     };\r
253 \r
254     static String ja_MonthNames[] = {\r
255         "1\u6708", \r
256         "2\u6708", \r
257         "3\u6708", \r
258         "4\u6708", \r
259         "5\u6708", \r
260         "6\u6708", \r
261         "7\u6708", \r
262         "8\u6708", \r
263         "9\u6708", \r
264         "10\u6708", \r
265         "11\u6708", \r
266         "12\u6708", \r
267     };\r
268 \r
269     static String ko_KR_MonthNames[] = {\r
270         "1\uC6D4", \r
271         "2\uC6D4", \r
272         "3\uC6D4", \r
273         "4\uC6D4", \r
274         "5\uC6D4", \r
275         "6\uC6D4", \r
276         "7\uC6D4", \r
277         "8\uC6D4", \r
278         "9\uC6D4", \r
279         "10\uC6D4", \r
280         "11\uC6D4", \r
281         "12\uC6D4", \r
282     };\r
283 \r
284     static String ko_MonthNames[] = {\r
285         "1\uC6D4", \r
286         "2\uC6D4", \r
287         "3\uC6D4", \r
288         "4\uC6D4", \r
289         "5\uC6D4", \r
290         "6\uC6D4", \r
291         "7\uC6D4", \r
292         "8\uC6D4", \r
293         "9\uC6D4", \r
294         "10\uC6D4", \r
295         "11\uC6D4", \r
296         "12\uC6D4", \r
297     };\r
298 \r
299     static String zh_Hant_TW_MonthNames[] = {\r
300         "\u4E00\u6708", \r
301         "\u4E8C\u6708", \r
302         "\u4E09\u6708", \r
303         "\u56DB\u6708", \r
304         "\u4E94\u6708", \r
305         "\u516D\u6708", \r
306         "\u4E03\u6708", \r
307         "\u516B\u6708", \r
308         "\u4E5D\u6708", \r
309         "\u5341\u6708", \r
310         "\u5341\u4E00\u6708", \r
311         "\u5341\u4E8C\u6708", \r
312     };\r
313 \r
314     static String zh_TW_MonthNames[] = {\r
315         "\u4E00\u6708", \r
316         "\u4E8C\u6708", \r
317         "\u4E09\u6708", \r
318         "\u56DB\u6708", \r
319         "\u4E94\u6708", \r
320         "\u516D\u6708", \r
321         "\u4E03\u6708", \r
322         "\u516B\u6708", \r
323         "\u4E5D\u6708", \r
324         "\u5341\u6708", \r
325         "\u5341\u4E00\u6708", \r
326         "\u5341\u4E8C\u6708", \r
327         };\r
328 \r
329     static String en_GB_MonthNames[] = {\r
330         "January", \r
331         "February", \r
332         "March", \r
333         "April", \r
334         "May", \r
335         "June", \r
336         "July", \r
337         "August", \r
338         "September", \r
339         "October", \r
340         "November", \r
341         "December", \r
342     };\r
343 \r
344     static String en_US_MonthNames[] = {\r
345         "January", \r
346         "February", \r
347         "March", \r
348         "April", \r
349         "May", \r
350         "June", \r
351         "July", \r
352         "August", \r
353         "September", \r
354         "October", \r
355         "November", \r
356         "December", \r
357     };\r
358 \r
359     static String en_CA_ShortMonthNames[] = {\r
360         "Jan",\r
361         "Feb",\r
362         "Mar",\r
363         "Apr",\r
364         "May",\r
365         "Jun",\r
366         "Jul",\r
367         "Aug",\r
368         "Sep",\r
369         "Oct",\r
370         "Nov",\r
371         "Dec",\r
372     };\r
373 \r
374     static String fr_CA_ShortMonthNames[] = {\r
375         "janv.",\r
376         "f\u00E9vr.",\r
377         "mars",\r
378         "avr.",\r
379         "mai",\r
380         "juin",\r
381         "juil.",\r
382         "ao\u00FBt",\r
383         "sept.",\r
384         "oct.",\r
385         "nov.",\r
386         "d\u00E9c.",\r
387     };\r
388 \r
389     static String zh_Hans_CN_ShortMonthNames[] = {\r
390         "\u4E00\u6708",\r
391         "\u4E8C\u6708",\r
392         "\u4E09\u6708",\r
393         "\u56DB\u6708",\r
394         "\u4E94\u6708",\r
395         "\u516D\u6708",\r
396         "\u4E03\u6708",\r
397         "\u516B\u6708",\r
398         "\u4E5D\u6708",\r
399         "\u5341\u6708",\r
400         "\u5341\u4E00\u6708",\r
401         "\u5341\u4E8C\u6708",\r
402     };\r
403 \r
404     static String zh_CN_ShortMonthNames[] = {\r
405         "\u4E00\u6708",\r
406         "\u4E8C\u6708",\r
407         "\u4E09\u6708",\r
408         "\u56DB\u6708",\r
409         "\u4E94\u6708",\r
410         "\u516D\u6708",\r
411         "\u4E03\u6708",\r
412         "\u516B\u6708",\r
413         "\u4E5D\u6708",\r
414         "\u5341\u6708",\r
415         "\u5341\u4E00\u6708",\r
416         "\u5341\u4E8C\u6708",\r
417     };\r
418 \r
419     static String zh_ShortMonthNames[] = {\r
420         "\u4E00\u6708",\r
421         "\u4E8C\u6708",\r
422         "\u4E09\u6708",\r
423         "\u56DB\u6708",\r
424         "\u4E94\u6708",\r
425         "\u516D\u6708",\r
426         "\u4E03\u6708",\r
427         "\u516B\u6708",\r
428         "\u4E5D\u6708",\r
429         "\u5341\u6708",\r
430         "\u5341\u4E00\u6708",\r
431         "\u5341\u4E8C\u6708",\r
432     };\r
433 \r
434     static String en_ShortMonthNames[] = {\r
435         "Jan",\r
436         "Feb",\r
437         "Mar",\r
438         "Apr",\r
439         "May",\r
440         "Jun",\r
441         "Jul",\r
442         "Aug",\r
443         "Sep",\r
444         "Oct",\r
445         "Nov",\r
446         "Dec",\r
447     };\r
448 \r
449     static String fr_FR_ShortMonthNames[] = {\r
450         "janv.",\r
451         "f\u00E9vr.",\r
452         "mars",\r
453         "avr.",\r
454         "mai",\r
455         "juin",\r
456         "juil.",\r
457         "ao\u00FBt",\r
458         "sept.",\r
459         "oct.",\r
460         "nov.",\r
461         "d\u00E9c.",\r
462     };\r
463 \r
464    static String fr_ShortMonthNames[] = {\r
465         "janv.",\r
466         "f\u00E9vr.",\r
467         "mars",\r
468         "avr.",\r
469         "mai",\r
470         "juin",\r
471         "juil.",\r
472         "ao\u00FBt",\r
473         "sept.",\r
474         "oct.",\r
475         "nov.",\r
476         "d\u00E9c.",\r
477     };\r
478 \r
479     static String de_ShortMonthNames[] = {\r
480         "Jan",\r
481         "Feb",\r
482         "Mrz",\r
483         "Apr",\r
484         "Mai",\r
485         "Jun",\r
486         "Jul",\r
487         "Aug",\r
488         "Sep",\r
489         "Okt",\r
490         "Nov",\r
491         "Dez",\r
492     };\r
493 \r
494     static String de_DE_ShortMonthNames[] = {\r
495         "Jan",\r
496         "Feb",\r
497         "Mrz",\r
498         "Apr",\r
499         "Mai",\r
500         "Jun",\r
501         "Jul",\r
502         "Aug",\r
503         "Sep",\r
504         "Okt",\r
505         "Nov",\r
506         "Dez",\r
507     };\r
508 \r
509     static String it_ShortMonthNames[] = {\r
510         "gen",\r
511         "feb",\r
512         "mar",\r
513         "apr",\r
514         "mag",\r
515         "giu",\r
516         "lug",\r
517         "ago",\r
518         "set",\r
519         "ott",\r
520         "nov",\r
521         "dic",\r
522     };\r
523 \r
524     static String it_IT_ShortMonthNames[] = {\r
525         "gen",\r
526         "feb",\r
527         "mar",\r
528         "apr",\r
529         "mag",\r
530         "giu",\r
531         "lug",\r
532         "ago",\r
533         "set",\r
534         "ott",\r
535         "nov",\r
536         "dic",\r
537     };\r
538 \r
539     static String ja_JP_ShortMonthNames[] = {\r
540         "1 \u6708",\r
541         "2 \u6708",\r
542         "3 \u6708",\r
543         "4 \u6708",\r
544         "5 \u6708",\r
545         "6 \u6708",\r
546         "7 \u6708",\r
547         "8 \u6708",\r
548         "9 \u6708",\r
549         "10 \u6708",\r
550         "11 \u6708",\r
551         "12 \u6708",\r
552     };\r
553 \r
554     static String ja_ShortMonthNames[] = {\r
555         "1 \u6708",\r
556         "2 \u6708",\r
557         "3 \u6708",\r
558         "4 \u6708",\r
559         "5 \u6708",\r
560         "6 \u6708",\r
561         "7 \u6708",\r
562         "8 \u6708",\r
563         "9 \u6708",\r
564         "10 \u6708",\r
565         "11 \u6708",\r
566         "12 \u6708",\r
567     };\r
568 \r
569     static String ko_KR_ShortMonthNames[] = {\r
570         "1\uC6D4",\r
571         "2\uC6D4",\r
572         "3\uC6D4",\r
573         "4\uC6D4",\r
574         "5\uC6D4",\r
575         "6\uC6D4",\r
576         "7\uC6D4",\r
577         "8\uC6D4",\r
578         "9\uC6D4",\r
579         "10\uC6D4",\r
580         "11\uC6D4",\r
581         "12\uC6D4",\r
582     };\r
583 \r
584     static String ko_ShortMonthNames[] = {\r
585         "1\uC6D4",\r
586         "2\uC6D4",\r
587         "3\uC6D4",\r
588         "4\uC6D4",\r
589         "5\uC6D4",\r
590         "6\uC6D4",\r
591         "7\uC6D4",\r
592         "8\uC6D4",\r
593         "9\uC6D4",\r
594         "10\uC6D4",\r
595         "11\uC6D4",\r
596         "12\uC6D4",\r
597     };\r
598 \r
599     static String zh_Hant_TW_ShortMonthNames[] = {\r
600         "\u4E00\u6708",\r
601         "\u4E8C\u6708",\r
602         "\u4E09\u6708",\r
603         "\u56DB\u6708",\r
604         "\u4E94\u6708",\r
605         "\u516D\u6708",\r
606         "\u4E03\u6708",\r
607         "\u516B\u6708",\r
608         "\u4E5D\u6708",\r
609         "\u5341\u6708",\r
610         "\u5341\u4E00\u6708",\r
611         "\u5341\u4E8C\u6708",\r
612     };\r
613 \r
614     static String zh_TW_ShortMonthNames[] = {\r
615         "\u4E00\u6708",\r
616         "\u4E8C\u6708",\r
617         "\u4E09\u6708",\r
618         "\u56DB\u6708",\r
619         "\u4E94\u6708",\r
620         "\u516D\u6708",\r
621         "\u4E03\u6708",\r
622         "\u516B\u6708",\r
623         "\u4E5D\u6708",\r
624         "\u5341\u6708",\r
625         "\u5341\u4E00\u6708",\r
626         "\u5341\u4E8C\u6708",\r
627     };\r
628 \r
629     static String en_GB_ShortMonthNames[] = {\r
630         "Jan",\r
631         "Feb",\r
632         "Mar",\r
633         "Apr",\r
634         "May",\r
635         "Jun",\r
636         "Jul",\r
637         "Aug",\r
638         "Sep",\r
639         "Oct",\r
640         "Nov",\r
641         "Dec",\r
642     };\r
643 \r
644     static String en_US_ShortMonthNames[] = {\r
645         "Jan",\r
646         "Feb",\r
647         "Mar",\r
648         "Apr",\r
649         "May",\r
650         "Jun",\r
651         "Jul",\r
652         "Aug",\r
653         "Sep",\r
654         "Oct",\r
655         "Nov",\r
656         "Dec",\r
657     };\r
658         \r
659     static {\r
660         cannedMonthNames.put("en_CA",      en_CA_MonthNames);\r
661         cannedMonthNames.put("fr_CA",      fr_CA_MonthNames);\r
662         cannedMonthNames.put("zh_Hans_CN", zh_Hans_CN_MonthNames);\r
663         cannedMonthNames.put("zh_CN",      zh_CN_MonthNames);\r
664         cannedMonthNames.put("zh",         zh_MonthNames);\r
665         cannedMonthNames.put("en",         en_MonthNames);\r
666         cannedMonthNames.put("fr_FR",      fr_FR_MonthNames);\r
667         cannedMonthNames.put("fr",         fr_MonthNames);\r
668         cannedMonthNames.put("de",         de_MonthNames);\r
669         cannedMonthNames.put("de_DE",      de_DE_MonthNames);\r
670         cannedMonthNames.put("it",         it_MonthNames);\r
671         cannedMonthNames.put("it_IT",      it_IT_MonthNames);\r
672         cannedMonthNames.put("ja_JP",      ja_JP_MonthNames);\r
673         cannedMonthNames.put("ja",         ja_MonthNames);\r
674         cannedMonthNames.put("ko_KR",      ko_KR_MonthNames);\r
675         cannedMonthNames.put("ko",         ko_MonthNames);\r
676         cannedMonthNames.put("zh_Hant_TW", zh_Hant_TW_MonthNames);\r
677         cannedMonthNames.put("zh_TW",      zh_TW_MonthNames);\r
678         cannedMonthNames.put("en_GB",      en_GB_MonthNames);\r
679         cannedMonthNames.put("en_US",      en_US_MonthNames);\r
680 \r
681         cannedShortMonthNames.put("en_CA",      en_CA_ShortMonthNames);\r
682         cannedShortMonthNames.put("fr_CA",      fr_CA_ShortMonthNames);\r
683         cannedShortMonthNames.put("zh_Hans_CN", zh_Hans_CN_ShortMonthNames);\r
684         cannedShortMonthNames.put("zh_CN",      zh_CN_ShortMonthNames);\r
685         cannedShortMonthNames.put("zh",         zh_ShortMonthNames);\r
686         cannedShortMonthNames.put("en",         en_ShortMonthNames);\r
687         cannedShortMonthNames.put("fr_FR",      fr_FR_ShortMonthNames);\r
688         cannedShortMonthNames.put("fr",         fr_ShortMonthNames);\r
689         cannedShortMonthNames.put("de",         de_ShortMonthNames);\r
690         cannedShortMonthNames.put("de_DE",      de_DE_ShortMonthNames);\r
691         cannedShortMonthNames.put("it",         it_ShortMonthNames);\r
692         cannedShortMonthNames.put("it_IT",      it_IT_ShortMonthNames);\r
693         cannedShortMonthNames.put("ja_JP",      ja_JP_ShortMonthNames);\r
694         cannedShortMonthNames.put("ja",         ja_ShortMonthNames);\r
695         cannedShortMonthNames.put("ko_KR",      ko_KR_ShortMonthNames);\r
696         cannedShortMonthNames.put("ko",         ko_ShortMonthNames);\r
697         cannedShortMonthNames.put("zh_Hant_TW", zh_Hant_TW_ShortMonthNames);\r
698         cannedShortMonthNames.put("zh_TW",      zh_TW_ShortMonthNames);\r
699         cannedShortMonthNames.put("en_GB",      en_GB_ShortMonthNames);\r
700         cannedShortMonthNames.put("en_US",      en_US_ShortMonthNames);\r
701     }\r
702 \r
703     private static DateFormatSymbols getCannedDateFormatSymbols(ULocale uloc)\r
704     {\r
705         DateFormatSymbols dfs =new DateFormatSymbols(GregorianCalendar.class, uloc);\r
706         String key = uloc.toString();\r
707         \r
708         dfs.setMonths((String[]) cannedMonthNames.get(key));\r
709         dfs.setShortMonths((String[]) cannedShortMonthNames.get(key));\r
710         \r
711         return dfs;\r
712     }\r
713     \r
714     private static SimpleDateFormat getCannedSimpleDateFormat(String pattern, ULocale uloc)\r
715     {\r
716         DateFormatSymbols dfs = getCannedDateFormatSymbols(uloc);\r
717         \r
718         return new SimpleDateFormat(pattern, dfs, uloc);\r
719     }\r
720     \r
721     /*\r
722      * The serialized form of a normally created DecimalFormatSymbols object\r
723      * will have locale-specific data in it that might change from one version\r
724      * of ICU4J to another. To guard against this, we store the following canned\r
725      * data into the test objects we create.\r
726      */\r
727     static HashMap cannedDecimalFormatSymbols = new HashMap();\r
728     \r
729     static String en_CA_StringSymbols[] = {\r
730         "$", \r
731         "E", \r
732         "\u221E", \r
733         "CAD", \r
734         "\uFFFD", \r
735         ".#,-.*;%\u2030+@0"\r
736     };\r
737 \r
738     static String fr_CA_StringSymbols[] = {\r
739         "$", \r
740         "E", \r
741         "\u221E", \r
742         "CAD", \r
743         "\uFFFD", \r
744         ",#\u00A0-,*;%\u2030+@0"\r
745     };\r
746 \r
747     static String zh_CN_StringSymbols[] = {\r
748         "\uFFE5", \r
749         "E", \r
750         "\u221E", \r
751         "CNY", \r
752         "\uFFFD",\r
753         ".#,-.*;%\u2030+@0"\r
754     };\r
755 \r
756     static String zh_StringSymbols[] = {\r
757         "\u00A4", \r
758         "E", \r
759         "\u221E", \r
760         "XXX", \r
761         "\uFFFD", \r
762         ".#,-.*;%\u2030+@0"\r
763     };\r
764 \r
765     static String en_StringSymbols[] = {\r
766         "\u00A4", \r
767         "E", \r
768         "\u221E", \r
769         "XXX", \r
770         "\uFFFD", \r
771         ".#,-.*;%\u2030+@0"\r
772     };\r
773 \r
774     static String fr_FR_StringSymbols[] = {\r
775         "\u20AC", \r
776         "E", \r
777         "\u221E", \r
778         "EUR", \r
779         "\uFFFD", \r
780         ",#\u00A0-,*;%\u2030+@0"\r
781     };\r
782 \r
783     static String fr_StringSymbols[] = {\r
784         "\u00A4", \r
785         "E", \r
786         "\u221E", \r
787         "XXX", \r
788         "\uFFFD", \r
789         ",#\u00A0-,*;%\u2030+@0"\r
790     };\r
791 \r
792     static String de_StringSymbols[] = {\r
793         "\u00A4", \r
794         "E", \r
795         "\u221E", \r
796         "XXX", \r
797         "\uFFFD",\r
798         ",#.-,*;%\u2030+@0"\r
799     };\r
800 \r
801     static String de_DE_StringSymbols[] = {\r
802         "\u20AC", \r
803         "E", \r
804         "\u221E", \r
805         "EUR", \r
806         "\uFFFD", \r
807         ",#.-,*;%\u2030+@0"\r
808     };\r
809 \r
810     static String it_StringSymbols[] = {\r
811         "\u00A4", \r
812         "E", \r
813         "\u221E", \r
814         "XXX", \r
815         "\uFFFD", \r
816         ",#.-,*;%\u2030+@0"\r
817     };\r
818 \r
819     static String it_IT_StringSymbols[] = {\r
820         "\u20AC", \r
821         "E", \r
822         "\u221E", \r
823         "EUR", \r
824         "\uFFFD", \r
825         ",#.-,*;%\u2030+@0"\r
826     };\r
827 \r
828     static String ja_JP_StringSymbols[] = {\r
829         "\uFFE5", \r
830         "E", \r
831         "\u221E", \r
832         "JPY", \r
833         "\uFFFD", \r
834         ".#,-.*;%\u2030+@0"\r
835     };\r
836 \r
837     static String ja_StringSymbols[] = {\r
838         "\u00A4", \r
839         "E", \r
840         "\u221E", \r
841         "XXX", \r
842         "\uFFFD", \r
843         ".#,-.*;%\u2030+@0"\r
844     };\r
845 \r
846     static String ko_KR_StringSymbols[] = {\r
847         "\uFFE6", \r
848         "E", \r
849         "\u221E", \r
850         "KRW", \r
851         "\uFFFD",\r
852         ".#,-.*;%\u2030+@0"\r
853     };\r
854 \r
855     static String ko_StringSymbols[] = {\r
856         "\u00A4", \r
857         "E", \r
858         "\u221E", \r
859         "XXX", \r
860         "\uFFFD",\r
861         ".#,-.*;%\u2030+@0"\r
862     };\r
863 \r
864     static String zh_Hans_CN_StringSymbols[] = {\r
865         "\uFFE5", \r
866         "E", \r
867         "\u221E", \r
868         "CNY", \r
869         "\uFFFD", \r
870         ".#,-.*;%\u2030+@0"\r
871     };\r
872 \r
873     static String zh_Hant_TW_StringSymbols[] = {\r
874         "NT$", \r
875         "E", \r
876         "\u221E", \r
877         "TWD", \r
878         "\uFFFD", \r
879         ".#,-.*;%\u2030+@0"\r
880     };\r
881 \r
882     static String zh_TW_StringSymbols[] = {\r
883         "NT$", \r
884         "E", \r
885         "\u221E", \r
886         "TWD", \r
887         "\uFFFD", \r
888         ".#,-.*;%\u2030+@0"\r
889     };\r
890 \r
891     static String en_GB_StringSymbols[] = {\r
892         "\u00A3", \r
893         "E", \r
894         "\u221E", \r
895         "GBP", \r
896         "\uFFFD", \r
897         ".#,-.*;%\u2030+@0"\r
898     };\r
899 \r
900     static String en_US_StringSymbols[] = {\r
901         "$", \r
902         "E", \r
903         "\u221E", \r
904         "USD", \r
905         "\uFFFD",\r
906         ".#,-.*;%\u2030+@0"\r
907     };\r
908     \r
909     static {\r
910         cannedDecimalFormatSymbols.put("en_CA",      en_CA_StringSymbols);\r
911         cannedDecimalFormatSymbols.put("fr_CA",      fr_CA_StringSymbols);\r
912         cannedDecimalFormatSymbols.put("zh_CN",      zh_CN_StringSymbols);\r
913         cannedDecimalFormatSymbols.put("zh",         zh_StringSymbols);\r
914         cannedDecimalFormatSymbols.put("en",         en_StringSymbols);\r
915         cannedDecimalFormatSymbols.put("fr_FR",      fr_FR_StringSymbols);\r
916         cannedDecimalFormatSymbols.put("fr",         fr_StringSymbols);\r
917         cannedDecimalFormatSymbols.put("de",         de_StringSymbols);\r
918         cannedDecimalFormatSymbols.put("de_DE",      de_DE_StringSymbols);\r
919         cannedDecimalFormatSymbols.put("it",         it_StringSymbols);\r
920         cannedDecimalFormatSymbols.put("it_IT",      it_IT_StringSymbols);\r
921         cannedDecimalFormatSymbols.put("ja_JP",      ja_JP_StringSymbols);\r
922         cannedDecimalFormatSymbols.put("ja",         ja_StringSymbols);\r
923         cannedDecimalFormatSymbols.put("ko_KR",      ko_KR_StringSymbols);\r
924         cannedDecimalFormatSymbols.put("ko",         ko_StringSymbols);\r
925         cannedDecimalFormatSymbols.put("zh_Hans_CN", zh_Hans_CN_StringSymbols);\r
926         cannedDecimalFormatSymbols.put("zh_Hant_TW", zh_Hant_TW_StringSymbols);\r
927         cannedDecimalFormatSymbols.put("zh_TW",      zh_TW_StringSymbols);\r
928         cannedDecimalFormatSymbols.put("en_GB",      en_GB_StringSymbols);\r
929         cannedDecimalFormatSymbols.put("en_US",      en_US_StringSymbols);\r
930     }\r
931     \r
932     private static char[] getCharSymbols(DecimalFormatSymbols dfs)\r
933     {\r
934         char symbols[] = {\r
935             dfs.getDecimalSeparator(),\r
936             dfs.getDigit(),\r
937             dfs.getGroupingSeparator(),\r
938             dfs.getMinusSign(),\r
939             dfs.getMonetaryDecimalSeparator(),\r
940             dfs.getPadEscape(),\r
941             dfs.getPatternSeparator(),\r
942             dfs.getPercent(),\r
943             dfs.getPerMill(),\r
944             dfs.getPlusSign(),\r
945             dfs.getSignificantDigit(),\r
946             dfs.getZeroDigit()\r
947         };\r
948         \r
949         return symbols;\r
950     }\r
951     \r
952     private static void setCharSymbols(DecimalFormatSymbols dfs, char symbols[])\r
953     {\r
954         dfs.setDecimalSeparator(symbols[0]);\r
955         dfs.setDigit(symbols[1]);\r
956         dfs.setGroupingSeparator(symbols[2]);\r
957         dfs.setMinusSign(symbols[3]);\r
958         dfs.setMonetaryDecimalSeparator(symbols[4]);\r
959         dfs.setPadEscape(symbols[5]);\r
960         dfs.setPatternSeparator(symbols[6]);\r
961         dfs.setPercent(symbols[7]);\r
962         dfs.setPerMill(symbols[8]);\r
963         dfs.setPlusSign(symbols[9]);\r
964         dfs.setSignificantDigit(symbols[10]);\r
965         dfs.setZeroDigit(symbols[11]);\r
966     }\r
967     \r
968     private static String[] getStringSymbols(DecimalFormatSymbols dfs)\r
969     {\r
970         String symbols[] = {\r
971             dfs.getCurrencySymbol(),\r
972             dfs.getExponentSeparator(),\r
973             dfs.getInfinity(),\r
974             dfs.getInternationalCurrencySymbol(),\r
975             dfs.getNaN()\r
976         };\r
977         \r
978         return symbols;\r
979     }\r
980     \r
981     private static DecimalFormatSymbols getCannedDecimalFormatSymbols(ULocale uloc)\r
982     {\r
983         DecimalFormatSymbols dfs = new DecimalFormatSymbols(uloc);\r
984         \r
985         setSymbols(dfs, (String[]) cannedDecimalFormatSymbols.get(uloc.toString()));\r
986         \r
987         return dfs;\r
988     }\r
989 \r
990     private static DecimalFormat getCannedDecimalFormat(String pattern, ULocale uloc)\r
991     {\r
992         return new DecimalFormat(pattern, getCannedDecimalFormatSymbols(uloc));\r
993     }\r
994     \r
995     private static void setSymbols(DecimalFormatSymbols dfs, String symbols[])\r
996     {\r
997         dfs.setCurrencySymbol(symbols[0]);\r
998         dfs.setExponentSeparator(symbols[1]);\r
999         dfs.setInfinity(symbols[2]);\r
1000         dfs.setInternationalCurrencySymbol(symbols[3]);\r
1001         dfs.setNaN(symbols[4]);\r
1002         \r
1003         setCharSymbols(dfs, symbols[5].toCharArray());\r
1004     }\r
1005     \r
1006     public static class RelativeDateFormatHandler implements SerializableTest.Handler\r
1007     {\r
1008         public Object[] getTestObjects()\r
1009         {\r
1010             DateFormat formats[] = { \r
1011                     DateFormat.getDateInstance(DateFormat.RELATIVE_LONG,new ULocale("en")),\r
1012                     DateFormat.getDateInstance(DateFormat.RELATIVE_SHORT,new ULocale("ru")),\r
1013             };\r
1014             \r
1015             return formats;\r
1016         }\r
1017         \r
1018         public boolean hasSameBehavior(Object a, Object b) {\r
1019             DateFormat da = (DateFormat)a;\r
1020             DateFormat db = (DateFormat)b;\r
1021             \r
1022             Date d = new Date(System.currentTimeMillis());\r
1023             return da.format(d).equals(db.format(d));\r
1024         }\r
1025     }\r
1026 \r
1027     public static class BasicDurationFormatHandler implements SerializableTest.Handler\r
1028     {\r
1029         public Object[] getTestObjects()\r
1030         {\r
1031             DurationFormat formats[] = { \r
1032                     DurationFormat.getInstance(new ULocale("en"))\r
1033                    \r
1034             };\r
1035             \r
1036             return formats;\r
1037         }\r
1038         \r
1039         //TODO: Revisit this after 3.8\r
1040         public boolean hasSameBehavior(Object a, Object b) {\r
1041             //DurationFormat da = (DurationFormat)a;\r
1042             //DurationFormat db = (DurationFormat)b;\r
1043             \r
1044             //Date d = new Date(12345);\r
1045             //System.err.println("Warning: BasicDurationFormat test is being skipped for now.");\r
1046             return true;\r
1047             //return da.format(d).equals(db.format(d));\r
1048         }\r
1049     }\r
1050 \r
1051     public static class NumberFormatHandler implements SerializableTest.Handler\r
1052     {\r
1053         public Object[] getTestObjects()\r
1054         {\r
1055             ULocale uloc = ULocale.forLocale(Locale.US);\r
1056             NumberFormat formats[] = {\r
1057                 /*\r
1058                  * The code below was used to genereate the\r
1059                  * serialized NumberFormat objects in ICU 3.6:\r
1060                  * \r
1061                  *    NumberFormat.getInstance(Locale.US)\r
1062                  *    NumberFormat.getCurrencyInstance(Locale.US)\r
1063                  *    NumberFormat.getPercentInstance(Locale.US)\r
1064                  *    NumberFormat.getScientificInstance(Locale.US)\r
1065                  * \r
1066                  * Because the locale data might now be different that it was in\r
1067                  * ICU 3.6, the only way to guarantee that the object we generate\r
1068                  * will match the ICU 3.6 objects is to generate DecimalFormat objects\r
1069                  * that use the same patterns and DecimalFormatSymbols that\r
1070                  * were used in ICU 3.6.\r
1071                  */\r
1072                 getCannedDecimalFormat("#,##0.###", uloc),\r
1073                 getCannedDecimalFormat("\u00A4#,##0.00;(\u00A4#,##0.00)", uloc),\r
1074                 getCannedDecimalFormat("#,##0%", uloc),\r
1075                 getCannedDecimalFormat("#E0", uloc)\r
1076                \r
1077             };\r
1078             \r
1079             return formats;\r
1080         }\r
1081 \r
1082         public boolean hasSameBehavior(Object a, Object b)\r
1083         {\r
1084             NumberFormat format_a = (NumberFormat) a;\r
1085             NumberFormat format_b = (NumberFormat) b;\r
1086             double number = 1234.56;\r
1087             \r
1088             return format_a.format(number).equals(format_b.format(number));\r
1089         }\r
1090     }\r
1091     \r
1092     public static class DecimalFormatHandler extends NumberFormatHandler\r
1093     {\r
1094         public Object[] getTestObjects()\r
1095         {\r
1096             Locale locales[] = SerializableTest.getLocales();\r
1097             DecimalFormat formats[] = new DecimalFormat[locales.length];\r
1098             \r
1099             for (int i = 0; i < locales.length; i += 1) {\r
1100                 ULocale uloc = ULocale.forLocale(locales[i]);\r
1101                 \r
1102                 formats[i] = getCannedDecimalFormat("#,##0.###", uloc);\r
1103             }\r
1104 //#if defined(FOUNDATION10) || defined(J2SE13)\r
1105 //#else\r
1106             if (formats[0] != null) {\r
1107                 // Ticket#6449\r
1108                 // Once formatToCharacterIterator is called, NumberFormat.Field\r
1109                 // instances are created and stored in the private List field.\r
1110                 // NumberForamt.Field is not a serializable, so serializing such\r
1111                 // instances end up NotSerializableException.  This problem was\r
1112                 // reproduced since formatToCharacterIterator was introduced,\r
1113                 // up to ICU 4.0.\r
1114 \r
1115                 AttributedCharacterIterator aci = formats[0].formatToCharacterIterator(new Double(12.345D));\r
1116                 if (aci == null) {} // NOP - for resolving 'Unused local variable' warning.\r
1117             }\r
1118 //#endif\r
1119             return formats;\r
1120         }\r
1121     }\r
1122     \r
1123     public static class RuleBasedNumberFormatHandler extends NumberFormatHandler\r
1124     {\r
1125         // default rules, from root.txt\r
1126         String xx_SpelloutRules = "=#,##0.######=;\n";\r
1127         String xx_OrdinalRules = "=#,##0=;\n";\r
1128         String xx_DurationRules = "=#,##0=;\n";\r
1129         \r
1130         String ja_spelloutRules = \r
1131             "%financial:\n" +\r
1132                 "\u96f6; \u58f1; \u5f10; \u53c2; \u56db; \u4f0d; \u516d; \u4e03; \u516b; \u4e5d;\n" +\r
1133                 "\u62fe[>>];\n" +\r
1134                 "20: <<\u62fe[>>];\n" +\r
1135                 "100: <<\u767e[>>];\n" +\r
1136                 "1000: <<\u5343[>>];\n" +\r
1137                 "10,000: <<\u4e07[>>];\n" +\r
1138                 "100,000,000: <<\u5104[>>];\n" +\r
1139                 "1,000,000,000,000: <<\u5146[>>];\n" +\r
1140                 "10,000,000,000,000,000: =#,##0=;\n" +\r
1141                 \r
1142             "%traditional:\n" +\r
1143                 "\u96f6; \u4e00; \u4e8c; \u4e09; \u56db; \u4e94; \u516d; \u4e03; \u516b; \u4e5d;\n" +\r
1144                 "\u5341[>>];\n" +\r
1145                 "20: <<\u5341[>>];\n" +\r
1146                 "100: <<\u767e[>>];\n" +\r
1147                 "1000: <<\u5343[>>];\n" +\r
1148                 "10,000: <<\u4e07[>>];\n" +\r
1149                 "100,000,000: <<\u5104[>>];\n" +\r
1150                 "1,000,000,000,000: <<\u5146[>>];\n" +\r
1151                 "10,000,000,000,000,000: =#,##0=;";\r
1152         \r
1153         String en_SpelloutRules = \r
1154             // This rule set shows the normal simple formatting rules for English\r
1155             "%simplified:\n" +\r
1156                    // negative number rule.  This rule is used to format negative\r
1157                    // numbers.  The result of formatting the number's absolute\r
1158                    // value is placed where the >> is.\r
1159                 "-x: minus >>;\n" +\r
1160                    // faction rule.  This rule is used for formatting numbers\r
1161                    // with fractional parts.  The result of formatting the\r
1162                    // number's integral part is substituted for the <<, and\r
1163                    // the result of formatting the number's fractional part\r
1164                    // (one digit at a time, e.g., 0.123 is "zero point one two\r
1165                    // three") replaces the >>.\r
1166                 "x.x: << point >>;\n" +\r
1167                    // the rules for the values from 0 to 19 are simply the\r
1168                    // words for those numbers\r
1169                 "zero; one; two; three; four; five; six; seven; eight; nine;\n" +\r
1170                 "ten; eleven; twelve; thirteen; fourteen; fifteen; sixteen;\n" +\r
1171                     "seventeen; eighteen; nineteen;\n" +\r
1172                    // beginning at 20, we use the >> to mark the position where\r
1173                    // the result of formatting the number's ones digit.  Thus,\r
1174                    // we only need a new rule at every multiple of 10.  Text in\r
1175                    // backets is omitted if the value being formatted is an\r
1176                    // even multiple of 10.\r
1177                 "20: twenty[->>];\n" +\r
1178                 "30: thirty[->>];\n" +\r
1179                 "40: forty[->>];\n" +\r
1180                 "50: fifty[->>];\n" +\r
1181                 "60: sixty[->>];\n" +\r
1182                 "70: seventy[->>];\n" +\r
1183                 "80: eighty[->>];\n" +\r
1184                 "90: ninety[->>];\n" +\r
1185                    // beginning at 100, we can use << to mark the position where\r
1186                    // the result of formatting the multiple of 100 is to be\r
1187                    // inserted.  Notice also that the meaning of >> has shifted:\r
1188                    // here, it refers to both the ones place and the tens place.\r
1189                    // The meanings of the << and >> tokens depend on the base value\r
1190                    // of the rule.  A rule's divisor is (usually) the highest\r
1191                    // power of 10 that is less than or equal to the rule's base\r
1192                    // value.  The value being formatted is divided by the rule's\r
1193                    // divisor, and the integral quotient is used to get the text\r
1194                    // for <<, while the remainder is used to produce the text\r
1195                    // for >>.  Again, text in brackets is omitted if the value\r
1196                    // being formatted is an even multiple of the rule's divisor\r
1197                    // (in this case, an even multiple of 100)\r
1198                 "100: << hundred[ >>];\n" +\r
1199                    // The rules for the higher numbers work the same way as the\r
1200                    // rule for 100: Again, the << and >> tokens depend on the\r
1201                    // rule's divisor, which for all these rules is also the rule's\r
1202                    // base value.  To group by thousand, we simply don't have any\r
1203                    // rules between 1,000 and 1,000,000.\r
1204                 "1000: << thousand[ >>];\n" +\r
1205                 "1,000,000: << million[ >>];\n" +\r
1206                 "1,000,000,000: << billion[ >>];\n" +\r
1207                 "1,000,000,000,000: << trillion[ >>];\n" +\r
1208                    // overflow rule.  This rule specifies that values of a\r
1209                    // quadrillion or more are shown in numerals rather than words.\r
1210                    // The == token means to format (with new rules) the value\r
1211                    // being formatted by this rule and place the result where\r
1212                    // the == is.  The #,##0 inside the == signs is a\r
1213                    // DecimalFormat pattern.  It specifies that the value should\r
1214                    // be formatted with a DecimalFormat object, and that it\r
1215                    // should be formatted with no decimal places, at least one\r
1216                    // digit, and a thousands separator.\r
1217                 "1,000,000,000,000,000: =#,##0=;\n" +\r
1218 \r
1219             // %default is a more elaborate form of %simplified;  It is basically\r
1220             // the same, except that it introduces "and" before the ones digit\r
1221             // when appropriate (basically, between the tens and ones digits) and\r
1222             // separates the thousands groups with commas in values over 100,000.\r
1223             "%default:\n" +\r
1224                    // negative-number and fraction rules.  These are the same\r
1225                    // as those for %simplified, but have to be stated here too\r
1226                    // because this is an entry point\r
1227                 "-x: minus >>;\n" +\r
1228                 "x.x: << point >>;\n" +\r
1229                    // just use %simplified for values below 100\r
1230                 "=%simplified=;\n" +\r
1231                    // for values from 100 to 9,999 use %%and to decide whether or\r
1232                    // not to interpose the "and"\r
1233                 "100: << hundred[ >%%and>];\n" +\r
1234                 "1000: << thousand[ >%%and>];\n" +\r
1235                    // for values of 100,000 and up, use %%commas to interpose the\r
1236                    // commas in the right places (and also to interpose the "and")\r
1237                 "100,000>>: << thousand[>%%commas>];\n" +\r
1238                 "1,000,000: << million[>%%commas>];\n" +\r
1239                 "1,000,000,000: << billion[>%%commas>];\n" +\r
1240                 "1,000,000,000,000: << trillion[>%%commas>];\n" +\r
1241                 "1,000,000,000,000,000: =#,##0=;\n" +\r
1242             // if the value passed to this rule set is greater than 100, don't\r
1243             // add the "and"; if it's less than 100, add "and" before the last\r
1244             // digits\r
1245             "%%and:\n" +\r
1246                 "and =%default=;\n" +\r
1247                 "100: =%default=;\n" +\r
1248             // this rule set is used to place the commas\r
1249             "%%commas:\n" +\r
1250                    // for values below 100, add "and" (the apostrophe at the\r
1251                    // beginning is ignored, but causes the space that follows it\r
1252                    // to be significant: this is necessary because the rules\r
1253                    // calling %%commas don't put a space before it)\r
1254                 "' and =%default=;\n" +\r
1255                    // put a comma after the thousands (or whatever preceded the\r
1256                    // hundreds)\r
1257                 "100: , =%default=;\n" +\r
1258                    // put a comma after the millions (or whatever precedes the\r
1259                    // thousands)\r
1260                 "1000: , <%default< thousand, >%default>;\n" +\r
1261                    // and so on...\r
1262                 "1,000,000: , =%default=;" +\r
1263             // %%lenient-parse isn't really a set of number formatting rules;\r
1264             // it's a set of collation rules.  Lenient-parse mode uses a Collator\r
1265             // object to compare fragments of the text being parsed to the text\r
1266             // in the rules, allowing more leeway in the matching text.  This set\r
1267             // of rules tells the formatter to ignore commas when parsing (it\r
1268             // already ignores spaces, which is why we refer to the space; it also\r
1269             // ignores hyphens, making "twenty one" and "twenty-one" parse\r
1270             // identically)\r
1271             "%%lenient-parse:\n" +\r
1272             //                "& ' ' , ',' ;\n" +\r
1273             "   &\u0000 << ' ' << ',' << '-'; \n";\r
1274 \r
1275         String en_GB_SpelloutRules =\r
1276             "%simplified:\n" +\r
1277             "-x: minus >>;\n" +\r
1278             "x.x: << point >>;\n" +\r
1279             "zero; one; two; three; four; five; six; seven; eight; nine;\n" +\r
1280             "ten; eleven; twelve; thirteen; fourteen; fifteen; sixteen;\n" +\r
1281             "    seventeen; eighteen; nineteen;\n" +\r
1282             "20: twenty[->>];\n" +\r
1283             "30: thirty[->>];\n" +\r
1284             "40: forty[->>];\n" +\r
1285             "50: fifty[->>];\n" +\r
1286             "60: sixty[->>];\n" +\r
1287             "70: seventy[->>];\n" +\r
1288             "80: eighty[->>];\n" +\r
1289             "90: ninety[->>];\n" +\r
1290             "100: << hundred[ >>];\n" +\r
1291             "1000: << thousand[ >>];\n" +\r
1292             "1,000,000: << million[ >>];\n" +\r
1293             "1,000,000,000,000: << billion[ >>];\n" +\r
1294             "1,000,000,000,000,000: =#,##0=;\n" +\r
1295         "%default:\n" +\r
1296             "-x: minus >>;\n" +\r
1297             "x.x: << point >>;\n" +\r
1298             "=%simplified=;\n" +\r
1299             "100: << hundred[ >%%and>];\n" +\r
1300             "1000: << thousand[ >%%and>];\n" +\r
1301             "100,000>>: << thousand[>%%commas>];\n" +\r
1302             "1,000,000: << million[>%%commas>];\n" +\r
1303             "1,000,000,000,000: << billion[>%%commas>];\n" +\r
1304             "1,000,000,000,000,000: =#,##0=;\n" +\r
1305         "%%and:\n" +\r
1306             "and =%default=;\n" +\r
1307             "100: =%default=;\n" +\r
1308         "%%commas:\n" +\r
1309             "' and =%default=;\n" +\r
1310             "100: , =%default=;\n" +\r
1311             "1000: , <%default< thousand, >%default>;\n" +\r
1312             "1,000,000: , =%default=;" +\r
1313         "%%lenient-parse:\n" +\r
1314             "& ' ' , ',' ;\n";\r
1315         \r
1316         String fr_SpelloutRules =\r
1317             // the main rule set\r
1318             "%main:\n" +\r
1319                 "-x: moins >>;\n" +\r
1320                 "x.x: << virgule >>;\n" +\r
1321                    // words for numbers from 0 to 10\r
1322                 "z\u00e9ro; un; deux; trois; quatre; cinq; six; sept; huit; neuf;\n" +\r
1323                 "dix; onze; douze; treize; quatorze; quinze; seize;\n" +\r
1324                 "    dix-sept; dix-huit; dix-neuf;\n" +\r
1325                    // ords for the multiples of 10: %%alt-ones inserts "et"\r
1326                    // when needed\r
1327                 "20: vingt[->%%alt-ones>];\n" +\r
1328                 "30: trente[->%%alt-ones>];\n" +\r
1329                 "40: quarante[->%%alt-ones>];\n" +\r
1330                 "50: cinquante[->%%alt-ones>];\n" +\r
1331                    // rule for 60.  The /20 causes this rule's multiplier to be\r
1332                    // 20 rather than 10, allowinhg us to recurse for all values\r
1333                    // from 60 to 79...\r
1334                 "60/20: soixante[->%%alt-ones>];\n" +\r
1335                    // ...except for 71, which must be special-cased\r
1336                 "71: soixante et onze;\n" +\r
1337                    // at 72, we have to repeat the rule for 60 to get us to 79\r
1338                 "72/20: soixante->%%alt-ones>;\n" +\r
1339                    // at 80, we state a new rule with the phrase for 80.  Since\r
1340                    // it changes form when there's a ones digit, we need a second\r
1341                    // rule at 81.  This rule also includes "/20," allowing it to\r
1342                    // be used correctly for all values up to 99\r
1343                 "80: quatre-vingts; 81/20: quatre-vingt->>;\n" +\r
1344                    // "cent" becomes plural when preceded by a multiplier, and\r
1345                    // the multiplier is omitted from the singular form\r
1346                 "100: cent[ >>];\n" +\r
1347                 "200: << cents[ >>];\n" +\r
1348                 "1000: mille[ >>];\n" +\r
1349                    // values from 1,100 to 1,199 are rendered as "onze cents..."\r
1350                    // instead of "mille cent..."  The > after "1000" decreases\r
1351                    // the rule's exponent, causing its multiplier to be 100 instead\r
1352                    // of 1,000.  This prevents us from getting "onze cents cent\r
1353                    // vingt-deux" ("eleven hundred one hundred twenty-two").\r
1354                 "1100>: onze cents[ >>];\n" +\r
1355                    // at 1,200, we go back to formating in thousands, so we\r
1356                    // repeat the rule for 1,000\r
1357                 "1200: mille >>;\n" +\r
1358                    // at 2,000, the multiplier is added\r
1359                 "2000: << mille[ >>];\n" +\r
1360                 "1,000,000: << million[ >>];\n" +\r
1361                 "1,000,000,000: << milliard[ >>];\n" +\r
1362                 "1,000,000,000,000: << billion[ >>];\n" +\r
1363                 "1,000,000,000,000,000: =#,##0=;\n" +\r
1364             // %%alt-ones is used to insert "et" when the ones digit is 1\r
1365             "%%alt-ones:\n" +\r
1366                 "; et-un; =%main=;\n" + \r
1367             "%%lenient-parse:\n" +\r
1368                 "&\u0000 << ' ' << ',' << '-';\n";\r
1369         \r
1370         String de_SpelloutRules =\r
1371             // 1 is "eins" when by itself, but turns into "ein" in most\r
1372             // combinations\r
1373             "%alt-ones:\n" +\r
1374                 "-x: minus >>;\n" +\r
1375                 "x.x: << komma >>;\n" +\r
1376                 "null; eins; =%%main=;\n" +\r
1377             "%%main:\n" +\r
1378                    // words for numbers from 0 to 12.  Notice that the values\r
1379                    // from 13 to 19 can derived algorithmically, unlike in most\r
1380                    // other languages\r
1381                 "null; ein; zwei; drei; vier; f\u00fcnf; sechs; sieben; acht; neun;\n" +\r
1382                 "zehn; elf; zw\u00f6lf; >>zehn;\n" +\r
1383                    // rules for the multiples of 10.  Notice that the ones digit\r
1384                    // goes on the front\r
1385                 "20: [>>und]zwanzig;\n" +\r
1386                 "30: [>>und]drei\u00dfig;\n" +\r
1387                 "40: [>>und]vierzig;\n" +\r
1388                 "50: [>>und]f\u00fcnfzig;\n" +\r
1389                 "60: [>>und]sechzig;\n" +\r
1390                 "70: [>>und]siebzig;\n" +\r
1391                 "80: [>>und]achtzig;\n" +\r
1392                 "90: [>>und]neunzig;\n" +\r
1393                 "100: hundert[>%alt-ones>];\n" +\r
1394                 "200: <<hundert[>%alt-ones>];\n" +\r
1395                 "1000: tausend[>%alt-ones>];\n" +\r
1396                 "2000: <<tausend[>%alt-ones>];\n" +\r
1397                 "1,000,000: eine Million[ >%alt-ones>];\n" +\r
1398                 "2,000,000: << Millionen[ >%alt-ones>];\n" +\r
1399                 "1,000,000,000: eine Milliarde[ >%alt-ones>];\n" +\r
1400                 "2,000,000,000: << Milliarden[ >%alt-ones>];\n" +\r
1401                 "1,000,000,000,000: eine Billion[ >%alt-ones>];\n" +\r
1402                 "2,000,000,000,000: << Billionen[ >%alt-ones>];\n" +\r
1403                 "1,000,000,000,000,000: =#,##0=;" +\r
1404             "%%lenient-parse:\n" +\r
1405                 "&\u0000 << ' ' << '-'\n" +\r
1406                 "& ae , \u00e4 & ae , \u00c4\n" +\r
1407                 "& oe , \u00f6 & oe , \u00d6\n" +\r
1408                 "& ue , \u00fc & ue , \u00dc\n";\r
1409         \r
1410         String it_SpelloutRules =\r
1411             // main rule set.  Follows the patterns of the preceding rule sets,\r
1412             // except that the final vowel is omitted from words ending in\r
1413             // vowels when they are followed by another word; instead, we have\r
1414             // separate rule sets that are identical to this one, except that\r
1415             // all the words that don't begin with a vowel have a vowel tacked\r
1416             // onto them at the front.  A word ending in a vowel calls a\r
1417             // substitution that will supply that vowel, unless that vowel is to\r
1418             // be elided.\r
1419             "%main:\n" +\r
1420                 "-x: meno >>;\n" +\r
1421                 "x.x: << virgola >>;\n" +\r
1422                 "zero; uno; due; tre; quattro; cinque; sei; sette; otto; nove;\n" +\r
1423                 "dieci; undici; dodici; tredici; quattordici; quindici; sedici;\n" +\r
1424                 "    diciasette; diciotto; diciannove;\n" +\r
1425                 "20: venti; vent>%%with-i>;\n" +\r
1426                 "30: trenta; trent>%%with-i>;\n" +\r
1427                 "40: quaranta; quarant>%%with-a>;\n" +\r
1428                 "50: cinquanta; cinquant>%%with-a>;\n" +\r
1429                 "60: sessanta; sessant>%%with-a>;\n" +\r
1430                 "70: settanta; settant>%%with-a>;\n" +\r
1431                 "80: ottanta; ottant>%%with-a>;\n" +\r
1432                 "90: novanta; novant>%%with-a>;\n" +\r
1433                 "100: cento; cent[>%%with-o>];\n" +\r
1434                 "200: <<cento; <<cent[>%%with-o>];\n" +\r
1435                 "1000: mille; mill[>%%with-i>];\n" +\r
1436                 "2000: <<mila; <<mil[>%%with-a>];\n" +\r
1437                 "100,000>>: <<mila[ >>];\n" +\r
1438                 "1,000,000: =#,##0= (incomplete data);\n" +\r
1439             "%%with-a:\n" +\r
1440                 "azero; uno; adue; atre; aquattro; acinque; asei; asette; otto; anove;\n" +\r
1441                 "adieci; undici; adodici; atredici; aquattordici; aquindici; asedici;\n" +\r
1442                 "    adiciasette; adiciotto; adiciannove;\n" +\r
1443                 "20: aventi; avent>%%with-i>;\n" +\r
1444                 "30: atrenta; atrent>%%with-i>;\n" +\r
1445                 "40: aquaranta; aquarant>%%with-a>;\n" +\r
1446                 "50: acinquanta; acinquant>%%with-a>;\n" +\r
1447                 "60: asessanta; asessant>%%with-a>;\n" +\r
1448                 "70: asettanta; asettant>%%with-a>;\n" +\r
1449                 "80: ottanta; ottant>%%with-a>;\n" +\r
1450                 "90: anovanta; anovant>%%with-a>;\n" +\r
1451                 "100: acento; acent[>%%with-o>];\n" +\r
1452                 "200: <%%with-a<cento; <%%with-a<cent[>%%with-o>];\n" +\r
1453                 "1000: amille; amill[>%%with-i>];\n" +\r
1454                 "2000: <%%with-a<mila; <%%with-a<mil[>%%with-a>];\n" +\r
1455                 "100,000: =%main=;\n" +\r
1456             "%%with-i:\n" +\r
1457                 "izero; uno; idue; itre; iquattro; icinque; isei; isette; otto; inove;\n" +\r
1458                 "idieci; undici; idodici; itredici; iquattordici; iquindici; isedici;\n" +\r
1459                 "    idiciasette; idiciotto; idiciannove;\n" +\r
1460                 "20: iventi; ivent>%%with-i>;\n" +\r
1461                 "30: itrenta; itrent>%%with-i>;\n" +\r
1462                 "40: iquaranta; iquarant>%%with-a>;\n" +\r
1463                 "50: icinquanta; icinquant>%%with-a>;\n" +\r
1464                 "60: isessanta; isessant>%%with-a>;\n" +\r
1465                 "70: isettanta; isettant>%%with-a>;\n" +\r
1466                 "80: ottanta; ottant>%%with-a>;\n" +\r
1467                 "90: inovanta; inovant>%%with-a>;\n" +\r
1468                 "100: icento; icent[>%%with-o>];\n" +\r
1469                 "200: <%%with-i<cento; <%%with-i<cent[>%%with-o>];\n" +\r
1470                 "1000: imille; imill[>%%with-i>];\n" +\r
1471                 "2000: <%%with-i<mila; <%%with-i<mil[>%%with-a>];\n" +\r
1472                 "100,000: =%main=;\n" +\r
1473             "%%with-o:\n" +\r
1474                 "ozero; uno; odue; otre; oquattro; ocinque; osei; osette; otto; onove;\n" +\r
1475                 "odieci; undici; ododici; otredici; oquattordici; oquindici; osedici;\n" +\r
1476                 "    odiciasette; odiciotto; odiciannove;\n" +\r
1477                 "20: oventi; ovent>%%with-i>;\n" +\r
1478                 "30: otrenta; otrent>%%with-i>;\n" +\r
1479                 "40: oquaranta; oquarant>%%with-a>;\n" +\r
1480                 "50: ocinquanta; ocinquant>%%with-a>;\n" +\r
1481                 "60: osessanta; osessant>%%with-a>;\n" +\r
1482                 "70: osettanta; osettant>%%with-a>;\n" +\r
1483                 "80: ottanta; ottant>%%with-a>;\n" +\r
1484                 "90: onovanta; onovant>%%with-a>;\n" +\r
1485                 "100: ocento; ocent[>%%with-o>];\n" +\r
1486                 "200: <%%with-o<cento; <%%with-o<cent[>%%with-o>];\n" +\r
1487                 "1000: omille; omill[>%%with-i>];\n" +\r
1488                 "2000: <%%with-o<mila; <%%with-o<mil[>%%with-a>];\n" +\r
1489                 "100,000: =%main=;\n" ;\r
1490         \r
1491         String en_OrdinalRules =\r
1492             // this rule set formats the numeral and calls %%abbrev to\r
1493             // supply the abbreviation\r
1494             "%main:\n" +\r
1495                 "=#,##0==%%abbrev=;\n" +\r
1496             // this rule set supplies the abbreviation\r
1497             "%%abbrev:\n" +\r
1498                    // the abbreviations.  Everything from 4 to 19 ends in "th"\r
1499                 "th; st; nd; rd; th;\n" +\r
1500                    // at 20, we begin repeating the cycle every 10 (13 is "13th",\r
1501                    // but 23 and 33 are "23rd" and "33rd")  We do this by\r
1502                    // ignoring all bug the ones digit in selecting the abbreviation\r
1503                 "20: >>;\n" +\r
1504                    // at 100, we repeat the whole cycle by considering only the\r
1505                    // tens and ones digits in picking an abbreviation\r
1506                 "100: >>;\n";\r
1507         \r
1508         String en_DurationRules =\r
1509             // main rule set for formatting with words\r
1510             "%with-words:\n" +\r
1511                    // take care of singular and plural forms of "second"\r
1512                 "0 seconds; 1 second; =0= seconds;\n" +\r
1513                    // use %%min to format values greater than 60 seconds\r
1514                 "60/60: <%%min<[, >>];\n" +\r
1515                    // use %%hr to format values greater than 3,600 seconds\r
1516                    // (the ">>>" below causes us to see the number of minutes\r
1517                    // when when there are zero minutes)\r
1518                 "3600/60: <%%hr<[, >>>];\n" +\r
1519             // this rule set takes care of the singular and plural forms\r
1520             // of "minute"\r
1521             "%%min:\n" +\r
1522                 "0 minutes; 1 minute; =0= minutes;\n" +\r
1523             // this rule set takes care of the singular and plural forms\r
1524             // of "hour"\r
1525             "%%hr:\n" +\r
1526                 "0 hours; 1 hour; =0= hours;\n" +\r
1527 \r
1528             // main rule set for formatting in numerals\r
1529             "%in-numerals:\n" +\r
1530                    // values below 60 seconds are shown with "sec."\r
1531                 "=0= sec.;\n" +\r
1532                    // higher values are shown with colons: %%min-sec is used for\r
1533                    // values below 3,600 seconds...\r
1534                 "60: =%%min-sec=;\n" +\r
1535                    // ...and %%hr-min-sec is used for values of 3,600 seconds\r
1536                    // and above\r
1537                 "3600: =%%hr-min-sec=;\n" +\r
1538             // this rule causes values of less than 10 minutes to show without\r
1539             // a leading zero\r
1540             "%%min-sec:\n" +\r
1541                 "0: :=00=;\n" +\r
1542                 "60/60: <0<>>;\n" +\r
1543             // this rule set is used for values of 3,600 or more.  Minutes are always\r
1544             // shown, and always shown with two digits\r
1545             "%%hr-min-sec:\n" +\r
1546                 "0: :=00=;\n" +\r
1547                 "60/60: <00<>>;\n" +\r
1548                 "3600/60: <#,##0<:>>>;\n" +\r
1549             // the lenient-parse rules allow several different characters to be used\r
1550             // as delimiters between hours, minutes, and seconds\r
1551             "%%lenient-parse:\n" +\r
1552                 "& ':' = '.' = ' ' = '-';\n";\r
1553 \r
1554             HashMap cannedData = new HashMap();\r
1555         \r
1556         {\r
1557             cannedData.put("en_CA/SpelloutRules",      en_SpelloutRules);\r
1558             cannedData.put("en_CA/OrdinalRules",       en_OrdinalRules);\r
1559             cannedData.put("en_CA/DurationRules",      en_DurationRules);\r
1560             \r
1561             cannedData.put("fr_CA/SpelloutRules",      fr_SpelloutRules);\r
1562             cannedData.put("fr_CA/OrdinalRules",       xx_OrdinalRules);\r
1563             cannedData.put("fr_CA/DurationRules",      xx_DurationRules);\r
1564             \r
1565             cannedData.put("zh_CN/SpelloutRules",      en_SpelloutRules);\r
1566             cannedData.put("zh_CN/OrdinalRules",       en_OrdinalRules);\r
1567             cannedData.put("zh_CH/DurationRules",      xx_DurationRules);\r
1568             \r
1569             cannedData.put("zh/SpelloutRules",         en_SpelloutRules);\r
1570             cannedData.put("zh/OrdinalRules",          en_OrdinalRules);\r
1571             cannedData.put("zh_DurationRules",         xx_DurationRules);\r
1572             \r
1573             cannedData.put("en/SpelloutRules",         en_SpelloutRules);\r
1574             cannedData.put("en/OrdinalRules",          en_OrdinalRules);\r
1575             cannedData.put("en/DurationRules",         en_DurationRules);\r
1576             \r
1577             cannedData.put("fr_FR/SpelloutRules",      fr_SpelloutRules);\r
1578             cannedData.put("fr_FR/OrdinalRules",       xx_OrdinalRules);\r
1579             cannedData.put("fr_FR/DurationRules",      xx_DurationRules);\r
1580             \r
1581             cannedData.put("fr/SpelloutRules",         fr_SpelloutRules);\r
1582             cannedData.put("fr/OrdinalRules",          xx_OrdinalRules);\r
1583             cannedData.put("fr/DurationRules",         xx_DurationRules);\r
1584             \r
1585             cannedData.put("de/SpelloutRules",         de_SpelloutRules);\r
1586             cannedData.put("de/OrdinalRules",          xx_OrdinalRules);\r
1587             cannedData.put("de/DurationRules",         xx_DurationRules);\r
1588             \r
1589             cannedData.put("de_DE/SpelloutRules",      de_SpelloutRules);\r
1590             cannedData.put("de_DE/OrdinalRules",       xx_OrdinalRules);\r
1591             cannedData.put("de_DE/DurationRules",      xx_DurationRules);\r
1592             \r
1593             cannedData.put("it/SpelloutRules",         it_SpelloutRules);\r
1594             cannedData.put("it/OrdinalRules",          xx_OrdinalRules);\r
1595             cannedData.put("it/DurationRules",         xx_DurationRules);\r
1596             \r
1597             cannedData.put("it_IT/SpelloutRules",      it_SpelloutRules);\r
1598             cannedData.put("it_IT/OrdinalRules",       xx_OrdinalRules);\r
1599             cannedData.put("it_IT/DuratonRules",       xx_DurationRules);\r
1600             \r
1601             cannedData.put("ko_KR/SpelloutRules",      en_SpelloutRules);\r
1602             cannedData.put("ko_KR/OrdinalRules",       en_OrdinalRules);\r
1603             cannedData.put("ko_KR/DurationRules",      en_DurationRules);\r
1604             \r
1605             cannedData.put("ko/SpelloutRules",         en_SpelloutRules);\r
1606             cannedData.put("ko/OrdinalRules",          en_OrdinalRules);\r
1607             cannedData.put("ko/DurationRules",         en_DurationRules);\r
1608             \r
1609             cannedData.put("zh_Hans_CN/SpelloutRules", en_SpelloutRules);\r
1610             cannedData.put("zh_Hans_CN/OrdinalRules",  en_OrdinalRules);\r
1611             cannedData.put("zh_Hans_CH/DurationRules", xx_DurationRules);\r
1612             \r
1613             cannedData.put("zh_Hant_TW/SpelloutRules", en_SpelloutRules);\r
1614             cannedData.put("zh_Hant_TW/OrdinalRules",  en_OrdinalRules);\r
1615             cannedData.put("zh_Hant_TW/DurationRules", en_DurationRules);\r
1616             \r
1617             cannedData.put("zh_TW/SpelloutRules",      en_SpelloutRules);\r
1618             cannedData.put("zh_TW/OrdinalRules",       en_OrdinalRules);\r
1619             cannedData.put("zh_TW/DurationRules",      en_DurationRules);\r
1620             \r
1621             cannedData.put("en_GB/SpelloutRules",      en_GB_SpelloutRules);\r
1622             cannedData.put("en_GB/OrdinalRules",       en_OrdinalRules);\r
1623             cannedData.put("en_GB/DurationRules",      en_DurationRules);\r
1624             \r
1625             cannedData.put("en_US/SpelloutRules",      en_SpelloutRules);\r
1626             cannedData.put("en_US/OrdinalRules",       en_OrdinalRules);\r
1627             cannedData.put("en_US/DurationRules",      en_DurationRules);\r
1628 \r
1629             cannedData.put("ja/SpelloutRules",         ja_spelloutRules);\r
1630             cannedData.put("ja/OrdinalRules",          xx_OrdinalRules);\r
1631             cannedData.put("ja/DurationRules",         xx_DurationRules);\r
1632             \r
1633             cannedData.put("ja_JP/SpelloutRules",      ja_spelloutRules);\r
1634             cannedData.put("ja_JP/OrdinalRules",       xx_OrdinalRules);\r
1635             cannedData.put("ja_JP/DurationRules",      xx_DurationRules);\r
1636         }\r
1637         \r
1638         int types[]        = {RuleBasedNumberFormat.SPELLOUT, RuleBasedNumberFormat.ORDINAL, RuleBasedNumberFormat.DURATION};\r
1639         String typeNames[] = {"SpelloutRules", "OrdinalRules", "DurationRules"};\r
1640         \r
1641         public Object[] getTestObjects()\r
1642         {\r
1643             Locale locales[] = SerializableTest.getLocales();\r
1644             RuleBasedNumberFormat formats[] = new RuleBasedNumberFormat[types.length * locales.length];\r
1645             int i = 0;\r
1646             \r
1647             for (int t = 0; t < types.length; t += 1) {\r
1648                 for (int l = 0; l < locales.length; l += 1) {\r
1649                     String cannedRules = (String) cannedData.get(locales[l].toString() + "/" + typeNames[t]);\r
1650                     \r
1651                     if (cannedRules != null) {\r
1652                         formats[i++] = new RuleBasedNumberFormat(cannedRules, locales[l]);\r
1653                     } else {\r
1654                         formats[i++] = new RuleBasedNumberFormat(locales[l], types[t]);\r
1655                     }\r
1656                 }\r
1657             }\r
1658             \r
1659             return formats;\r
1660         }\r
1661     }\r
1662     \r
1663     public static class DecimalFormatSymbolsHandler implements SerializableTest.Handler\r
1664     {\r
1665         public Object[] getTestObjects()\r
1666         {\r
1667             Locale locales[] = SerializableTest.getLocales();\r
1668             DecimalFormatSymbols dfs[] = new DecimalFormatSymbols[locales.length];\r
1669             \r
1670             for (int i = 0; i < locales.length; i += 1) {\r
1671                 ULocale uloc = ULocale.forLocale(locales[i]);\r
1672 \r
1673                 dfs[i] = getCannedDecimalFormatSymbols(uloc);\r
1674 \r
1675 //                System.out.println("\n    " + uloc.toString() + " = \"" + \r
1676 //                        com.ibm.icu.impl.Utility.escape(String.valueOf(getCharSymbols(dfs[i]), 0, 12)) + "\"");\r
1677             }\r
1678             \r
1679             return dfs;\r
1680         }\r
1681         \r
1682         public boolean hasSameBehavior(Object a, Object b)\r
1683         {\r
1684             DecimalFormatSymbols dfs_a = (DecimalFormatSymbols) a;\r
1685             DecimalFormatSymbols dfs_b = (DecimalFormatSymbols) b;\r
1686             String strings_a[] = getStringSymbols(dfs_a);\r
1687             String strings_b[] = getStringSymbols(dfs_b);\r
1688             char chars_a[] = getCharSymbols(dfs_a);\r
1689             char chars_b[] = getCharSymbols(dfs_b);\r
1690 \r
1691             return SerializableTest.compareStrings(strings_a, strings_b) && SerializableTest.compareChars(chars_a, chars_b);\r
1692         }\r
1693     }\r
1694     \r
1695     public static class CurrencyPluralInfoHandler implements SerializableTest.Handler\r
1696     {\r
1697         public Object[] getTestObjects()\r
1698         {\r
1699             CurrencyPluralInfo currencyPluralInfo[] = {\r
1700                 new CurrencyPluralInfo()\r
1701             };\r
1702             currencyPluralInfo[0].setPluralRules("one: n is 1; few: n in 2..4");\r
1703             currencyPluralInfo[0].setCurrencyPluralPattern("few", "few currency");\r
1704             return currencyPluralInfo;\r
1705         }\r
1706         \r
1707         public boolean hasSameBehavior(Object a, Object b)\r
1708         {\r
1709             return a.equals(b);\r
1710         }\r
1711     }\r
1712     \r
1713     public static class MessageFormatHandler implements SerializableTest.Handler\r
1714     {\r
1715         public Object[] getTestObjects()\r
1716         {\r
1717             MessageFormat formats[] = {new MessageFormat("pattern{0}")};\r
1718             \r
1719             return formats;\r
1720         }\r
1721 \r
1722         public boolean hasSameBehavior(Object a, Object b)\r
1723         {\r
1724             MessageFormat mfa = (MessageFormat) a;\r
1725             MessageFormat mfb = (MessageFormat) b;\r
1726             Object arguments[] = {new Integer(123456)};\r
1727             \r
1728             return mfa.format(arguments) != mfb.format(arguments);\r
1729         }\r
1730     }\r
1731 \r
1732 //#if defined(FOUNDATION10) || defined(J2SE13)\r
1733 //#else\r
1734     public static class MessageFormatFieldHandler implements SerializableTest.Handler\r
1735     {\r
1736         public Object[] getTestObjects()\r
1737         {\r
1738             return new Object[] {MessageFormat.Field.ARGUMENT};\r
1739         }\r
1740 \r
1741         public boolean hasSameBehavior(Object a, Object b)\r
1742         {\r
1743             return (a == b);\r
1744         }\r
1745     }\r
1746 //#endif\r
1747 \r
1748     public static class DateFormatHandler implements SerializableTest.Handler\r
1749     {\r
1750         static HashMap cannedPatterns = new HashMap();\r
1751         static Date fixedDate;\r
1752         \r
1753         {\r
1754             cannedPatterns.put("en_CA",      "EEEE, MMMM d, yyyy h:mm:ss a z");\r
1755             cannedPatterns.put("fr_CA",      "EEEE d MMMM yyyy HH' h 'mm' min 'ss' s 'z");\r
1756             cannedPatterns.put("zh_Hans_CN", "yyyy'\u5E74'M'\u6708'd'\u65E5'EEEE ahh'\u65F6'mm'\u5206'ss'\u79D2' z");\r
1757             cannedPatterns.put("zh_CN",      "yyyy'\u5E74'M'\u6708'd'\u65E5'EEEE ahh'\u65F6'mm'\u5206'ss'\u79D2' z");\r
1758             cannedPatterns.put("zh",         "EEEE, yyyy MMMM dd HH:mm:ss z");\r
1759             cannedPatterns.put("en",         "EEEE, MMMM d, yyyy h:mm:ss a z");\r
1760             cannedPatterns.put("fr_FR",      "EEEE d MMMM yyyy HH' h 'mm z");\r
1761             cannedPatterns.put("fr",         "EEEE d MMMM yyyy HH' h 'mm z");\r
1762             cannedPatterns.put("de",         "EEEE, d. MMMM yyyy H:mm' Uhr 'z");\r
1763             cannedPatterns.put("de_DE",      "EEEE, d. MMMM yyyy H:mm' Uhr 'z");\r
1764             cannedPatterns.put("it",         "EEEE d MMMM yyyy HH:mm:ss z");\r
1765             cannedPatterns.put("it_IT",      "EEEE d MMMM yyyy HH:mm:ss z");\r
1766             cannedPatterns.put("ja_JP",      "yyyy'\u5E74'M'\u6708'd'\u65E5'EEEE H'\u6642'mm'\u5206'ss'\u79D2'z");\r
1767             cannedPatterns.put("ja",         "yyyy'\u5E74'M'\u6708'd'\u65E5'EEEE H'\u6642'mm'\u5206'ss'\u79D2'z");\r
1768             cannedPatterns.put("ko_KR",      "yyyy'\uB144' M'\uC6D4' d'\uC77C' EEEE a hh'\uC2DC' mm'\uBD84' ss'\uCD08' z");\r
1769             cannedPatterns.put("ko",         "yyyy'\uB144' M'\uC6D4' d'\uC77C' EEEE a hh'\uC2DC' mm'\uBD84' ss'\uCD08' z");\r
1770             cannedPatterns.put("zh_Hant_TW", "yyyy'\u5E74'M'\u6708'd'\u65E5'EEEE ahh'\u6642'mm'\u5206'ss'\u79D2' z");\r
1771             cannedPatterns.put("zh_TW",      "yyyy'\u5E74'M'\u6708'd'\u65E5'EEEE ahh'\u6642'mm'\u5206'ss'\u79D2' z");\r
1772             cannedPatterns.put("en_GB",      "EEEE, d MMMM yyyy HH:mm:ss z");\r
1773             cannedPatterns.put("en_US",      "EEEE, MMMM d, yyyy h:mm:ss a z");\r
1774             \r
1775             // Get a date that will likely not move in or out of Daylight savings time...\r
1776             Calendar cal = Calendar.getInstance(Locale.US);\r
1777             \r
1778             cal.clear();\r
1779             cal.set(2007, Calendar.JANUARY, 1, 12, 0, 0); // January 1, 2007 12:00:00 PM.\r
1780             fixedDate = cal.getTime();\r
1781         }\r
1782         \r
1783         public Object[] getTestObjects()\r
1784         {\r
1785             Locale locales[] = SerializableTest.getLocales();\r
1786             DateFormat formats[] = new DateFormat[locales.length];\r
1787             \r
1788             for (int i = 0; i < locales.length; i += 1) {\r
1789                 ULocale uloc = ULocale.forLocale(locales[i]);\r
1790                 \r
1791               //formats[i] = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, locales[i]);\r
1792                 formats[i] = getCannedSimpleDateFormat((String)cannedPatterns.get(uloc.toString()), uloc);\r
1793             }\r
1794             \r
1795             return formats;\r
1796         }\r
1797         \r
1798         public boolean hasSameBehavior(Object a, Object b)\r
1799         {\r
1800             DateFormat dfa = (DateFormat) a;\r
1801             DateFormat dfb = (DateFormat) b;\r
1802           //Date date = new Date(System.currentTimeMillis());\r
1803             String sfa = dfa.format(fixedDate);\r
1804             String sfb = dfb.format(fixedDate);\r
1805 \r
1806             if (!sfa.equals(sfb)) {\r
1807                 // TODO\r
1808                 // In ICU3.8, localized GMT format pattern was added in\r
1809                 // DateFormatSymbols, which has no public setter.\r
1810                 // The difference of locale data for localized GMT format\r
1811                 // will produce different format result.  This is a temporary\r
1812                 // workaround for the issue.\r
1813                 DateFormatSymbols dfsa = ((SimpleDateFormat)dfa).getDateFormatSymbols();\r
1814                 DateFormatSymbols tmp = (DateFormatSymbols)((SimpleDateFormat)dfb).getDateFormatSymbols().clone();\r
1815 \r
1816                 tmp.setMonths(dfsa.getMonths());\r
1817                 tmp.setShortMonths(dfsa.getShortMonths());\r
1818                 tmp.setWeekdays(dfsa.getWeekdays());\r
1819                 tmp.setShortWeekdays(dfsa.getShortWeekdays());\r
1820                 tmp.setAmPmStrings(dfsa.getAmPmStrings());\r
1821 \r
1822                 ((SimpleDateFormat)dfa).setDateFormatSymbols(tmp);\r
1823 \r
1824                 sfa = dfa.format(fixedDate);\r
1825             }\r
1826 \r
1827             return sfa.equals(sfb);\r
1828         }\r
1829         \r
1830     }\r
1831 \r
1832 //#if defined(FOUNDATION10) || defined(J2SE13)\r
1833 //#else\r
1834     public static class DateFormatFieldHandler implements SerializableTest.Handler\r
1835     {\r
1836         public Object[] getTestObjects() {\r
1837             return new Object[] {\r
1838                     DateFormat.Field.AM_PM,\r
1839                     DateFormat.Field.DAY_OF_MONTH,\r
1840                     DateFormat.Field.DAY_OF_WEEK,\r
1841                     DateFormat.Field.DAY_OF_WEEK_IN_MONTH,\r
1842                     DateFormat.Field.DAY_OF_YEAR,\r
1843                     DateFormat.Field.ERA,\r
1844                     DateFormat.Field.HOUR_OF_DAY0,\r
1845                     DateFormat.Field.HOUR_OF_DAY1,\r
1846                     DateFormat.Field.HOUR0,\r
1847                     DateFormat.Field.HOUR1,\r
1848                     DateFormat.Field.MILLISECOND,\r
1849                     DateFormat.Field.MINUTE,\r
1850                     DateFormat.Field.MONTH,\r
1851                     DateFormat.Field.SECOND,\r
1852                     DateFormat.Field.TIME_ZONE,\r
1853                     DateFormat.Field.WEEK_OF_MONTH,\r
1854                     DateFormat.Field.WEEK_OF_YEAR,\r
1855                     DateFormat.Field.YEAR,\r
1856                     DateFormat.Field.DOW_LOCAL,\r
1857                     DateFormat.Field.EXTENDED_YEAR,\r
1858                     DateFormat.Field.JULIAN_DAY,\r
1859                     DateFormat.Field.MILLISECONDS_IN_DAY,\r
1860                     DateFormat.Field.YEAR_WOY,\r
1861                     DateFormat.Field.QUARTER\r
1862             };\r
1863         }\r
1864         public boolean hasSameBehavior(Object a, Object b)\r
1865         {\r
1866             return (a == b);\r
1867         }\r
1868     }\r
1869 //#endif\r
1870 \r
1871     public static class DateFormatSymbolsHandler implements SerializableTest.Handler\r
1872     {\r
1873         \r
1874         public Object[] getTestObjects()\r
1875         {\r
1876             Locale locales[] = SerializableTest.getLocales();\r
1877             DateFormatSymbols dfs[] = new DateFormatSymbols[locales.length];\r
1878             \r
1879             for (int i = 0; i < locales.length; i += 1) {\r
1880                 ULocale uloc = ULocale.forLocale(locales[i]);\r
1881                 \r
1882                 dfs[i] = getCannedDateFormatSymbols(uloc);\r
1883             }\r
1884             \r
1885             return dfs;\r
1886         }\r
1887         \r
1888         public boolean hasSameBehavior(Object a, Object b)\r
1889         {\r
1890             DateFormatSymbols dfs_a = (DateFormatSymbols) a;\r
1891             DateFormatSymbols dfs_b = (DateFormatSymbols) b;\r
1892             String months_a[] = dfs_a.getMonths();\r
1893             String months_b[] = dfs_b.getMonths();\r
1894             \r
1895             return SerializableTest.compareStrings(months_a, months_b);\r
1896         }\r
1897     }\r
1898     \r
1899     public static class SimpleDateFormatHandler extends DateFormatHandler\r
1900     {\r
1901         String patterns[] = {\r
1902             "EEEE, yyyy MMMM dd",\r
1903             "yyyy MMMM d",\r
1904             "yyyy MMM d",\r
1905             "yy/MM/dd"\r
1906         };\r
1907         \r
1908         public Object[] getTestObjects()\r
1909         {\r
1910             Locale locales[] = SerializableTest.getLocales();\r
1911             SimpleDateFormat dateFormats[] = new SimpleDateFormat[patterns.length * locales.length];\r
1912             int i = 0;\r
1913             \r
1914             for (int p = 0; p < patterns.length; p += 1) {\r
1915                 for (int l = 0; l < locales.length; l += 1) {\r
1916                     dateFormats[i++] = getCannedSimpleDateFormat(patterns[p], ULocale.forLocale(locales[l]));\r
1917                 }\r
1918             }\r
1919             \r
1920             return dateFormats;\r
1921         }\r
1922     }\r
1923 \r
1924     public static class DateIntervalFormatHandler implements SerializableTest.Handler\r
1925     {\r
1926         public Object[] getTestObjects()\r
1927         {\r
1928             DateIntervalFormat dateIntervalFormats[] = {\r
1929                 DateIntervalFormat.getInstance("yMMMMEEEEd")\r
1930             };\r
1931             return dateIntervalFormats;\r
1932         }\r
1933 \r
1934         public boolean hasSameBehavior(Object a, Object b)\r
1935         {\r
1936             DateIntervalFormat dfa = (DateIntervalFormat) a;\r
1937             DateIntervalFormat dfb = (DateIntervalFormat) b;\r
1938             DateInterval dateInterval = new DateInterval(1, System.currentTimeMillis());\r
1939             String sfa = dfa.format(dateInterval);\r
1940             String sfb = dfb.format(dateInterval);\r
1941 \r
1942             return sfa.equals(sfb);\r
1943         }\r
1944     }\r
1945 \r
1946 \r
1947     public static class DateIntervalInfoHandler implements SerializableTest.Handler\r
1948     {\r
1949         public Object[] getTestObjects()\r
1950         {\r
1951             DateIntervalInfo dateIntervalInfo[] = {\r
1952                 new DateIntervalInfo()\r
1953             };\r
1954             dateIntervalInfo[0].setIntervalPattern("yMd", Calendar.YEAR, "yy/MM/dd - yy/MM/dd");\r
1955             dateIntervalInfo[0].setIntervalPattern("yMd", Calendar.MONTH, "yy/MM - MM/dd");\r
1956             return dateIntervalInfo;\r
1957         }\r
1958 \r
1959         public boolean hasSameBehavior(Object a, Object b)\r
1960         {\r
1961             return a.equals(b);\r
1962         }\r
1963     }\r
1964 \r
1965 \r
1966     public static class PatternInfoHandler implements SerializableTest.Handler\r
1967     {\r
1968         public Object[] getTestObjects()\r
1969         {\r
1970             DateIntervalInfo.PatternInfo patternInfo[] = {\r
1971                 new DateIntervalInfo.PatternInfo("yyyy MMM dd - ", \r
1972                                                  "dd",\r
1973                                                  false)\r
1974             };\r
1975             return patternInfo;\r
1976         }\r
1977 \r
1978         public boolean hasSameBehavior(Object a, Object b)\r
1979         {\r
1980             return a.equals(b);\r
1981         }\r
1982     }\r
1983 \r
1984     public static class ChineseDateFormatHandler extends DateFormatHandler\r
1985     {\r
1986         String patterns[] = {\r
1987             "EEEE y'x'G-Ml-d",\r
1988             "y'x'G-Ml-d",\r
1989             "y'x'G-Ml-d",\r
1990             "y'x'G-Ml-d"\r
1991         };\r
1992         \r
1993         public Object[] getTestObjects()\r
1994         {\r
1995             Locale locales[] = SerializableTest.getLocales();\r
1996             ChineseDateFormat dateFormats[] = new ChineseDateFormat[patterns.length * locales.length];\r
1997             int i = 0;\r
1998             \r
1999             for (int p = 0; p < patterns.length; p += 1) {\r
2000                 for (int l = 0; l < locales.length; l += 1) {\r
2001                     ULocale locale = new ULocale(locales[l].toString() + "@calendar=chinese");\r
2002                     \r
2003                     dateFormats[i++] = new ChineseDateFormat(patterns[p], locale);\r
2004                 }\r
2005             }\r
2006             \r
2007             return dateFormats;\r
2008         }\r
2009     }\r
2010 \r
2011 //#if defined(FOUNDATION10) || defined(J2SE13)\r
2012 //#else\r
2013     public static class ChineseDateFormatFieldHandler implements SerializableTest.Handler\r
2014     {\r
2015         public Object[] getTestObjects() {\r
2016             return new Object[] {\r
2017                     ChineseDateFormat.Field.IS_LEAP_MONTH\r
2018             };\r
2019         }\r
2020         public boolean hasSameBehavior(Object a, Object b)\r
2021         {\r
2022             return (a == b);\r
2023         }\r
2024     }\r
2025 //#endif\r
2026 \r
2027     public static class ChineseDateFormatSymbolsHandler extends DateFormatSymbolsHandler\r
2028     {\r
2029         public Object[] getTestObjects()\r
2030         {\r
2031             Locale locales[] = SerializableTest.getLocales();\r
2032             ChineseDateFormatSymbols cdfs[] = new ChineseDateFormatSymbols[locales.length];\r
2033             \r
2034             for (int i = 0; i < locales.length; i += 1) {\r
2035                 ULocale uloc = ULocale.forLocale(locales[i]);\r
2036                 \r
2037                 cdfs[i] = new ChineseDateFormatSymbols(uloc);\r
2038                 cdfs[i].setMonths((String[]) cannedMonthNames.get(uloc.toString()));\r
2039             }\r
2040             \r
2041             return cdfs;\r
2042         }\r
2043         \r
2044         public boolean hasSameBehavior(Object a, Object b)\r
2045         {\r
2046             if (! super.hasSameBehavior(a, b)) {\r
2047                 return false;\r
2048             }\r
2049             \r
2050             ChineseDateFormatSymbols cdfs_a = (ChineseDateFormatSymbols) a;\r
2051             ChineseDateFormatSymbols cdfs_b = (ChineseDateFormatSymbols) b;\r
2052             \r
2053             return cdfs_a.getLeapMonth(0).equals(cdfs_b.getLeapMonth(0)) &&\r
2054                    cdfs_a.getLeapMonth(1).equals(cdfs_b.getLeapMonth(1));\r
2055         }\r
2056     }\r
2057 \r
2058 //#if defined(FOUNDATION10) || defined(J2SE13)\r
2059 //#else\r
2060     public static class NumberFormatFieldHandler implements SerializableTest.Handler\r
2061     {\r
2062         public Object[] getTestObjects()\r
2063         {\r
2064             NumberFormat.Field fields[] = {\r
2065                 NumberFormat.Field.CURRENCY, NumberFormat.Field.DECIMAL_SEPARATOR, NumberFormat.Field.EXPONENT,\r
2066                 NumberFormat.Field.EXPONENT_SIGN, NumberFormat.Field.EXPONENT_SYMBOL, NumberFormat.Field.FRACTION,\r
2067                 NumberFormat.Field.GROUPING_SEPARATOR, NumberFormat.Field.INTEGER, NumberFormat.Field.PERCENT,\r
2068                 NumberFormat.Field.PERMILLE, NumberFormat.Field.SIGN\r
2069             };\r
2070             \r
2071             return fields;\r
2072         }\r
2073         \r
2074         public boolean hasSameBehavior(Object a, Object b)\r
2075         {\r
2076             NumberFormat.Field field_a = (NumberFormat.Field) a;\r
2077             NumberFormat.Field field_b = (NumberFormat.Field) b;\r
2078             \r
2079             return field_a.toString().equals(field_b.toString());\r
2080         }\r
2081     }\r
2082 //#endif\r
2083 \r
2084     public static class DateNumberFormatHandler implements SerializableTest.Handler\r
2085     {\r
2086         public Object[] getTestObjects()\r
2087         {\r
2088             Locale locales[] = SerializableTest.getLocales();\r
2089             DateNumberFormat[] dnfmts = new DateNumberFormat[locales.length];\r
2090             for (int i = 0; i < locales.length; i++) {\r
2091                 ULocale uloc = ULocale.forLocale(locales[i]);\r
2092                 dnfmts[i] = new DateNumberFormat(uloc,'0');\r
2093             }\r
2094             return dnfmts;\r
2095         }\r
2096 \r
2097         public boolean hasSameBehavior(Object a, Object b) {\r
2098             return a.equals(b);\r
2099         }\r
2100     }\r
2101 \r
2102     public static class PluralFormatHandler implements SerializableTest.Handler {\r
2103         public Object[] getTestObjects() {\r
2104             Locale[] locales = { Locale.US }; // main test is in plural rules handler\r
2105             PluralFormat[] plfmts = new PluralFormat[locales.length];\r
2106             for (int i = 0; i < locales.length; i++) {\r
2107                 ULocale uloc = ULocale.forLocale(locales[i]);\r
2108                 try {\r
2109                     plfmts[i] = new PluralFormat(uloc, "one{1 foo} other{# foo}");\r
2110                 } catch (Exception e) {\r
2111                     e.printStackTrace();\r
2112                 }\r
2113             }\r
2114             return plfmts;\r
2115         }\r
2116         public boolean hasSameBehavior(Object a, Object b) {\r
2117             PluralFormat pfa = (PluralFormat)a;\r
2118             PluralFormat pfb = (PluralFormat)b;\r
2119             boolean isSame = true;\r
2120             for (int i = 0; i < 10; i++) {\r
2121                 String texta = pfa.format(i);\r
2122                 String textb = pfb.format(i);\r
2123                 if (!texta.equals(textb)) {\r
2124                     isSame = false;\r
2125                     break;\r
2126                 }\r
2127             }\r
2128             return isSame;\r
2129         }\r
2130     }\r
2131 \r
2132     public static class PluralRulesHandler implements SerializableTest.Handler {\r
2133         public Object[] getTestObjects() {\r
2134             String[] localeNames = {"ja","da","fr","lv","ga","ro","lt","hr","cs","pl","sl"};\r
2135             PluralRules[] plrulz = new PluralRules[localeNames.length];\r
2136             for (int i = 0; i < localeNames.length; i++) {\r
2137                 ULocale uloc = ULocale.createCanonical(localeNames[i]);\r
2138                 try {\r
2139                     plrulz[i] = PluralRules.forLocale(uloc);\r
2140                 } catch (Exception e) {\r
2141                     e.printStackTrace();\r
2142                 }\r
2143             }\r
2144             return plrulz;\r
2145         }\r
2146         public boolean hasSameBehavior(Object a, Object b) {\r
2147             return a.equals(b);\r
2148         }\r
2149     }\r
2150     \r
2151     public static class TimeUnitFormatHandler implements SerializableTest.Handler {\r
2152         // TODO - more test coverage!\r
2153         public Object[] getTestObjects() {\r
2154             return new Object[] { new TimeUnitFormat().setLocale(ULocale.ENGLISH) };\r
2155         }\r
2156         public boolean hasSameBehavior(Object a, Object b) {\r
2157             TimeUnitFormat tufa = (TimeUnitFormat)a;\r
2158             TimeUnitFormat tufb = (TimeUnitFormat)b;\r
2159 \r
2160             TimeUnitAmount amount = new TimeUnitAmount(3, TimeUnit.HOUR);\r
2161             String resa = tufa.format(amount);\r
2162             String resb = tufb.format(amount);\r
2163 \r
2164             return resa.equals(resb);\r
2165         }\r
2166     }\r
2167 \r
2168     public static void main(String[] args)\r
2169     {\r
2170         // nothing needed...\r
2171     }\r
2172 \r
2173 }\r
2174 //eof\r