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) 1996-2016, International Business Machines Corporation and    *
7 * others. All Rights Reserved.                                                *
8 *******************************************************************************
9 */
10
11package android.icu.util;
12
13import java.util.Date;
14
15/**
16 * <b>Note:</b> The Holiday framework is a technology preview.
17 * Despite its age, is still draft API, and clients should treat it as such.
18 *
19 * A holiday whose date can be represented by a month, day, and optionally day of week
20 * in the Gregorian calendar.
21 *
22 * @hide Only a subset of ICU is exposed in Android
23 * @hide draft / provisional / internal are hidden on Android
24 */
25public class SimpleHoliday extends Holiday {
26    /**
27     * Construct an object representing a holiday
28     *
29     * @param month         The month in which this holiday occurs (0-based)
30     * @param dayOfMonth    The date within the month (1-based).
31     *
32     * @param name  The name of this holiday.  This string is used as a key
33     *              to look up the holiday's name a resource bundle.
34     *              If the name is not found in the resource bundle,
35     *              getDisplayName will return this string instead.
36     *
37     * @see Holiday#getDisplayName(java.util.Locale)
38     * @hide draft / provisional / internal are hidden on Android
39     */
40    public SimpleHoliday(int month, int dayOfMonth, String name)
41    {
42        super(name, new SimpleDateRule(month, dayOfMonth));
43    }
44
45    /**
46     * Construct an object representing a holiday
47     *
48     * @param month         The month in which this holiday occurs (0-based)
49     * @param dayOfMonth    The date within the month (1-based).
50     *
51     * @param name  The name of this holiday.  This string is used as a key
52     *              to look up the holiday's name a resource bundle.
53     *              If the name is not found in the resource bundle,
54     *              getDisplayName will return this string instead.
55     *
56     * @see Holiday#getDisplayName(java.util.Locale)
57     * @hide draft / provisional / internal are hidden on Android
58     */
59    public SimpleHoliday(int month, int dayOfMonth, String name,
60                            int startYear)
61    {
62        super(name, rangeRule(startYear, 0, new SimpleDateRule(month, dayOfMonth)));
63    }
64
65    /**
66     * Construct an object representing a holiday
67     *
68     * @param month         The month in which this holiday occurs (0-based)
69     * @param dayOfMonth    The date within the month (1-based).
70     *
71     * @param name  The name of this holiday.  This string is used as a key
72     *              to look up the holiday's name a resource bundle.
73     *              If the name is not found in the resource bundle,
74     *              getDisplayName will return this string instead.
75     *
76     * @see Holiday#getDisplayName(java.util.Locale)
77     * @hide draft / provisional / internal are hidden on Android
78     */
79    public SimpleHoliday(int month, int dayOfMonth, String name,
80                            int startYear, int endYear)
81    {
82        super(name, rangeRule(startYear, endYear, new SimpleDateRule(month, dayOfMonth)));
83    }
84
85    /** // TODO: remove
86     * Construct an object representing a holiday
87     *
88     * @param month The month in which this holiday occurs (0-based)
89     *
90     * @param dayOfMonth A date within the month (1-based).  The
91     *      interpretation of this parameter depends on the value of
92     *      <code>dayOfWeek</code>.
93     *
94     * @param dayOfWeek The day of the week on which this holiday occurs.
95     *      The following values are legal: <ul>
96     *      <li>dayOfWeek == 0 - use dayOfMonth only
97     *      <li>dayOfWeek &lt; 0  - use last -dayOfWeek before or on dayOfMonth
98     *      <li>dayOfWeek &gt; 0  - use first dayOfWeek after or on dayOfMonth
99     *      </ul>
100     *
101     * @param name  The name of this holiday.  This string is used as a key
102     *              to look up the holiday's name a resource bundle.
103     *              If the name is not found in the resource bundle,
104     *              getDisplayName will return this string instead.
105     *
106     * @see Holiday#getDisplayName(java.util.Locale)
107     * @hide draft / provisional / internal are hidden on Android
108     */
109    public SimpleHoliday(int month, int dayOfMonth, int dayOfWeek, String name)
110    {
111        super(name, new SimpleDateRule(month, dayOfMonth,
112                                        dayOfWeek > 0 ? dayOfWeek : - dayOfWeek,
113                                        dayOfWeek > 0));
114    }
115
116    /**
117     * @hide draft / provisional / internal are hidden on Android
118     */
119    public SimpleHoliday(int month, int dayOfMonth, int dayOfWeek, String name,
120                        int startYear)
121    {
122        super(name, rangeRule(startYear, 0,
123                              new SimpleDateRule(month, dayOfMonth,
124                                                 dayOfWeek > 0 ? dayOfWeek : - dayOfWeek,
125                                                 dayOfWeek > 0)));
126    }
127
128
129    /**
130     * @hide draft / provisional / internal are hidden on Android
131     */
132    public SimpleHoliday(int month, int dayOfMonth, int dayOfWeek, String name,
133                        int startYear, int endYear)
134    {
135        super(name, rangeRule(startYear, endYear,
136                              new SimpleDateRule(month, dayOfMonth,
137                                                 dayOfWeek > 0 ? dayOfWeek : - dayOfWeek,
138                                                 dayOfWeek > 0)));
139    }
140
141    private static DateRule rangeRule(int startYear, int endYear, DateRule rule)
142    {
143        if (startYear == 0 && endYear == 0) {
144            return rule;
145        }
146
147        RangeDateRule rangeRule = new RangeDateRule();
148
149        if (startYear != 0) {
150            Calendar start = new GregorianCalendar(startYear, Calendar.JANUARY, 1);
151            rangeRule.add(start.getTime(), rule);
152        } else {
153            rangeRule.add(rule);
154        }
155        if (endYear != 0) {
156            Date end = new GregorianCalendar(endYear, Calendar.DECEMBER, 31).getTime();
157            rangeRule.add(end, null);
158        }
159
160        return rangeRule;
161    }
162
163    /* Constants for holidays that are common throughout the Western
164     * and Christian worlds.... */
165
166    /**
167     * New Year's Day - January 1st
168     * @hide draft / provisional / internal are hidden on Android
169     */
170    public static final SimpleHoliday NEW_YEARS_DAY =
171        new SimpleHoliday(Calendar.JANUARY,    1,  "New Year's Day");
172
173    /**
174     * Epiphany, January 6th
175     * @hide draft / provisional / internal are hidden on Android
176     */
177    public static final SimpleHoliday EPIPHANY =
178        new SimpleHoliday(Calendar.JANUARY,    6,  "Epiphany");
179
180    /**
181     * May Day, May 1st
182     * @hide draft / provisional / internal are hidden on Android
183     */
184    public static final SimpleHoliday MAY_DAY =
185        new SimpleHoliday(Calendar.MAY,        1,  "May Day");
186
187    /**
188     * Assumption, August 15th
189     * @hide draft / provisional / internal are hidden on Android
190     */
191    public static final SimpleHoliday ASSUMPTION =
192        new SimpleHoliday(Calendar.AUGUST,    15,  "Assumption");
193
194    /**
195     * All Saints' Day, November 1st
196     * @hide draft / provisional / internal are hidden on Android
197     */
198    public static final SimpleHoliday ALL_SAINTS_DAY =
199        new SimpleHoliday(Calendar.NOVEMBER,   1,  "All Saints' Day");
200
201    /**
202     * All Souls' Day, November 1st
203     * @hide draft / provisional / internal are hidden on Android
204     */
205    public static final SimpleHoliday ALL_SOULS_DAY =
206        new SimpleHoliday(Calendar.NOVEMBER,   2,  "All Souls' Day");
207
208    /**
209     * Immaculate Conception, December 8th
210     * @hide draft / provisional / internal are hidden on Android
211     */
212    public static final SimpleHoliday IMMACULATE_CONCEPTION =
213        new SimpleHoliday(Calendar.DECEMBER,   8,  "Immaculate Conception");
214
215    /**
216     * Christmas Eve, December 24th
217     * @hide draft / provisional / internal are hidden on Android
218     */
219    public static final SimpleHoliday CHRISTMAS_EVE =
220        new SimpleHoliday(Calendar.DECEMBER,  24,  "Christmas Eve");
221
222    /**
223     * Christmas, December 25th
224     * @hide draft / provisional / internal are hidden on Android
225     */
226    public static final SimpleHoliday CHRISTMAS =
227        new SimpleHoliday(Calendar.DECEMBER,  25,  "Christmas");
228
229    /**
230     * Boxing Day, December 26th
231     * @hide draft / provisional / internal are hidden on Android
232     */
233    public static final SimpleHoliday BOXING_DAY =
234        new SimpleHoliday(Calendar.DECEMBER,  26,  "Boxing Day");
235
236    /**
237     * Saint Stephen's Day, December 26th
238     * @hide draft / provisional / internal are hidden on Android
239     */
240    public static final SimpleHoliday ST_STEPHENS_DAY =
241        new SimpleHoliday(Calendar.DECEMBER,  26,  "St. Stephen's Day");
242
243    /**
244     * New Year's Eve, December 31st
245     * @hide draft / provisional / internal are hidden on Android
246     */
247    public static final SimpleHoliday NEW_YEARS_EVE =
248        new SimpleHoliday(Calendar.DECEMBER,  31,  "New Year's Eve");
249
250}
251