Class DefaultHolidayManager

  • Direct Known Subclasses:
    JapaneseHolidayManager

    public class DefaultHolidayManager
    extends HolidayManager
    Manager implementation for reading data from the configuration datasource. It uses a list a parsers for parsing the different type of XML nodes.
    Author:
    Sven Diedrichsen
    • Field Detail

      • configuration

        protected Configuration configuration
        Configuration parsed on initialization.
    • Constructor Detail

      • DefaultHolidayManager

        public DefaultHolidayManager()
    • Method Detail

      • getHolidays

        public Set<Holiday> getHolidays​(int year,
                                        String... args)
        Returns the holidays for the requested year and hierarchy structure.

        Calls Set<LocalDate> getHolidays(int year, Configuration c, String... args) with the configuration from initialization.

        Specified by:
        getHolidays in class HolidayManager
        Parameters:
        year - i.e. 2010
        args - i.e. args = {'ny'}. returns US/New York holidays. No args -> holidays common to whole country
        Returns:
        the list of holidays for the requested year
      • getHolidays

        public Set<Holiday> getHolidays​(LocalDate startDateInclusive,
                                        LocalDate endDateInclusive,
                                        String... args)
        Returns the holidays for the requested interval and hierarchy structure.

        Calls getHolidays(year, args) for each year within the interval and returns a list of holidays which are then contained in the interval.

        Specified by:
        getHolidays in class HolidayManager
        Parameters:
        startDateInclusive - the start date of the interval in which holidays lie, inclusive
        endDateInclusive - the end date of the interval in which holidays lie, inclusive
        args - a String object.
        Returns:
        list of holidays within the interval
      • doInit

        public void doInit()

        Initializes the DefaultHolidayManager by loading the holidays XML file as resource from the classpath. When the XML file is found it will be unmarshalled with JAXB to some Java classes.

        Specified by:
        doInit in class HolidayManager
      • logHierarchy

        protected static void logHierarchy​(Configuration configuration,
                                           int level)
        Logs the hierarchy structure.
        Parameters:
        configuration - Configuration to log hierarchy for.
        level - an int.
      • validateConfigurationHierarchy

        protected static void validateConfigurationHierarchy​(Configuration c)
        Validates the content of the provided configuration by checking for multiple hierarchy entries within one configuration. It traverses down the configuration tree.
        Parameters:
        c - a Configuration object.
      • getCalendarHierarchy

        public CalendarHierarchy getCalendarHierarchy()
        Returns the configured hierarchy structure for the specific manager. This hierarchy shows how the configured holidays are structured and can be retrieved.

        Returns the configurations hierarchy.
        i.e. Hierarchy 'us' -> Children 'al','ak','ar', ... ,'wv','wy'. Every child might itself have children. The ids be used to call getHolidays()/isHoliday().

        Specified by:
        getCalendarHierarchy in class HolidayManager
        Returns:
        Current calendars hierarchy