org.chronicj.impl
Class DayInMonthTE

java.lang.Object
  |
  +--org.chronicj.impl.AbstractTemporalExpression
        |
        +--org.chronicj.impl.DayInMonthTE
All Implemented Interfaces:
TemporalExpression

public class DayInMonthTE
extends AbstractTemporalExpression

Implements support for temporal expressions of the form: "last Friday of the month" or "first Tuesday of the month". Expressions syntax is specified in the constructor call (DayInMonthTE(int, int)).

This class is based directly on patterns described in a paper by Martin Fowler which can be found here.

Author:
Matthew Lipper
See Also:
Recurring Events for Calendars by Martin Fowler

Constructor Summary
DayInMonthTE(int dayIndex)
          Creates a temporal expression using day of the week 1 to 7.
DayInMonthTE(int dayIndex, int count)
          Creates a temporal expression using day of the week 1 to 7 and day of week in month which may be either positive or negative indicating whether count is from beginning or end of the month, respectively.
 
Method Summary
 boolean includes(org.chronicj.TimePoint aTimePoint)
          Does the value of the supplied argument match this expression? If this instance was created with DayInMonthTE(int, int) constructor:
true = day of week matches and week of month matches, e.g.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DayInMonthTE

public DayInMonthTE(int dayIndex,
                    int count)
Creates a temporal expression using day of the week 1 to 7 and day of week in month which may be either positive or negative indicating whether count is from beginning or end of the month, respectively. For example, if the first day of the week is set to Sunday (set in GregorianCalendar):

TemporalExpression anExpression = new DayInMonthTE(3,2); //example 1
TemporalExpression anotherExpression = new DayInMonthTE(6,-1); //example 2

Example 1 creates the expression "the second Tuesday" of the month. Example 2 creates the expression "the last Friday" of the month.

Parameters:
dayIndex - the day of the week numbered from 1 to 7
count - the week number from the beginning of the month if positive or the the week number from the end of the month if negative.

DayInMonthTE

public DayInMonthTE(int dayIndex)
Creates a temporal expression using day of the week 1 to 7. For example:

TemporalExpression sunday = new DayInMonthTE(1); //Sunday
TemporalExpression saturday = new DayInMonthTE(7); //SaturdayTemporalExpression thursday = new DayInMonthTE(5); //Thursday

Parameters:
dayIndex - the day of the week numbered from 1 to 7
Method Detail

includes

public boolean includes(org.chronicj.TimePoint aTimePoint)
Does the value of the supplied argument match this expression? If this instance was created with DayInMonthTE(int, int) constructor:
true = day of week matches and week of month matches, e.g. 3rd Tuesday of the month. If this instance was created with DayInMonthTE(int) constructor:
true = day of week matches, e.g. Friday.

Specified by:
includes in interface TemporalExpression
Specified by:
includes in class AbstractTemporalExpression
Parameters:
aTimePoint - the TimePoint against which to check
Returns:
boolean true if the given TimePoint occurs during the time this expression describes.
See Also:
TemporalExpression


Copyright © 2003-2004 Digital Clash Software. All Rights Reserved.