public class Period extends java.lang.Object implements Scheduleable, java.lang.Cloneable
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:
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:Period period = new Period(); period.include(WEEKDAYS_IN_MONTH, MONDAY);
Modifier and Type | Field and Description |
---|---|
static int |
APRIL
A constant for including or excluding April.
|
static int |
AUGUST
A constant for including or excluding August.
|
static int |
DAYS_IN_MONTH
A constant for days in month component in the period.
|
static int |
DECEMBER
A constant for including or excluding December.
|
static int |
FEBRUARY
A constant for including or excluding Frebruary.
|
static int |
FIRST_WEEKDAY_OF_MONTH
A constant for including first weekday in a month.
|
static int |
FOURTH_WEEKDAY_OF_MONTH
A constant for including forth weekday in a month.
|
static int |
FRIDAY
A constant for including or excluding Friday.
|
static int |
JANUARY
A constant for including or excluding January.
|
static int |
JULY
A constant for including or excluding July.
|
static int |
JUNE
A constant for including or excluding June.
|
static int |
LAST_DAY_OF_MONTH
A constant for including last day of a month.
|
static int |
LAST_WEEKDAY_OF_MONTH
A constant for including last weekday in a month.
|
static int |
MARCH
A constant for including or excluding March.
|
static int |
MAY
A constant for including or excluding May.
|
static int |
MINUTES_IN_DAY
A constant for time of day component in the period.
|
static int |
MONDAY
A constant for including or excluding Monday.
|
static int |
MONTHS_IN_YEAR
A constant for months in year component in the period.
|
static int |
NOVEMBER
A constant for including or excluding November.
|
static int |
NUM_OF_DAYS_IN_MONTH
A constant for the number of days in a DaysInMonth.
|
static int |
NUM_OF_DAYS_IN_WEEK
A constant for the number of days in a WeekDaysInMonth.
|
static int |
NUM_OF_INTERVALS
A constant for the number 15-minute intervals in TimeOfDay.
|
static int |
NUM_OF_MINUTES
A constant for the number of minutes in MinutesInDay.
|
static int |
NUM_OF_MONTHS
A constant for number of months in MonthsInYear.
|
static int |
OCTOBER
A constant for including or excluding October.
|
static int |
SATURDAY
A constant for including or excluding Saturday.
|
static int |
SECOND_WEEKDAY_OF_MONTH
A constant for including second weekday in a month.
|
static int |
SEPTEMBER
A constant for including or excluding September.
|
static int |
SUNDAY
A constant for including or excluding Sunday.
|
static int |
THIRD_WEEKDAY_OF_MONTH
A constant for including third weekday in a month.
|
static int |
THURSDAY
A constant for including or excluding Thursday.
|
static int |
TIME_OF_DAY
A constant for time of day component in the period.
|
static int |
TUESDAY
A constant for including or excluding Tuesday.
|
static int |
WEDNESDAY
A constant for including or excluding Wednesday.
|
static int |
WEEKDAYS_IN_MONTH
A constant for weekdays in month component in the period.
|
Constructor and Description |
---|
Period()
Creates a Period.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Returns a copy of this Period.
|
boolean |
equals(java.lang.Object o)
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 |
getMinutesInDay()
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 |
inSchedule(java.util.GregorianCalendar gc)
Checks to see if this object is in schedule based on passed GregorianCalendar.
|
boolean |
isAlwaysExcluded()
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.
|
java.lang.String |
toString()
Returns a string reprensentation of this Period.
|
java.lang.String |
toString(int iType)
Deprecated.
|
public static final int TIME_OF_DAY
public static final int WEEKDAYS_IN_MONTH
public static final int DAYS_IN_MONTH
public static final int MONTHS_IN_YEAR
public static final int MINUTES_IN_DAY
public static final int NUM_OF_INTERVALS
public static final int NUM_OF_MINUTES
public static final int NUM_OF_DAYS_IN_MONTH
public static final int NUM_OF_DAYS_IN_WEEK
public static final int NUM_OF_MONTHS
public static final int SUNDAY
public static final int MONDAY
public static final int TUESDAY
public static final int WEDNESDAY
public static final int THURSDAY
public static final int FRIDAY
public static final int SATURDAY
public static final int FIRST_WEEKDAY_OF_MONTH
public static final int SECOND_WEEKDAY_OF_MONTH
public static final int THIRD_WEEKDAY_OF_MONTH
public static final int FOURTH_WEEKDAY_OF_MONTH
public static final int LAST_WEEKDAY_OF_MONTH
public static final int LAST_DAY_OF_MONTH
public static final int JANUARY
public static final int FEBRUARY
public static final int MARCH
public static final int APRIL
public static final int MAY
public static final int JUNE
public static final int JULY
public static final int AUGUST
public static final int SEPTEMBER
public static final int OCTOBER
public static final int NOVEMBER
public static final int DECEMBER
public Period()
public void include(int component, int index)
component
- the component of this Period.index
- specific period to be included for the specified component.public void exclude(int component, int index)
component
- the component of this Period.index
- specific period to be included for the specified component.public void includeAll(int component)
component
- the component of this Period.public void excludeAll(int component)
component
- the component of this Period.public boolean isIncluded(int component, int index)
component
- the component of this Period.index
- specific period of the specified component.public boolean isAlwaysExcluded()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- Object to compare.public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
public COM.TIBCO.hawk.config.rbengine.schedule.impl.ScheduleMinutesInDay getMinutesInDay()
public java.lang.String toString(int iType)
iType
- the component type of the period.public java.lang.String toString()
toString
in class java.lang.Object
public boolean inSchedule(java.util.GregorianCalendar gc)
inSchedule
in interface Scheduleable
gc
- GregorianCalendar for checking if this Period is in schedule.Copyright © 2000-2019 TIBCO Inc. All Rights Reserved.