Package org.jfree.date
Class RelativeDayOfWeekRule
java.lang.Object
org.jfree.date.AnnualDateRule
org.jfree.date.RelativeDayOfWeekRule
- All Implemented Interfaces:
Cloneable
An annual date rule that returns a date for each year based on (a) a
reference rule; (b) a day of the week; and (c) a selection parameter
(SerialDate.PRECEDING, SerialDate.NEAREST, SerialDate.FOLLOWING).
For example, Good Friday can be specified as 'the Friday PRECEDING Easter Sunday'.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intThe day of the week (SerialDate.MONDAY, SerialDate.TUESDAY, and so on).private intSpecifies which day of the week (PRECEDING, NEAREST or FOLLOWING).private AnnualDateRuleA reference to the annual date rule on which this rule is based. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor - builds a rule for the Monday following 1 January.RelativeDayOfWeekRule(AnnualDateRule subrule, int dayOfWeek, int relative) Standard constructor - builds rule based on the supplied sub-rule. -
Method Summary
Modifier and TypeMethodDescriptionclone()Creates a clone of this rule.getDate(int year) Returns the date generated by this rule, for the specified year.intReturns the day-of-the-week for this rule.intReturns the 'relative' attribute, that determines *which* day-of-the-week we are interested in (SerialDate.PRECEDING, SerialDate.NEAREST or SerialDate.FOLLOWING).Returns the sub-rule (also called the reference rule).voidsetDayOfWeek(int dayOfWeek) Sets the day-of-the-week for this rule.voidsetRelative(int relative) Sets the 'relative' attribute (SerialDate.PRECEDING, SerialDate.NEAREST, SerialDate.FOLLOWING).voidsetSubrule(AnnualDateRule subrule) Sets the sub-rule.
-
Field Details
-
subrule
A reference to the annual date rule on which this rule is based. -
dayOfWeek
private int dayOfWeekThe day of the week (SerialDate.MONDAY, SerialDate.TUESDAY, and so on). -
relative
private int relativeSpecifies which day of the week (PRECEDING, NEAREST or FOLLOWING).
-
-
Constructor Details
-
RelativeDayOfWeekRule
public RelativeDayOfWeekRule()Default constructor - builds a rule for the Monday following 1 January. -
RelativeDayOfWeekRule
Standard constructor - builds rule based on the supplied sub-rule.- Parameters:
subrule- the rule that determines the reference date.dayOfWeek- the day-of-the-week relative to the reference date.relative- indicates *which* day-of-the-week (preceding, nearest or following).
-
-
Method Details
-
getSubrule
Returns the sub-rule (also called the reference rule).- Returns:
- The annual date rule that determines the reference date for this rule.
-
setSubrule
Sets the sub-rule.- Parameters:
subrule- the annual date rule that determines the reference date for this rule.
-
getDayOfWeek
public int getDayOfWeek()Returns the day-of-the-week for this rule.- Returns:
- the day-of-the-week for this rule.
-
setDayOfWeek
public void setDayOfWeek(int dayOfWeek) Sets the day-of-the-week for this rule.- Parameters:
dayOfWeek- the day-of-the-week (SerialDate.MONDAY, SerialDate.TUESDAY, and so on).
-
getRelative
public int getRelative()Returns the 'relative' attribute, that determines *which* day-of-the-week we are interested in (SerialDate.PRECEDING, SerialDate.NEAREST or SerialDate.FOLLOWING).- Returns:
- The 'relative' attribute.
-
setRelative
public void setRelative(int relative) Sets the 'relative' attribute (SerialDate.PRECEDING, SerialDate.NEAREST, SerialDate.FOLLOWING).- Parameters:
relative- determines *which* day-of-the-week is selected by this rule.
-
clone
Creates a clone of this rule.- Overrides:
clonein classAnnualDateRule- Returns:
- a clone of this rule.
- Throws:
CloneNotSupportedException- this should never happen.
-
getDate
Returns the date generated by this rule, for the specified year.- Specified by:
getDatein classAnnualDateRule- Parameters:
year- the year (1900 <= year <= 9999).- Returns:
- The date generated by the rule for the given year (possibly
null).
-