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