• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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-2009, International Business Machines Corporation and   *
7  * others. All Rights Reserved.                                               *
8  ******************************************************************************
9  */
10 
11 package ohos.global.icu.impl.duration.impl;
12 
13 import java.util.ArrayList;
14 import java.util.List;
15 
16 /**
17  * DataRecord contains the data used by PeriodFormatterData. Fields are
18  * package-private for ease of access. This is a struct, it knows how to read
19  * and write itself to/from simple XML, that's all.
20  * @hide exposed on OHOS
21  */
22 public class DataRecord {
23     byte pl;
24     String[][] pluralNames;
25     byte[] genders; // EGender
26     String[] singularNames;
27     String[] halfNames;
28     String[] numberNames;
29     String[] mediumNames;
30     String[] shortNames;
31     String[] measures;
32     String[] rqdSuffixes;
33     String[] optSuffixes;
34     String[] halves;
35     byte[] halfPlacements; // EHalfPlacement
36     byte[] halfSupport; // EHalfSupport
37     String fifteenMinutes;
38     String fiveMinutes;
39     boolean requiresDigitSeparator;
40     String digitPrefix;
41     String countSep;
42     String shortUnitSep;
43     String[] unitSep;
44     boolean[] unitSepRequiresDP;
45     boolean[] requiresSkipMarker;
46     byte numberSystem; // ENumberSystem
47     char zero;
48     char decimalSep;
49     boolean omitSingularCount;
50     boolean omitDualCount;
51     byte zeroHandling; // EZeroHandling
52     byte decimalHandling; // EDecimalHandling
53     byte fractionHandling; // EFractionHandling
54     String skippedUnitMarker;
55     boolean allowZero;
56     boolean weeksAloneOnly;
57     byte useMilliseconds; // EMilliSupport
58     ScopeData[] scopeData;
59 
read(String ln, RecordReader in)60     public static DataRecord read(String ln, RecordReader in) {
61         if (in.open("DataRecord")) {
62             DataRecord record = new DataRecord();
63             record.pl = in.namedIndex("pl", EPluralization.names);
64             record.pluralNames = in.stringTable("pluralName");
65             record.genders = in.namedIndexArray("gender", EGender.names);
66             record.singularNames = in.stringArray("singularName");
67             record.halfNames = in.stringArray("halfName");
68             record.numberNames = in.stringArray("numberName");
69             record.mediumNames = in.stringArray("mediumName");
70             record.shortNames = in.stringArray("shortName");
71             record.measures = in.stringArray("measure");
72             record.rqdSuffixes = in.stringArray("rqdSuffix");
73             record.optSuffixes = in.stringArray("optSuffix");
74             record.halves = in.stringArray("halves");
75             record.halfPlacements = in.namedIndexArray("halfPlacement",
76                     EHalfPlacement.names);
77             record.halfSupport = in.namedIndexArray("halfSupport",
78                     EHalfSupport.names);
79             record.fifteenMinutes = in.string("fifteenMinutes");
80             record.fiveMinutes = in.string("fiveMinutes");
81             record.requiresDigitSeparator = in.bool("requiresDigitSeparator");
82             record.digitPrefix = in.string("digitPrefix");
83             record.countSep = in.string("countSep");
84             record.shortUnitSep = in.string("shortUnitSep");
85             record.unitSep = in.stringArray("unitSep");
86             record.unitSepRequiresDP = in.boolArray("unitSepRequiresDP");
87             record.requiresSkipMarker = in.boolArray("requiresSkipMarker");
88             record.numberSystem = in.namedIndex("numberSystem",
89                     ENumberSystem.names);
90             record.zero = in.character("zero");
91             record.decimalSep = in.character("decimalSep");
92             record.omitSingularCount = in.bool("omitSingularCount");
93             record.omitDualCount = in.bool("omitDualCount");
94             record.zeroHandling = in.namedIndex("zeroHandling",
95                     EZeroHandling.names);
96             record.decimalHandling = in.namedIndex("decimalHandling",
97                     EDecimalHandling.names);
98             record.fractionHandling = in.namedIndex("fractionHandling",
99                     EFractionHandling.names);
100             record.skippedUnitMarker = in.string("skippedUnitMarker");
101             record.allowZero = in.bool("allowZero");
102             record.weeksAloneOnly = in.bool("weeksAloneOnly");
103             record.useMilliseconds = in.namedIndex("useMilliseconds",
104                     EMilliSupport.names);
105             if (in.open("ScopeDataList")) {
106                 List<ScopeData> list = new ArrayList<ScopeData>(); // of ScopeData
107                 ScopeData data;
108                 while (null != (data = ScopeData.read(in))) {
109                     list.add(data);
110                 }
111                 if (in.close()) {
112                     record.scopeData = list.toArray(new ScopeData[list.size()]);
113                 }
114             }
115 
116             if (in.close()) {
117                 return record;
118             }
119         } else {
120             throw new InternalError("did not find DataRecord while reading "
121                     + ln);
122         }
123         throw new InternalError("null data read while reading " + ln);
124         // Thread.dumpStack();
125         // return null;
126     }
127 
write(RecordWriter out)128     public void write(RecordWriter out) {
129         out.open("DataRecord");
130         out.namedIndex("pl", EPluralization.names, pl);
131         out.stringTable("pluralName", pluralNames);
132         out.namedIndexArray("gender", EGender.names, genders);
133         out.stringArray("singularName", singularNames);
134         out.stringArray("halfName", halfNames);
135         out.stringArray("numberName", numberNames);
136         out.stringArray("mediumName", mediumNames);
137         out.stringArray("shortName", shortNames);
138         out.stringArray("measure", measures);
139         out.stringArray("rqdSuffix", rqdSuffixes);
140         out.stringArray("optSuffix", optSuffixes);
141         out.stringArray("halves", halves);
142         out.namedIndexArray("halfPlacement", EHalfPlacement.names,
143                 halfPlacements);
144         out.namedIndexArray("halfSupport", EHalfSupport.names, halfSupport);
145         out.string("fifteenMinutes", fifteenMinutes);
146         out.string("fiveMinutes", fiveMinutes);
147         out.bool("requiresDigitSeparator", requiresDigitSeparator);
148         out.string("digitPrefix", digitPrefix);
149         out.string("countSep", countSep);
150         out.string("shortUnitSep", shortUnitSep);
151         out.stringArray("unitSep", unitSep);
152         out.boolArray("unitSepRequiresDP", unitSepRequiresDP);
153         out.boolArray("requiresSkipMarker", requiresSkipMarker);
154         out.namedIndex("numberSystem", ENumberSystem.names, numberSystem);
155         out.character("zero", zero);
156         out.character("decimalSep", decimalSep);
157         out.bool("omitSingularCount", omitSingularCount);
158         out.bool("omitDualCount", omitDualCount);
159         out.namedIndex("zeroHandling", EZeroHandling.names, zeroHandling);
160         out.namedIndex("decimalHandling", EDecimalHandling.names,
161                 decimalHandling);
162         out.namedIndex("fractionHandling", EFractionHandling.names,
163                 fractionHandling);
164         out.string("skippedUnitMarker", skippedUnitMarker);
165         out.bool("allowZero", allowZero);
166         out.bool("weeksAloneOnly", weeksAloneOnly);
167         out.namedIndex("useMilliseconds", EMilliSupport.names, useMilliseconds);
168         if (scopeData != null) {
169             out.open("ScopeDataList");
170             for (int i = 0; i < scopeData.length; ++i) {
171                 scopeData[i].write(out);
172             }
173             out.close();
174         }
175         out.close();
176     }
177 
178     /**
179      * @hide exposed on OHOS
180      */
181     public static class ScopeData {
182         String prefix;
183         boolean requiresDigitPrefix;
184         String suffix;
185 
write(RecordWriter out)186         public void write(RecordWriter out) {
187             out.open("ScopeData");
188             out.string("prefix", prefix);
189             out.bool("requiresDigitPrefix", requiresDigitPrefix);
190             out.string("suffix", suffix);
191             out.close();
192         }
193 
read(RecordReader in)194         public static ScopeData read(RecordReader in) {
195             if (in.open("ScopeData")) {
196                 ScopeData scope = new ScopeData();
197                 scope.prefix = in.string("prefix");
198                 scope.requiresDigitPrefix = in.bool("requiresDigitPrefix");
199                 scope.suffix = in.string("suffix");
200                 if (in.close()) {
201                     return scope;
202                 }
203             }
204             return null;
205         }
206     }
207 
208     /**
209      * @hide exposed on OHOS
210      */
211     public static interface ETimeLimit {
212         public static final byte NOLIMIT = 0;
213         public static final byte LT = 1;
214         public static final byte MT = 2;
215         public static final String[] names = { "NOLIMIT", "LT", "MT" };
216     }
217 
218     /**
219      * @hide exposed on OHOS
220      */
221     public static interface ETimeDirection {
222         public static final byte NODIRECTION = 0;
223         public static final byte PAST = 1;
224         public static final byte FUTURE = 2;
225         public static final String[] names = { "NODIRECTION", "PAST", "FUTURE" };
226     }
227 
228     /**
229      * @hide exposed on OHOS
230      */
231     public static interface EUnitVariant {
232         public static final byte PLURALIZED = 0;
233         public static final byte MEDIUM = 1;
234         public static final byte SHORT = 2;
235         public static final String[] names = { "PLURALIZED", "MEDIUM", "SHORT" };
236     }
237 
238     /**
239      * @hide exposed on OHOS
240      */
241     public static interface ECountVariant {
242         public static final byte INTEGER = 0;
243         public static final byte INTEGER_CUSTOM = 1;
244         public static final byte HALF_FRACTION = 2;
245         public static final byte DECIMAL1 = 3;
246         public static final byte DECIMAL2 = 4;
247         public static final byte DECIMAL3 = 5;
248         public static final String[] names = { "INTEGER", "INTEGER_CUSTOM",
249             "HALF_FRACTION", "DECIMAL1", "DECIMAL2", "DECIMAL3" };
250     }
251 
252     /**
253      * @hide exposed on OHOS
254      */
255     public static interface EPluralization {
256         public static final byte NONE = 0;
257         public static final byte PLURAL = 1;
258         public static final byte DUAL = 2;
259         public static final byte PAUCAL = 3;
260         public static final byte HEBREW = 4;
261         public static final byte ARABIC = 5;
262         public static final String[] names = { "NONE", "PLURAL", "DUAL",
263             "PAUCAL", "HEBREW", "ARABIC" };
264     }
265 
266     /**
267      * @hide exposed on OHOS
268      */
269     public static interface EHalfPlacement {
270         public static final byte PREFIX = 0;
271         public static final byte AFTER_FIRST = 1;
272         public static final byte LAST = 2;
273         public static final String[] names = { "PREFIX", "AFTER_FIRST", "LAST" };
274     }
275 
276     /**
277      * @hide exposed on OHOS
278      */
279     public static interface ENumberSystem {
280         public static final byte DEFAULT = 0;
281         public static final byte CHINESE_TRADITIONAL = 1;
282         public static final byte CHINESE_SIMPLIFIED = 2;
283         public static final byte KOREAN = 3;
284         public static final String[] names = { "DEFAULT",
285             "CHINESE_TRADITIONAL", "CHINESE_SIMPLIFIED", "KOREAN" };
286     }
287 
288     /**
289      * @hide exposed on OHOS
290      */
291     public static interface EZeroHandling {
292         public static final byte ZPLURAL = 0;
293         public static final byte ZSINGULAR = 1;
294         public static final String[] names = { "ZPLURAL", "ZSINGULAR" };
295     }
296 
297     /**
298      * @hide exposed on OHOS
299      */
300     public static interface EDecimalHandling {
301         public static final byte DPLURAL = 0;
302         public static final byte DSINGULAR = 1;
303         public static final byte DSINGULAR_SUBONE = 2;
304         public static final byte DPAUCAL = 3;
305         public static final String[] names = { "DPLURAL", "DSINGULAR",
306             "DSINGULAR_SUBONE", "DPAUCAL" };
307     }
308 
309     /**
310      * @hide exposed on OHOS
311      */
312     public static interface EFractionHandling {
313         public static final byte FPLURAL = 0;
314         public static final byte FSINGULAR_PLURAL = 1;
315         public static final byte FSINGULAR_PLURAL_ANDAHALF = 2;
316         public static final byte FPAUCAL = 3;
317         public static final String[] names = { "FPLURAL", "FSINGULAR_PLURAL",
318             "FSINGULAR_PLURAL_ANDAHALF", "FPAUCAL" };
319     }
320 
321     /**
322      * @hide exposed on OHOS
323      */
324     public static interface EHalfSupport {
325         public static final byte YES = 0;
326         public static final byte NO = 1;
327         public static final byte ONE_PLUS = 2;
328         public static final String[] names = { "YES", "NO", "ONE_PLUS" };
329     }
330 
331     /**
332      * @hide exposed on OHOS
333      */
334     public static interface EMilliSupport {
335         public static final byte YES = 0;
336         public static final byte NO = 1;
337         public static final byte WITH_SECONDS = 2;
338         public static final String[] names = { "YES", "NO", "WITH_SECONDS" };
339     }
340 
341     /**
342      * @hide exposed on OHOS
343      */
344     public static interface ESeparatorVariant {
345         public static final byte NONE = 0;
346         public static final byte SHORT = 1;
347         public static final byte FULL = 2;
348         public static final String[] names = { "NONE", "SHORT", "FULL" };
349     }
350 
351     /**
352      * @hide exposed on OHOS
353      */
354     public static interface EGender {
355         public static final byte M = 0;
356         public static final byte F = 1;
357         public static final byte N = 2;
358         public static final String[] names = { "M", "F", "N" };
359     }
360 }
361