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