Package de.focus_shift.impl
Class DefaultHolidayManager
- java.lang.Object
-
- de.focus_shift.HolidayManager
-
- de.focus_shift.impl.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 Summary
Fields Modifier and Type Field Description protected ConfigurationconfigurationConfiguration parsed on initialization.-
Fields inherited from class de.focus_shift.HolidayManager
calendarUtil
-
-
Constructor Summary
Constructors Constructor Description DefaultHolidayManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddoInit()CalendarHierarchygetCalendarHierarchy()Returns the configured hierarchy structure for the specific manager.Set<Holiday>getHolidays(int year, String... args)Returns the holidays for the requested year and hierarchy structure.Set<Holiday>getHolidays(LocalDate startDateInclusive, LocalDate endDateInclusive, String... args)Returns the holidays for the requested interval and hierarchy structure.protected static voidlogHierarchy(Configuration configuration, int level)Logs the hierarchy structure.protected static voidvalidateConfigurationHierarchy(Configuration c)Validates the content of the provided configuration by checking for multiple hierarchy entries within one configuration.-
Methods inherited from class de.focus_shift.HolidayManager
clearManagerCache, getConfigurationService, getInstance, getInstance, getInstance, getManagerParameter, getSupportedCalendarCodes, init, isHoliday, isHoliday, isHoliday, isHoliday, isManagerCachingEnabled, setConfigurationService, setManagerCachingEnabled
-
-
-
-
Field Detail
-
configuration
protected Configuration configuration
Configuration parsed on initialization.
-
-
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:
getHolidaysin classHolidayManager- Parameters:
year- i.e. 2010args- 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:
getHolidaysin classHolidayManager- Parameters:
startDateInclusive- the start date of the interval in which holidays lie, inclusiveendDateInclusive- the end date of the interval in which holidays lie, inclusiveargs- aStringobject.- 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:
doInitin classHolidayManager
-
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- aConfigurationobject.
-
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:
getCalendarHierarchyin classHolidayManager- Returns:
- Current calendars hierarchy
-
-