java.lang.Object
COM.TIBCO.hawk.config.rbengine.schedule.Period
All Implemented Interfaces:
Scheduleable, Cloneable

public class Period extends Object implements Scheduleable, Cloneable
A Period defines the time intervals, days or months that should be included or excluded in a schedule. It contains 4 schedule components:
  • MinutesInDay
  • DaysInMonth
  • WeekDaysInMonth
  • MonthsInYear
A Period is in-schedule only if all of its 4 components are in-schedule. Otherwise, a Period is out-of-schedule.

A Period can be used as an inclusion period or exclusion period in a Schedule. When a Period is used as an inclusion period, the Schedule is in-schedule when the Period is in-schedule. When a Period is used as an exclusion period, the Schedule is out-of-schedule when the Period is in-schedule.

MinutesInDay contains a set of 1440 continuous 1-minute intervals in a 24 hour period. Intervals of MinutesInDay can be accessed using an interger index value. The first interval starts at 12:00am has an index value of 0. The last interval is from 11:59pm with an index value of 1439. A MinutesInDay is in-schedule if the time for checking the schedule is included in the MinutesInDay. Otherwise, it is out-of-schedule.

DaysInMonth contains a set of 31 days in a month. A newly created period includes every day of the month. A day in DaysInMonth can be accessed using an integer index value. The first day starts at first of the month with an index value of 0. The last day is the 31th day with an index value of 30. The constant LAST_DAY_OF_MONTH should be used for last day of a month. A DaysInMonth is in-schedule if the day in the date for checking the schedule is included in the DaysInMonth. Otherwise, it is out-of-schedule. Including or excluding a day that a month does not contain will have no effect in the schedule. For example, excluding the 31st day for Febuary has no effect on the schedule.

WeekDaysInMonth contains a set of 7 days in a week. The first day of the week starts on Sunday and ends on Saturday. To include a day in WeekDaysInMonth in the schedule, useful constant are provided or integer index value of 0 to 6 may be used. Index value of 0 correspond to Sunday and 6 correspond to Saturday. There are 5 constants that can be used to indicate a particular weekday with in a month. They are:

  • FIRST_WEEKDAY_OF_MONTH - for the first weekday of the month.
  • SECOND_WEEKDAY_OF_MONTH - for the second weekday of the month.
  • THIRD_WEEKDAY_OF_MONTH - for the third weekday of the month.
  • FORTH_WEEKDAY_OF_MONTH - for the forth weekday of the month.
  • LAST_WEEKDAY_OF_MONTH - for the last weekday of the month.
A WeekDaysInMonth is in-schedule if the day of date for checking the schedule is included in the WeekDaysInMonth. Otherwise, it is out-of-schedule. If FIRST_WEEKDAY_OF_MONTH, SECOND_WEEKDAY_OF_MONTH, THIRD_WEEKDAY_OF_MONTH, FOURTH_WEEKDAY_OF_MONTH, or LAST_WEEKDAY_OF_MONTH is not included in the schedule, that weekday of the month will be excluded.

MonthsInYear contains a set of 12 months in a year. The first month of the year starts on January and ends on December. To include a month in MonthsInYear in the schedule, useful constant are provided or integer value of 0 to 11 may be used. Interger value of 0 correspond to January and 11 correspond to December. A MonthsInYear is in-schedule if the month of the date used for checking the schedule is included in the MonthsInYear. Otherwise, it is out-of-schedule.

Note that DaysInMonth and WeekDaysInMonth both contain day definition for the schedule - one in term of day of week and the other in term of day of month. If the same day in DaysInMonth or WeekDaysInMonth is out-of-schedule, that day is consider out-of-schedule. For example, if the WeekDaysInMonth in a Period includes weekdays (Monday to Friday), and the DaysInMonth in the same Period include the first day of the month. If the first day of the month is on Sunday, then period is out of schedule on the first day of the month eventhough it is included in DaysInMonth of the period.

The 4 components of the period is accessed from 5 common methods:

These methods take an argument to indicate which component that method is intended for. A constant is provided for each component to be used for the argument. They are:
  • MINUTES_IN_DAY for MinutesInDay
  • WEEKDAYS_IN_MONTH for WeekDaysInMonth
  • DAYS_IN_MONTH for DaysInMonth
  • MONTHS_IN_YEAR for MonthsInYear
The following code fragment shows how include Monday in WeekDaysInMonth:
           Period period = new Period();
           period.include(WEEKDAYS_IN_MONTH, MONDAY);
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected COM.TIBCO.hawk.config.rbengine.schedule.impl.ScheduleDaysInMonth
     
    protected COM.TIBCO.hawk.config.rbengine.schedule.impl.ScheduleDaysInWeek
     
    protected COM.TIBCO.hawk.config.rbengine.schedule.impl.ScheduleMinutesInDay
     
    protected COM.TIBCO.hawk.config.rbengine.schedule.impl.ScheduleMonthsInYear
     
    static final int
    A constant for including or excluding April.
    static final int
    A constant for including or excluding August.
    static final int
    A constant for days in month component in the period.
    static final int
    A constant for including or excluding December.
    static final int
    A constant for including or excluding Frebruary.
    static final int
    A constant for including first weekday in a month.
    static final int
    A constant for including forth weekday in a month.
    static final int
    A constant for including or excluding Friday.
    static final int
    A constant for including or excluding January.
    static final int
    A constant for including or excluding July.
    static final int
    A constant for including or excluding June.
    static final int
    A constant for including last day of a month.
    static final int
    A constant for including last weekday in a month.
    static final int
    A constant for including or excluding March.
    static final int
    A constant for including or excluding May.
    static final int
    A constant for time of day component in the period.
    static final int
    A constant for including or excluding Monday.
    static final int
    A constant for months in year component in the period.
    static final int
    A constant for including or excluding November.
    static final int
    A constant for the number of days in a DaysInMonth.
    static final int
    A constant for the number of days in a WeekDaysInMonth.
    static final int
    A constant for the number 15-minute intervals in TimeOfDay.
    static final int
    A constant for the number of minutes in MinutesInDay.
    static final int
    A constant for number of months in MonthsInYear.
    static final int
    A constant for including or excluding October.
    static final int
    A constant for including or excluding Saturday.
    static final int
    A constant for including second weekday in a month.
    static final int
    A constant for including or excluding September.
    static final int
    A constant for including or excluding Sunday.
    static final int
    A constant for including third weekday in a month.
    static final int
    A constant for including or excluding Thursday.
    static final int
    A constant for time of day component in the period.
    static final int
    A constant for including or excluding Tuesday.
    static final int
    A constant for including or excluding Wednesday.
    static final int
    A constant for weekdays in month component in the period.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a Period.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a copy of this Period.
    boolean
    Compares the specified object with this Period.
    void
    exclude(int component, int index)
    Excludes the specific time period of a component in this Period.
    void
    excludeAll(int component)
    Excludes the entire time period of a component in this Period.
    COM.TIBCO.hawk.config.rbengine.schedule.impl.ScheduleMinutesInDay
    Deprecated. 
    void
    include(int component, int index)
    Includes the specific time period of a component in this Period.
    void
    includeAll(int component)
    Includes the entire time period of a component in this Period.
    boolean
    Checks to see if this object is in schedule based on passed GregorianCalendar.
    boolean
    Returns false if the definition of the schedule components in the Period will cause it to be always excluded in the schedule.
    boolean
    isIncluded(int component, int index)
    Checks to see if a period within a component is included in this Period.
    Returns a string reprensentation of this Period.
    toString(int iType)
    Deprecated. 

    Methods inherited from class java.lang.Object

    finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • TIME_OF_DAY

      public static final int TIME_OF_DAY
      A constant for time of day component in the period.
      See Also:
    • WEEKDAYS_IN_MONTH

      public static final int WEEKDAYS_IN_MONTH
      A constant for weekdays in month component in the period.
      See Also:
    • DAYS_IN_MONTH

      public static final int DAYS_IN_MONTH
      A constant for days in month component in the period.
      See Also:
    • MONTHS_IN_YEAR

      public static final int MONTHS_IN_YEAR
      A constant for months in year component in the period.
      See Also:
    • MINUTES_IN_DAY

      public static final int MINUTES_IN_DAY
      A constant for time of day component in the period.
      See Also:
    • NUM_OF_INTERVALS

      public static final int NUM_OF_INTERVALS
      A constant for the number 15-minute intervals in TimeOfDay.
      See Also:
    • NUM_OF_MINUTES

      public static final int NUM_OF_MINUTES
      A constant for the number of minutes in MinutesInDay.
      See Also:
    • NUM_OF_DAYS_IN_MONTH

      public static final int NUM_OF_DAYS_IN_MONTH
      A constant for the number of days in a DaysInMonth.
      See Also:
    • NUM_OF_DAYS_IN_WEEK

      public static final int NUM_OF_DAYS_IN_WEEK
      A constant for the number of days in a WeekDaysInMonth.
      See Also:
    • NUM_OF_MONTHS

      public static final int NUM_OF_MONTHS
      A constant for number of months in MonthsInYear.
      See Also:
    • SUNDAY

      public static final int SUNDAY
      A constant for including or excluding Sunday.
      See Also:
    • MONDAY

      public static final int MONDAY
      A constant for including or excluding Monday.
      See Also:
    • TUESDAY

      public static final int TUESDAY
      A constant for including or excluding Tuesday.
      See Also:
    • WEDNESDAY

      public static final int WEDNESDAY
      A constant for including or excluding Wednesday.
      See Also:
    • THURSDAY

      public static final int THURSDAY
      A constant for including or excluding Thursday.
      See Also:
    • FRIDAY

      public static final int FRIDAY
      A constant for including or excluding Friday.
      See Also:
    • SATURDAY

      public static final int SATURDAY
      A constant for including or excluding Saturday.
      See Also:
    • FIRST_WEEKDAY_OF_MONTH

      public static final int FIRST_WEEKDAY_OF_MONTH
      A constant for including first weekday in a month.
      See Also:
    • SECOND_WEEKDAY_OF_MONTH

      public static final int SECOND_WEEKDAY_OF_MONTH
      A constant for including second weekday in a month.
      See Also:
    • THIRD_WEEKDAY_OF_MONTH

      public static final int THIRD_WEEKDAY_OF_MONTH
      A constant for including third weekday in a month.
      See Also:
    • FOURTH_WEEKDAY_OF_MONTH

      public static final int FOURTH_WEEKDAY_OF_MONTH
      A constant for including forth weekday in a month.
      See Also:
    • LAST_WEEKDAY_OF_MONTH

      public static final int LAST_WEEKDAY_OF_MONTH
      A constant for including last weekday in a month.
      See Also:
    • LAST_DAY_OF_MONTH

      public static final int LAST_DAY_OF_MONTH
      A constant for including last day of a month.
      See Also:
    • JANUARY

      public static final int JANUARY
      A constant for including or excluding January.
      See Also:
    • FEBRUARY

      public static final int FEBRUARY
      A constant for including or excluding Frebruary.
      See Also:
    • MARCH

      public static final int MARCH
      A constant for including or excluding March.
      See Also:
    • APRIL

      public static final int APRIL
      A constant for including or excluding April.
      See Also:
    • MAY

      public static final int MAY
      A constant for including or excluding May.
      See Also:
    • JUNE

      public static final int JUNE
      A constant for including or excluding June.
      See Also:
    • JULY

      public static final int JULY
      A constant for including or excluding July.
      See Also:
    • AUGUST

      public static final int AUGUST
      A constant for including or excluding August.
      See Also:
    • SEPTEMBER

      public static final int SEPTEMBER
      A constant for including or excluding September.
      See Also:
    • OCTOBER

      public static final int OCTOBER
      A constant for including or excluding October.
      See Also:
    • NOVEMBER

      public static final int NOVEMBER
      A constant for including or excluding November.
      See Also:
    • DECEMBER

      public static final int DECEMBER
      A constant for including or excluding December.
      See Also:
    • _smid

      protected COM.TIBCO.hawk.config.rbengine.schedule.impl.ScheduleMinutesInDay _smid
    • _sdiw

      protected COM.TIBCO.hawk.config.rbengine.schedule.impl.ScheduleDaysInWeek _sdiw
    • _sdim

      protected COM.TIBCO.hawk.config.rbengine.schedule.impl.ScheduleDaysInMonth _sdim
    • _smiy

      protected COM.TIBCO.hawk.config.rbengine.schedule.impl.ScheduleMonthsInYear _smiy
  • Constructor Details

    • Period

      public Period()
      Creates a Period. The new Period has no time, day, or month included.
  • Method Details

    • include

      public void include(int component, int index)
      Includes the specific time period of a component in this Period.
      Parameters:
      component - the component of this Period.
      index - specific period to be included for the specified component.
      See Also:
    • exclude

      public void exclude(int component, int index)
      Excludes the specific time period of a component in this Period.
      Parameters:
      component - the component of this Period.
      index - specific period to be included for the specified component.
      See Also:
    • includeAll

      public void includeAll(int component)
      Includes the entire time period of a component in this Period.
      Parameters:
      component - the component of this Period.
      See Also:
    • excludeAll

      public void excludeAll(int component)
      Excludes the entire time period of a component in this Period.
      Parameters:
      component - the component of this Period.
      See Also:
    • isIncluded

      public boolean isIncluded(int component, int index)
      Checks to see if a period within a component is included in this Period.

      Parameters:
      component - the component of this Period.
      index - specific period of the specified component.
      Returns:
      true if the period is included, false otherwise.
    • isAlwaysExcluded

      public boolean isAlwaysExcluded()
      Returns false if the definition of the schedule components in the Period will cause it to be always excluded in the schedule.
    • equals

      public boolean equals(Object o)
      Compares the specified object with this Period.

      Overrides:
      equals in class Object
      Parameters:
      o - Object to compare.
      Returns:
      true if objects are equal, false otherwise.
    • clone

      public Object clone() throws CloneNotSupportedException
      Returns a copy of this Period.
      Overrides:
      clone in class Object
      Returns:
      a copy of this Period.
      Throws:
      CloneNotSupportedException
    • getMinutesInDay

      public COM.TIBCO.hawk.config.rbengine.schedule.impl.ScheduleMinutesInDay getMinutesInDay()
      Deprecated.
      Returns minutes in day component.
      Returns:
      minutes in day component of this period.
    • toString

      public String toString(int iType)
      Deprecated.
      Returns a string reprensentation of the specified component of the period.
      Parameters:
      iType - the component type of the period.
      Returns:
      a string reprensentation of the specified component of the period.
    • toString

      public String toString()
      Returns a string reprensentation of this Period. The string is a concatination of the string representation of the schedule components MinutesInDay, DaysInMonth, WeekDaysInMonth and MonthsInYear.

      Overrides:
      toString in class Object
    • inSchedule

      public boolean inSchedule(GregorianCalendar gc)
      Checks to see if this object is in schedule based on passed GregorianCalendar.
      Specified by:
      inSchedule in interface Scheduleable
      Parameters:
      gc - GregorianCalendar for checking if this Period is in schedule.
      Returns:
      true if this Period is in schedule.