]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-52_1/main/tests/core/src/com/ibm/icu/dev/test/util/CalendarFieldsSet.java
Added flags.
[Dictionary.git] / jars / icu4j-52_1 / main / tests / core / src / com / ibm / icu / dev / test / util / CalendarFieldsSet.java
1 /*
2  *******************************************************************************
3  * Copyright (C) 2007, International Business Machines Corporation and         *
4  * others. All Rights Reserved.                                                *
5  *******************************************************************************
6  */
7 package com.ibm.icu.dev.test.util;
8
9 import com.ibm.icu.util.Calendar;
10
11 /**
12  * @author srl
13  *
14  */
15 public class CalendarFieldsSet extends FieldsSet {
16
17     /**
18      * @param whichEnum
19      * @param fieldsCount
20      */
21     public CalendarFieldsSet() {
22         super(DebugUtilitiesData.UCalendarDateFields,-1);
23     }
24     
25     public boolean  matches(Calendar cal, CalendarFieldsSet diffSet) {
26         boolean match = true;
27         for(int i=0;i<fieldCount();i++) {
28             if(isSet(i)) {
29                 int calVal = cal.get(i);
30                 if(calVal != get(i)) {
31                     match = false;
32                     diffSet.set(i, calVal);
33                 }
34             }
35         }
36         return match;
37     }
38
39     /**
40      * set the specified fields on this calendar. Doesn't clear first. Returns any errors the cale 
41      */
42     public void setOnCalendar(Calendar cal) {
43         for(int i=0;i<fieldCount();i++) {
44             if(isSet(i)) {
45                 cal.set(i, get(i));
46             }
47         }
48     }
49
50     protected void handleParseValue(FieldsSet inheritFrom, int field, String substr) {
51         if(field == Calendar.MONTH) {
52             parseValueEnum(DebugUtilitiesData.UCalendarMonths, inheritFrom, field, substr);
53             // will fallback to default.
54         } else {
55             parseValueDefault(inheritFrom, field, substr);
56         }
57     }
58 }