|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.jaret.util.date.holidayenumerator.HolidayEnumeratorBase
public abstract class HolidayEnumeratorBase
Base implementation for HolidayEnumerators. This abstract class contains a complete base implementation and some date
calculation code (easter and other). Concrete HolidayEnumertaors have to implement the method
fillMap(int year)
to fill all hollidays (and special days). To add a day the method
addNamedDate
should be used. Attention has to be taken: all month values start with 0 (january = 0)
Nested Class Summary | |
---|---|
class |
HolidayEnumeratorBase.EasyDate
Simple holder class for a split date. |
class |
HolidayEnumeratorBase.NamedDateImpl
Implementation of the NamedDate for use with holiday enumerators. |
Field Summary | |
---|---|
protected Locale |
_locale
locale. |
protected String |
_regionId
region id. |
protected Map<Integer,Map<Integer,Map<Integer,NamedDate>>> |
_yearMap
map containing the holidays and special days. |
protected static Calendar |
CALENDAR
calendar instance for calculations. |
Constructor Summary | |
---|---|
HolidayEnumeratorBase()
|
Method Summary | |
---|---|
protected void |
addNamedDate(HolidayEnumeratorBase.EasyDate ed,
boolean isHoliday,
String name)
|
protected void |
addNamedDate(int year,
int month,
int day,
boolean isHoliday,
String name)
Add a named date to the list of holidays. |
protected void |
addNamedDate(int year,
int month,
int day,
int dayOffset,
boolean isHoliday,
String name)
|
HolidayEnumeratorBase.EasyDate |
calcEaster(int year)
Calculate the easter date (sunday) for a given year. |
protected int |
daysInMonth(int year,
int month)
|
boolean |
equals(Object obj)
. |
protected abstract void |
fillMap(int year)
Calculate the holidays for a given year. |
HolidayEnumeratorBase.EasyDate |
fridayOrMonday(HolidayEnumeratorBase.EasyDate ed)
If the given Date is a saturday return the friday before, if it is a sunday return the monday after, in all other cases return null . |
String[] |
getAvailableRegionIds()
Retrieve the available region identifiers of the holiday enumerator. |
protected Date |
getDate(int year,
int month,
int day,
int dayOffset)
|
String |
getDayName(Date date)
Retrieve the name of a special day or holiday. |
HolidayEnumeratorBase.EasyDate |
getEasyDate(int year,
int month,
int day)
|
Locale |
getLocale()
Retrieve the Locale of this HolidayEnumerator. |
List<NamedDate> |
getNamedDays(int year,
boolean includeSpecialDays)
Retrieve a list of named days for a given year. |
List<NamedDate> |
getNamedDays(int year,
int month,
boolean includeSpecialDays)
Retrieve a list of named days for a given year. |
String |
getRegionId()
Retrieve the RegionId of this HolidayEnumerator. |
protected int |
getWeekday(Date date)
|
int |
hashCode()
|
protected void |
init()
Do initializations. |
boolean |
isHoliday(Date date)
Check whether a given day denotes a holiday. |
boolean |
isSpecialDay(Date date)
Check whether a given day denotes a special (named) day. |
HolidayEnumeratorBase.EasyDate |
lastWeekdayInMonth(int year,
int month,
int weekday)
Calculate the last weekday in a given month. |
HolidayEnumeratorBase.EasyDate |
nThWeekdayInMonth(int year,
int month,
int weekday,
int nTh)
Calculate the nTh weekday in a month (i.e. the 3rd Monday in october) |
void |
setLocale(Locale locale)
|
void |
setRegionId(String regionId)
|
String |
toString()
toString delivers the region. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Map<Integer,Map<Integer,Map<Integer,NamedDate>>> _yearMap
protected static final Calendar CALENDAR
protected Locale _locale
protected String _regionId
Constructor Detail |
---|
public HolidayEnumeratorBase()
Method Detail |
---|
protected abstract void fillMap(int year)
year
- year to calculate the holidays forpublic String[] getAvailableRegionIds()
getAvailableRegionIds
in interface HolidayEnumerator
public String toString()
toString
in class Object
public boolean equals(Object obj)
equals
in class Object
public int hashCode()
hashCode
in class Object
protected void init()
protected void addNamedDate(int year, int month, int day, boolean isHoliday, String name)
year
- yearmonth
- (0= January!)day
- dayisHoliday
- true for holiday, false = special dayname
- name of the dateprotected void addNamedDate(int year, int month, int day, int dayOffset, boolean isHoliday, String name)
protected void addNamedDate(HolidayEnumeratorBase.EasyDate ed, boolean isHoliday, String name)
protected Date getDate(int year, int month, int day, int dayOffset)
protected int getWeekday(Date date)
public boolean isHoliday(Date date)
isHoliday
in interface HolidayEnumerator
date
- date to be checked
public boolean isSpecialDay(Date date)
isSpecialDay
in interface HolidayEnumerator
date
- The date to be checked
public String getDayName(Date date)
getDayName
in interface HolidayEnumerator
date
- date for which the name is to be retrieved
null
if no name is found.public Locale getLocale()
getLocale
in interface HolidayEnumerator
public void setLocale(Locale locale)
public String getRegionId()
getRegionId
in interface HolidayEnumerator
public void setRegionId(String regionId)
public List<NamedDate> getNamedDays(int year, boolean includeSpecialDays)
getNamedDays
in interface HolidayEnumerator
year
- year to be questionedincludeSpecialDays
- if true, special days are includes, otherwise the list will only contain holidays
public List<NamedDate> getNamedDays(int year, int month, boolean includeSpecialDays)
getNamedDays
in interface HolidayEnumerator
year
- year to be questionedmonth
- month to be questionedincludeSpecialDays
- if true, special days are includes, otherwise the list will only contain holidays
public HolidayEnumeratorBase.EasyDate calcEaster(int year)
year
- year (valid input from 1583 to 2499)
public HolidayEnumeratorBase.EasyDate nThWeekdayInMonth(int year, int month, int weekday, int nTh)
year
- yearmonth
- month (starting with january = 0)weekday
- weekday as constant from java.util.CalendarnTh
- first=1, ... max 5
public HolidayEnumeratorBase.EasyDate lastWeekdayInMonth(int year, int month, int weekday)
year
- yearmonth
- (January=0!)weekday
- constant from java.util.Calendar
public HolidayEnumeratorBase.EasyDate fridayOrMonday(HolidayEnumeratorBase.EasyDate ed)
null
. Used for correction of US holidays.
ed
- date to go from
protected int daysInMonth(int year, int month)
public HolidayEnumeratorBase.EasyDate getEasyDate(int year, int month, int day)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |