12ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller/* GENERATED SOURCE. DO NOT MODIFY. */
2f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert// © 2016 and later: Unicode, Inc. and others.
3f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert// License & terms of use: http://www.unicode.org/copyright.html#License
42ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller/*
52ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller *******************************************************************************
62ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Copyright (C) 1996-2011, International Business Machines Corporation and    *
72ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * others. All Rights Reserved.                                                *
82ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller *******************************************************************************
92ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */
102ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
112ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerpackage android.icu.util;
122ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
132ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport java.util.Date;
142ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport java.util.Locale;
152ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport java.util.MissingResourceException;
162ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport java.util.ResourceBundle;
172ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
182ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport android.icu.util.ULocale.Category;
192ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
202ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller/**
212ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * <b>Note:</b> The Holiday framework is a technology preview.
222ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Despite its age, is still draft API, and clients should treat it as such.
23f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert *
242ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * An abstract class representing a holiday.
25836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller * @hide Only a subset of ICU is exposed in Android
26836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller * @hide draft / provisional / internal are hidden on Android
272ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */
282ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerpublic abstract class Holiday implements DateRule
292ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller{
302ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
31836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller     * @hide draft / provisional / internal are hidden on Android
322ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
332ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public static Holiday[] getHolidays()
342ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    {
352ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return getHolidays(ULocale.getDefault(Category.FORMAT));
362ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
372ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
382ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
39836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller     * @hide draft / provisional / internal are hidden on Android
402ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
412ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public static Holiday[] getHolidays(Locale locale)
422ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    {
432ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return getHolidays(ULocale.forLocale(locale));
442ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
452ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
462ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
47836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller     * @hide draft / provisional / internal are hidden on Android
482ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
492ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public static Holiday[] getHolidays(ULocale locale)
502ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    {
512ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        Holiday[] result = noHolidays;
522ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
532ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        try {
542ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            ResourceBundle bundle = UResourceBundle.getBundleInstance("android.icu.impl.data.HolidayBundle", locale);
552ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
562ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            result = (Holiday[]) bundle.getObject("holidays");
572ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        }
582ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        catch (MissingResourceException e) {
592ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        }
602ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return result;
612ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
622ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
632ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
642ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * Return the first occurrence of this holiday on or after the given date
652ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *
662ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @param start Only holidays on or after this date are returned.
672ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *
682ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @return      The date on which this holiday occurs, or null if it
692ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *              does not occur on or after the start date.
702ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *
712ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @see #firstBetween
72836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller     * @hide draft / provisional / internal are hidden on Android
732ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
74f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert    @Override
752ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public Date firstAfter(Date start) {
762ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return rule.firstAfter(start);
772ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
782ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
792ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
802ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * Return the first occurrence of this holiday that is on or after
812ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * the given start date and before the given end date.
822ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *
832ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @param start Only occurrences on or after this date are returned.
842ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @param end   Only occurrences before this date are returned.
852ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *
862ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @return      The date on which this event occurs, or null if it
872ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *              does not occur between the start and end dates.
882ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *
892ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @see #firstAfter
90836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller     * @hide draft / provisional / internal are hidden on Android
912ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
92f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert    @Override
932ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public Date firstBetween(Date start, Date end) {
942ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return rule.firstBetween(start, end);
952ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
962ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
972ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
982ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * Checks whether this holiday falls on the given date.  This does
992ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * <em>not</em> take time of day into account; instead it checks
1002ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * whether the holiday and the given date are on the same day.
1012ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *
1022ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @param date  The date to check.
1032ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @return      true if this holiday occurs on the given date.
104836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller     * @hide draft / provisional / internal are hidden on Android
1052ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
106f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert    @Override
1072ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public boolean isOn(Date date) {
1082ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        //System.out.println(name + ".isOn(" + date.toString() + "):");
1092ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return rule.isOn(date);
1102ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
1112ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
1122ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
1132ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * Check whether this holiday occurs at least once between the two
1142ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * dates given.
115836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller     * @hide draft / provisional / internal are hidden on Android
1162ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
117f86f25d102340da66b9c7cb6b2d5ecdc0de43ecfFredrik Roubert    @Override
1182ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public boolean isBetween(Date start, Date end) {
1192ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return rule.isBetween(start, end);
1202ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
1212ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
1222ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
1232ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * Construct a new Holiday object.  This is for use by subclasses only.
1242ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * This constructs a new holiday with the given name and date rules.
1252ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *
1262ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @param name  The name of this holiday.  The getDisplayName method
1272ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *              uses this string as a key to look up the holiday's name a
1282ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *              resource bundle object named HolidayBundle.
1292ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *
1302ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @param rule  The date rules used for determining when this holiday
1312ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *              falls.  Holiday's implementation of the DateRule interface
1322ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *              simply delegates to this DateRule object.
133836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller     * @hide draft / provisional / internal are hidden on Android
1342ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
1352ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    protected Holiday(String name, DateRule rule)
1362ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    {
1372ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        this.name = name;
1382ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        this.rule = rule;
1392ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
1402ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
1412ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
1422ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * Return the name of this holiday in the language of the default <code>DISPLAY</code> locale.
1432ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @see Category#DISPLAY
144836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller     * @hide draft / provisional / internal are hidden on Android
1452ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
1462ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public String getDisplayName() {
1472ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return getDisplayName(ULocale.getDefault(Category.DISPLAY));
1482ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
1492ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
1502ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
1512ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * Return the name of this holiday in the language of the specified locale.
1522ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * The <code>name</code> parameter passed to this object's constructor is used
1532ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * as a key to look up the holiday's localized name in a ResourceBundle object
1542ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * named HolidayBundle.
1552ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *
1562ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @param locale   A locale specifying the language in which the name is desired.
1572ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *
1582ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @see ResourceBundle
159836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller     * @hide draft / provisional / internal are hidden on Android
1602ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
1612ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public String getDisplayName(Locale locale)
1622ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    {
1632ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return getDisplayName(ULocale.forLocale(locale));
1642ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
1652ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
1662ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
1672ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * Return the name of this holiday in the language of the specified locale
1682ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * The <code>name</code> parameter passed to this object's constructor is used
1692ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * as a key to look up the holiday's localized name in a ResourceBundle object
1702ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * named HolidayBundle.
1712ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *
1722ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @param locale   A locale specifying the language in which the name is desired.
1732ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     *
1742ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @see ResourceBundle
175836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller     * @hide draft / provisional / internal are hidden on Android
1762ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
1772ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public String getDisplayName(ULocale locale)
1782ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    {
1792ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        String dispName = name;
1802ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
1812ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        try {
1822ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            ResourceBundle bundle = UResourceBundle.getBundleInstance("android.icu.impl.data.HolidayBundle", locale);
1832ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            dispName = bundle.getString(name);
1842ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        }
1852ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        catch (MissingResourceException e) {
1862ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        }
1872ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return dispName;
1882ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
1892ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
1902ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
191836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller     * @hide draft / provisional / internal are hidden on Android
1922ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
1932ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public DateRule getRule() {
1942ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return rule;
1952ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
1962ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
1972ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
198836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller     * @hide draft / provisional / internal are hidden on Android
1992ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
2002ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public void setRule(DateRule rule) {
2012ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        this.rule = rule;
2022ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
2032ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
2042ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    private String      name;
2052ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    private DateRule    rule;
2062ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
2072ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    private static Holiday[] noHolidays = {};
2082ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller}
209