]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-52_1/main/tests/core/src/com/ibm/icu/dev/test/duration/LanguageTestRoot.java
Clean up imports.
[Dictionary.git] / jars / icu4j-52_1 / main / tests / core / src / com / ibm / icu / dev / test / duration / LanguageTestRoot.java
1 /*
2 ******************************************************************************
3 * Copyright (C) 2007-2010, International Business Machines Corporation and   *
4 * others. All Rights Reserved.                                               *
5 ******************************************************************************
6 */
7
8 // Copyright 2006 Google Inc.  All Rights Reserved.
9
10 package com.ibm.icu.dev.test.duration;
11
12 import java.io.BufferedReader;
13 import java.io.InputStream;
14 import java.io.InputStreamReader;
15 import java.io.PrintWriter;
16 import java.util.ArrayList;
17 import java.util.HashMap;
18 import java.util.List;
19 import java.util.Map;
20
21 import com.ibm.icu.dev.test.TestFmwk;
22 import com.ibm.icu.impl.duration.BasicPeriodFormatterService;
23 import com.ibm.icu.impl.duration.Period;
24 import com.ibm.icu.impl.duration.PeriodBuilder;
25 import com.ibm.icu.impl.duration.PeriodBuilderFactory;
26 import com.ibm.icu.impl.duration.PeriodFormatter;
27 import com.ibm.icu.impl.duration.PeriodFormatterFactory;
28 import com.ibm.icu.impl.duration.TimeUnit;
29 import com.ibm.icu.impl.duration.TimeUnitConstants;
30 import com.ibm.icu.impl.duration.impl.DataRecord.ECountVariant;
31 import com.ibm.icu.impl.duration.impl.DataRecord.EUnitVariant;
32
33 /**
34  * Test cases for en
35  */
36 public class LanguageTestRoot extends TestFmwk implements TimeUnitConstants {
37
38     private static final TimeUnit[] units = {
39         TimeUnit.YEAR, TimeUnit.MONTH, TimeUnit.WEEK, TimeUnit.DAY, TimeUnit.HOUR, 
40         TimeUnit.MINUTE, TimeUnit.SECOND, TimeUnit.MILLISECOND
41     };
42
43     protected boolean inheritTargets() {
44         return true;
45     }
46
47     private static final BasicPeriodFormatterService pfs = BasicPeriodFormatterService
48             .getInstance();
49
50     private TestData data;
51     private String locale;
52
53     //private DurationFormatterFactory dfFactory;
54     private PeriodFormatterFactory pfFactory;
55     private PeriodBuilderFactory pbFactory;
56
57     private PrintWriter pw;
58
59     private static final Map datacache = new HashMap(); // String->TestData
60
61     private static final long[] approxDurations = {
62         36525L*24*60*60*10, 3045*24*60*60*10L, 7*24*60*60*1000L, 24*60*60*1000L, 
63         60*60*1000L, 60*1000L, 1000L, 1L
64     };
65
66     private static long approximateDuration(TimeUnit unit) {
67         return approxDurations[unit.ordinal()];
68     }
69
70     private static TestData getTestData(String locale) {
71         // debug
72         if (locale.equals("testFullPluralizedForms")) {
73             Thread.dumpStack();
74         }
75         TestData data = (TestData) datacache.get(locale);
76         if (data == null) {
77             try {
78                 InputStream is = LanguageTestRoot.class
79                         .getResourceAsStream("testdata/testdata_" + locale
80                                 + ".txt");
81                 // debug
82                 if (is == null) {
83                     System.out.println("test data for locale '" + locale
84                             + "' is null");
85                 }
86                 InputStreamReader isr = new InputStreamReader(is, "UTF-8");
87                 data = new FileTestData(isr);
88             } catch (Exception e) {
89                 System.err.println(e.getMessage());
90                 // swallow any exception
91             }
92         }
93         return data;
94     }
95
96     public LanguageTestRoot(String locale, boolean ignore) {
97         this(getTestData(locale), locale);
98     }
99
100     public LanguageTestRoot(TestData data, String locale) {
101         if (data == null) {
102             data = DefaultData.getInstance();
103         }
104         this.data = data;
105         this.locale = locale;
106     }
107
108     public static void writeData(PrintWriter pw, String locale)
109             throws Exception {
110         LanguageTestRoot test = new LanguageTestRoot(DefaultData.getInstance(),
111                 locale);
112         test.writeData(pw);
113     }
114
115     private void writeData(PrintWriter writer) throws Exception {
116 /*
117       pw = writer;
118       setUp();
119       testFullPluralizedForms();
120       tearDown();
121       setUp();
122       testMediumForms();
123       tearDown();
124       setUp();
125       testShortForms();
126       tearDown();
127       setUp();
128       testCustomMinutes();
129       tearDown();
130       setUp();
131       testLimitedUnits();
132       tearDown();
133       setUp();
134       testHalfUnits();
135       tearDown();
136       setUp();
137       testFractionalUnits();
138       tearDown();
139       setUp();
140       testMultipleUnits();
141       tearDown();
142       pw = null;
143       writer.flush();
144 */
145     }
146
147     protected void xAssertEquals(String msg, String[] expected, int n,
148             String actual) {
149         if (pw != null) {
150             pw.println(actual);
151         } else {
152             // java doesn't dump enough context to be useful, so do it myself
153             if (actual == null) {
154                 assertEquals(msg, expected[n], actual);
155             } else {
156                 if (!actual.equals(expected[n])) {
157                     fail("\n(!!"
158                             + msg
159                             + ") "
160                             + asciify("expected '" + expected[n]
161                                     + "' but got '" + actual + "'"));
162                 }
163             }
164         }
165     }
166
167     protected static String timestring(Period ts) {
168         StringBuffer buf = new StringBuffer();
169         if (ts.isMoreThan()) {
170             buf.append("mt");
171         } else if (ts.isLessThan()) {
172             buf.append("lt");
173         }
174         for (int i = 0; i < units.length; ++i) {
175             TimeUnit p = units[i];
176             if (ts.isSet(p)) {
177                 buf.append(Float.toString(ts.getCount(p)));
178                 buf.append(p.toString().charAt(0));
179             }
180         }
181         buf.append(ts.isInPast() ? "p" : "f");
182         return buf.toString();
183     }
184
185     protected static String asciify(String s) {
186         StringBuffer sb = null;
187         for (int i = 0, e = s.length(); i < e; ++i) {
188             char c = s.charAt(i);
189             if (c < 0x20 || c > 0x7e) {
190                 if (sb == null) {
191                     sb = new StringBuffer();
192                     sb.append(s.substring(0, i));
193                 }
194                 sb.append("\\u");
195                 if (c < 0x10) {
196                     sb.append("000");
197                 } else if (c < 0x100) {
198                     sb.append("00");
199                 } else if (c < 0x1000) {
200                     sb.append("0");
201                 }
202                 sb.append(Integer.toHexString(c));
203             } else {
204                 if (sb != null) {
205                     sb.append(c);
206                 }
207             }
208         }
209         if (sb != null) {
210             System.out.println("asciify '" + s + "' --> '" + sb.toString()
211                     + "'");
212         }
213         return sb == null ? s : sb.toString();
214     }
215
216     private void xAssertEquals(String[] expected, int n, String actual) {
217         xAssertEquals(null, expected, n, actual);
218     }
219
220     protected void setUp() throws Exception {
221         pfFactory = pfs.newPeriodFormatterFactory().setLocale(locale);
222         pbFactory = pfs.newPeriodBuilderFactory().setLocale(locale);
223     }
224
225     public void testFullPluralizedForms() throws Exception {
226         setUp();
227         int[] counts = data.getFullPluralizedFormCounts();
228         String[] targets = data.getFullPluralizedFormTargets();
229         if (pw != null) {
230             pw.println("=fullPluralizedFormCounts");
231             for (int i = 0; i < counts.length; ++i) {
232                 int c = counts[i];
233                 pw.println(String.valueOf(c));
234             }
235             pw.println("=fullPluralizedFormTargets");
236         }
237
238         int n = 0;
239         PeriodFormatter pf = pfFactory.getFormatter();
240         for (int i = 0; i < units.length; ++i) {
241             TimeUnit u = units[i];
242             // System.err.print("\nunit: " + u);
243             PeriodBuilder pb = pbFactory.getFixedUnitBuilder(u);
244             for (int j = 0; j < counts.length; ++j) {
245                 int c = counts[j];
246                 // System.err.println("\ncount[" + j + "]: " + c);
247                 Period p = pb.create(approximateDuration(u) * c);
248                 String string = pf.format(p);
249                 xAssertEquals(u.toString() + c, targets, n++, string);
250             }
251         }
252     }
253
254     public void testMediumForms() throws Exception {
255         setUp();
256         String[] targets = data.getMediumFormTargets();
257
258         if (pw != null) {
259             pw.println("=mediumFormTargets");
260         }
261
262         pfFactory.setUnitVariant(EUnitVariant.MEDIUM);
263         pfFactory.setDisplayPastFuture(false);
264         PeriodFormatter pf = pfFactory.getFormatter();
265         int n = 0;
266         for (int i = 0; i < units.length; ++i) {
267             TimeUnit u = units[i];
268             PeriodBuilder pb = pbFactory.getFixedUnitBuilder(u);
269             Period p = pb.create(approximateDuration(u) * 3);
270             String string = pf.format(p);
271             xAssertEquals(u.toString(), targets, n++, string);
272         }
273     }
274
275     public void testShortForms() throws Exception {
276         setUp();
277         String[] targets = data.getShortFormTargets();
278
279         if (pw != null) {
280             pw.println("=shortFormTargets");
281         }
282
283         pfFactory.setUnitVariant(EUnitVariant.SHORT);
284         pfFactory.setDisplayPastFuture(false);
285         PeriodFormatter pf = pfFactory.getFormatter();
286         int n = 0;
287         for (int i = 0; i < units.length; ++i) {
288             TimeUnit u = units[i];
289             PeriodBuilder pb = pbFactory.getFixedUnitBuilder(u);
290             Period p = pb.create(approximateDuration(u) * 3);
291             String string = pf.format(p);
292             xAssertEquals(u.toString(), targets, n++, string);
293         }
294     }
295
296     public void testCustomMinutes() throws Exception {
297         setUp();
298         String[] targets = data.getCustomMinuteTargets();
299
300         if (pw != null) {
301             pw.println("=customMinuteTargets");
302         }
303
304         pfFactory.setCountVariant(ECountVariant.INTEGER_CUSTOM);
305         pfFactory.setDisplayPastFuture(false);
306         PeriodFormatter pf = pfFactory.getFormatter();
307
308         Period p = Period.at(1, HOUR);
309         int n = 0;
310         for (int i = 1; i < 12; ++i) {
311             p = p.and(i * 5, MINUTE).omit(HOUR);
312             xAssertEquals(targets, n++, pf.format(p));
313             p = p.and(1, HOUR);
314             xAssertEquals(targets, n++, pf.format(p));
315         }
316     }
317
318     public void testLimitedUnits() throws Exception {
319         setUp();
320         String[] targets = data.getLimitedUnitTargets();
321
322         if (pw != null) {
323             pw.println("=limitedPeriodTargets");
324         }
325
326         Period p = Period.at(1, MONTH);
327         int n = 0;
328         for (int i = 0; i < 3; ++i) {
329             switch (i) {
330             case 0:
331                 p = p.at();
332                 break;
333             case 1:
334                 p = p.lessThan();
335                 break;
336             case 2:
337                 p = p.moreThan();
338                 break;
339             }
340             for (int j = 0; j < 3; ++j) {
341                 pfFactory.setDisplayPastFuture(true);
342                 switch (j) {
343                 case 0:
344                     pfFactory.setDisplayPastFuture(false);
345                     break;
346                 case 1:
347                     p = p.inPast();
348                     break;
349                 case 2:
350                     p = p.inFuture();
351                     break;
352                 }
353
354                 PeriodFormatter pf = pfFactory.getFormatter();
355
356                 p = p.omit(WEEK).omit(DAY);
357                 xAssertEquals(targets, n++, pf.format(p));
358
359                 p = p.and(2, WEEK);
360                 xAssertEquals(targets, n++, pf.format(p));
361
362                 p = p.and(3, DAY);
363                 xAssertEquals(targets, n++, pf.format(p));
364             }
365         }
366
367         p = p.omit(MONTH).omit(WEEK).omit(DAY).and(1, HOUR);
368         for (int i = 0; i < 3; ++i) {
369             switch (i) {
370             case 0:
371                 p = p.at();
372                 break;
373             case 1:
374                 p = p.lessThan();
375                 break;
376             case 2:
377                 p = p.moreThan();
378                 break;
379             }
380             for (int j = 0; j < 3; ++j) {
381                 pfFactory.setDisplayPastFuture(true);
382                 switch (j) {
383                 case 0:
384                     pfFactory.setDisplayPastFuture(false);
385                     break;
386                 case 1:
387                     p = p.inPast();
388                     break;
389                 case 2:
390                     p = p.inFuture();
391                     break;
392                 }
393
394                 PeriodFormatter pf = pfFactory.getFormatter();
395
396                 p = p.omit(MINUTE).omit(SECOND);
397                 xAssertEquals(targets, n++, pf.format(p));
398
399                 p = p.and(2, MINUTE);
400                 xAssertEquals(targets, n++, pf.format(p));
401
402                 p = p.and(3, SECOND);
403                 xAssertEquals(targets, n++, pf.format(p));
404             }
405         }
406     }
407
408     public void testHalfUnits() throws Exception {
409         setUp();
410         int[] counts = data.getHalfUnitCounts();
411         String[] targets = data.getHalfUnitTargets();
412
413         if (pw != null) {
414             pw.println("=halfPeriodCounts");
415             for (int i = 0; i < counts.length; ++i) {
416                 int c = counts[i];
417                 pw.println(String.valueOf(c));
418             }
419             pw.println("=halfPeriodTargets");
420         }
421
422         pfFactory.setCountVariant(ECountVariant.HALF_FRACTION);
423         pfFactory.setDisplayPastFuture(false);
424         PeriodFormatter pf = pfFactory.getFormatter();
425
426         int n = 0;
427         for (int i = 0; i < units.length; ++i) {
428             TimeUnit u = units[i];
429             for (int j = 0; j < counts.length; ++j) {
430                 int c = counts[j];
431                 Period p = Period.at(c + .5f, u);
432                 String string = pf.format(p);
433                 xAssertEquals(u.toString(), targets, n++, string);
434             }
435         }
436     }
437
438     public void testFractionalUnits() throws Exception {
439         setUp();
440         float[] counts = data.getFractionalUnitCounts();
441         String[] targets = data.getFractionalUnitTargets();
442
443         if (pw != null) {
444             pw.println("=fractionalPeriodCounts");
445             for (int i = 0; i < counts.length; ++i) {
446                 float c = counts[i];
447                 pw.println(String.valueOf(c));
448             }
449             pw.println("=fractionalPeriodTargets");
450         }
451
452         pfFactory.setCountVariant(ECountVariant.DECIMAL2);
453         pfFactory.setDisplayPastFuture(false);
454         PeriodFormatter pf = pfFactory.getFormatter();
455
456         int n = 0;
457         for (int i = 0; i < units.length; ++i) {
458             TimeUnit u = units[i];
459             for (int j = 0; j < counts.length; ++j) {
460                 float c = counts[j];
461                 Period p = Period.at(c, u);
462                 String string = pf.format(p);
463                 xAssertEquals(u.toString(), targets, n++, string);
464             }
465         }
466     }
467
468     public void testMultipleUnits() throws Exception {
469         setUp();
470         String[] targets = data.getMultipleUnitTargets();
471
472         if (pw != null) {
473             pw.println("=multiplePeriodTargets");
474         }
475
476         pfFactory.setCountVariant(ECountVariant.INTEGER);
477         pfFactory.setDisplayPastFuture(false);
478         PeriodFormatter pf = pfFactory.getFormatter();
479
480         int n = 0;
481         for (int i = 0; i < units.length - 1; ++i) {
482             Period p = Period.at(1, units[i]).and(2, units[i + 1]);
483             xAssertEquals(targets, n++, pf.format(p));
484             if (i < units.length - 2) {
485                 p = Period.at(1, units[i]).and(3, units[i + 2]);
486                 xAssertEquals(targets, n++, pf.format(p));
487                 p = Period.at(1, units[i]).and(2, units[i + 1]).and(3,
488                         units[i + 2]);
489                 xAssertEquals(targets, n++, pf.format(p));
490             }
491         }
492     }
493
494     public static abstract class TestData {
495         abstract int[] getFullPluralizedFormCounts();
496         abstract String[] getFullPluralizedFormTargets();
497         abstract String[] getMediumFormTargets();
498         abstract String[] getShortFormTargets();
499         abstract String[] getCustomMinuteTargets();
500         abstract String[] getLimitedUnitTargets();
501         abstract int[] getHalfUnitCounts();
502         abstract String[] getHalfUnitTargets();
503         abstract float[] getFractionalUnitCounts();
504         abstract String[] getFractionalUnitTargets();
505         abstract String[] getMultipleUnitTargets();
506     }
507
508 }
509
510 class FileTestData extends LanguageTestRoot.TestData {
511     private int[] fullPluralizedFormCounts;
512     private String[] fullPluralizedFormTargets;
513     private String[] mediumFormTargets;
514     private String[] shortFormTargets;
515     private String[] customMinuteTargets;
516     private String[] limitedUnitTargets;
517     private int[] halfUnitCounts;
518     private String[] halfUnitTargets;
519     private float[] fractionalUnitCounts;
520     private String[] fractionalUnitTargets;
521     private String[] multipleUnitTargets;
522
523     int[] getFullPluralizedFormCounts() {
524         return fullPluralizedFormCounts;
525     }
526
527     String[] getFullPluralizedFormTargets() {
528         return fullPluralizedFormTargets;
529     }
530
531     String[] getMediumFormTargets() {
532         return mediumFormTargets;
533     }
534
535     String[] getShortFormTargets() {
536         return shortFormTargets;
537     }
538
539     String[] getCustomMinuteTargets() {
540         return customMinuteTargets;
541     }
542
543     String[] getLimitedUnitTargets() {
544         return limitedUnitTargets;
545     }
546
547     int[] getHalfUnitCounts() {
548         return halfUnitCounts;
549     }
550
551     String[] getHalfUnitTargets() {
552         return halfUnitTargets;
553     }
554
555     float[] getFractionalUnitCounts() {
556         return fractionalUnitCounts;
557     }
558
559     String[] getFractionalUnitTargets() {
560         return fractionalUnitTargets;
561     }
562
563     String[] getMultipleUnitTargets() {
564         return multipleUnitTargets;
565     }
566
567     public FileTestData(InputStreamReader isr) throws Exception {
568         BufferedReader br = new BufferedReader(isr);
569
570         class Wrapup {
571             int[] intArray;
572
573             float[] floatArray;
574
575             String[] stringArray;
576
577             void wrapup(List /* of String */list, Element element) {
578                 if (list == null)
579                     return;
580
581                 switch (element.mode) {
582                 case EMode.mString:
583                     stringArray = (String[]) list.toArray(new String[list
584                             .size()]);
585                     break;
586
587                 case EMode.mInt:
588                     intArray = new int[list.size()];
589                     for (int i = 0, e = intArray.length; i < e; ++i) {
590                         intArray[i] = Integer.parseInt((String) list.get(i));
591                     }
592                     break;
593
594                 case EMode.mFloat:
595                     floatArray = new float[list.size()];
596                     for (int i = 0, e = floatArray.length; i < e; ++i) {
597                         floatArray[i] = Float.parseFloat((String) list.get(i));
598                     }
599                     break;
600                 }
601
602                 switch (element.which) {
603                 case Element.XfullPluralizedFormCounts:
604                     FileTestData.this.fullPluralizedFormCounts = intArray;
605                     break;
606                 case Element.XfullPluralizedFormTargets:
607                     FileTestData.this.fullPluralizedFormTargets = stringArray;
608                     break;
609                 case Element.XmediumFormTargets:
610                     FileTestData.this.mediumFormTargets = stringArray;
611                     break;
612                 case Element.XshortFormTargets:
613                     FileTestData.this.shortFormTargets = stringArray;
614                     break;
615                 case Element.XcustomMinuteTargets:
616                     FileTestData.this.customMinuteTargets = stringArray;
617                     break;
618                 case Element.XlimitedUnitTargets:
619                     FileTestData.this.limitedUnitTargets = stringArray;
620                     break;
621                 case Element.XhalfUnitCounts:
622                     FileTestData.this.halfUnitCounts = intArray;
623                     break;
624                 case Element.XhalfUnitTargets:
625                     FileTestData.this.halfUnitTargets = stringArray;
626                     break;
627                 case Element.XfractionalUnitCounts:
628                     FileTestData.this.fractionalUnitCounts = floatArray;
629                     break;
630                 case Element.XfractionalUnitTargets:
631                     FileTestData.this.fractionalUnitTargets = stringArray;
632                     break;
633                 case Element.XmultipleUnitTargets:
634                     FileTestData.this.multipleUnitTargets = stringArray;
635                     break;
636                 }
637             }
638         }
639         Wrapup w = new Wrapup();
640
641         List /* of String */list = null;
642         Element element = null;
643         String line = null;
644         while (null != (line = br.readLine())) {
645             line = line.trim();
646             if (line.length() == 0 || line.charAt(0) == '#')
647                 continue;
648             if (line.charAt(0) == '=') {
649                 w.wrapup(list, element);
650
651                 list = new ArrayList();
652                 element = Element.forString(line.substring(1));
653             } else if (line.equals("null")) {
654                 list.add(null);
655             } else {
656                 list.add(line);
657             }
658         }
659         w.wrapup(list, element);
660     }
661 }
662
663 class DefaultData extends LanguageTestRoot.TestData {
664     private static final int[] fullPluralizedFormCounts = { -3, -2, -1, 0, 1,
665             2, 3, 5, 10, 11, 12, 20, 21, 22, 23, 25 };
666
667     private static final int[] halfUnitCounts = { 0, 1, 2, 5, 10, 11, 12, 20,
668             21, 22 };
669
670     private static final float[] fractionalUnitCounts = { 0.025f, 1.0f, 1.205f,
671             2.125f, 12.05f };
672
673     private static final DefaultData instance = new DefaultData();
674
675     private DefaultData() {
676     }
677
678     public static DefaultData getInstance() {
679         return instance;
680     }
681
682     int[] getFullPluralizedFormCounts() {
683         return fullPluralizedFormCounts;
684     }
685
686     String[] getFullPluralizedFormTargets() {
687         return null;
688     }
689
690     String[] getMediumFormTargets() {
691         return null;
692     }
693
694     String[] getShortFormTargets() {
695         return null;
696     }
697
698     String[] getCustomMinuteTargets() {
699         return null;
700     }
701
702     String[] getLimitedUnitTargets() {
703         return null;
704     }
705
706     int[] getHalfUnitCounts() {
707         return halfUnitCounts;
708     }
709
710     String[] getHalfUnitTargets() {
711         return null;
712     }
713
714     float[] getFractionalUnitCounts() {
715         return fractionalUnitCounts;
716     }
717
718     String[] getFractionalUnitTargets() {
719         return null;
720     }
721
722     String[] getMultipleUnitTargets() {
723         return null;
724     }
725 }
726
727 class EMode {
728     static final int mString = 0;
729     static final int mInt = 1;
730     static final int mFloat = 2;
731 }
732
733 class Element {
734     final String name;
735     final int mode;
736     final int which;
737
738     static int counter = 0;
739     static Element[] list = new Element[11];
740
741     Element(String name) {
742         this.name = name;
743         mode = EMode.mString;
744         this.which = counter++;
745         list[this.which] = this;
746     }
747
748     Element(String name, int mode) {
749         this.name = name;
750         this.mode = mode;
751         this.which = counter++;
752         list[this.which] = this;
753     }
754
755     static final int XfullPluralizedFormCounts = 0;
756     static final int XfullPluralizedFormTargets = 1;
757     static final int XmediumFormTargets = 2;
758     static final int XshortFormTargets = 3;
759     static final int XcustomMinuteTargets = 4;
760     static final int XlimitedUnitTargets = 5;
761     static final int XhalfUnitCounts = 6;
762     static final int XhalfUnitTargets = 7;
763     static final int XfractionalUnitCounts = 8;
764     static final int XfractionalUnitTargets = 9;
765     static final int XmultipleUnitTargets = 10;
766
767     static final Element fullPluralizedFormCounts = new Element(
768             "fullPluralizedFormCounts", EMode.mInt);
769
770     static final Element fullPluralizedFormTargets = new Element(
771             "fullPluralizedFormTargets");
772
773     static final Element mediumFormTargets = new Element("mediumFormTargets");
774
775     static final Element shortFormTargets = new Element("shortFormTargets");
776
777     static final Element customMinuteTargets = new Element(
778             "customMinuteTargets");
779
780     static final Element limitedUnitTargets = new Element("limitedUnitTargets");
781
782     static final Element halfUnitCounts = new Element("halfUnitCounts",
783             EMode.mInt);
784
785     static final Element halfUnitTargets = new Element("halfUnitTargets");
786
787     static final Element fractionalUnitCounts = new Element(
788             "fractionalUnitCounts", EMode.mFloat);
789
790     static final Element fractionalUnitTargets = new Element(
791             "fractionalUnitTargets");
792
793     static final Element multipleUnitTargets = new Element(
794             "multipleUnitTargets");
795
796     static Element forString(String s) {
797         for (int i = 0; i < list.length; ++i) {
798             if (list[i].name.equals(s)) {
799                 return list[i];
800             }
801         }
802         return null;
803     }
804 }
805