Class ScheduleTrigger
- All Implemented Interfaces:
Serializable
Examples:
To define a schedule trigger that runs once at a specified time:
ScheduleTrigger trigger = new ScheduleTrigger();
trigger.setTriggerType(TriggerType.ONCE);
trigger.setStartDate(todayDate);
To define a schedule trigger that runs every two days with a scheduled end date:
ScheduleTrigger trigger = new ScheduleTrigger();
trigger.setTriggerType(TriggerType.DAILY);
trigger.setStartDate(startDate);
trigger.setInterval(2);
trigger.setEndDate(endDate);
To define a schedule trigger that runs every week on Monday for the next eight weeks:
ScheduleTrigger trigger = new ScheduleTrigger();
trigger.setTriggerType(TriggerType.WEEKLY);
trigger.setStartDate(todayDate);
List
daysOfWeek.add(DayOfWeek.MON);
trigger.setDaysOfWeek(daysOfWeek);
trigger.setNumOccurrences(8);
To define a schedule trigger that runs every five minutes indefinitely:
ScheduleTrigger trigger = new ScheduleTrigger();
trigger.setTriggerType(TriggerType.MINUTELY);
trigger.setStartDate(todayDate);
trigger.setInterval(5);
trigger.setRepeatForever(true);
There are several options to define how or whether a recurring schedule ends. Here is the order in which the options take precedence: if repeat forever is set to True, that takes precedence, and the other options are ignored. If repeat forever is False, and numOccurrences is specified, the endDate is ignored.
repeatForever numOccurrences endDate
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe days of a week to use in weekly schedules.static enumThe intervals in which the schedule runs. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanFor WEEKLY trigger types, gets the days of the week on which the schedule executes.Gets the end date and time of the schedule that specifies when the schedule stops executing.intGets the interval number for the schedule.intGets the number of times to execute the schedule.booleanIndicates whether to repeat the schedule indefinitely.Gets the start date and time of the schedule.Gets the trigger type for the schedule.inthashCode()voidsetDaysOfWeek(Set<ScheduleTrigger.DayOfWeek> daysOfWeek) Sets the days of the week.voidsetEndDate(Date endDate) Sets the end date and time of the schedule.voidsetInterval(int interval) Sets the interval number for the schedule.voidsetNumOccurrences(int numOccurrences) Sets the number of times to execute the schedule.voidsetRepeatForever(boolean repeatForever) Sets whether to repeat the schedule indefinitely.voidsetStartDate(Date startDate) Sets the start date and time of the schedule.voidsetTriggerType(ScheduleTrigger.TriggerType triggerType) Sets the trigger type for the schedule.toString()
-
Constructor Details
-
ScheduleTrigger
public ScheduleTrigger()
-
-
Method Details
-
getStartDate
Gets the start date and time of the schedule.- Returns:
- The start date and time.
-
setStartDate
Sets the start date and time of the schedule.- Parameters:
startDate- the start date and time.
-
getEndDate
Gets the end date and time of the schedule that specifies when the schedule stops executing.- Returns:
- The end date and time.
-
setEndDate
Sets the end date and time of the schedule. For a recurring schedule, if the end date is not null, and the numOccurrences value is greater than 0, the numOccurrences value is honored first. The end date cannot be null if repeatForever is False and numOccurrences is not set or is 0.- Parameters:
endDate- the end date.
-
getRepeatForever
public boolean getRepeatForever()Indicates whether to repeat the schedule indefinitely. The default is False. This applies only to the recurring TriggerTypes MINUTELY, HOURLY, and DAILY.- Returns:
- True, if the schedule repeats forever, false otherwise.
-
setRepeatForever
public void setRepeatForever(boolean repeatForever) Sets whether to repeat the schedule indefinitely. The default is False. This applies to the recurring TriggerTypes MINUTELY, HOURLY, DAILY, or WEEKLY.- Parameters:
repeatForever- the indicator to repeat forever.
-
getInterval
public int getInterval()Gets the interval number for the schedule. For example, if TriggerType is DAILY, and interval is 2, it will run every 2 days.- Returns:
- The interval.
-
setInterval
public void setInterval(int interval) Sets the interval number for the schedule. For example, if TriggerType is DAILY, and interval is 2, it will run every 2 days. The value must be greater than 1 if the recurring TriggerType is MINUTELY, HOURLY, or DAILY.- Parameters:
interval- The interval to set.
-
getTriggerType
Gets the trigger type for the schedule.- Returns:
- The trigger type.
-
setTriggerType
Sets the trigger type for the schedule.- Parameters:
triggerType- the trigger type.
-
getNumOccurrences
public int getNumOccurrences()Gets the number of times to execute the schedule. For a recurring schedule, if the end date is not null and the numOccurrences value is greater than 0, the numOccurrences value is honored first.- Returns:
- The number of times.
-
setNumOccurrences
public void setNumOccurrences(int numOccurrences) Sets the number of times to execute the schedule. For a recurring schedule, if the end date is not null and the numOccurrences value is greater than 0, the numOccurrences value is honored first.- Parameters:
numOccurrences- the number of times.
-
getDaysOfWeek
For WEEKLY trigger types, gets the days of the week on which the schedule executes. For other trigger types, this value is ignored.- Returns:
- The days of the week.
-
setDaysOfWeek
Sets the days of the week. This value cannot be null or empty, if TriggerType is WEEKLY. For other trigger types, this value is ignored.- Parameters:
daysOfWeek- the days of the week.
-
hashCode
public int hashCode() -
equals
-
toString
-