public class ScheduleTrigger extends Object implements 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
Modifier and Type | Class and Description |
---|---|
static class |
ScheduleTrigger.DayOfWeek
The days of a week to use in weekly schedules.
|
static class |
ScheduleTrigger.TriggerType
The intervals in which the schedule runs.
|
Constructor and Description |
---|
ScheduleTrigger() |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
Set<ScheduleTrigger.DayOfWeek> |
getDaysOfWeek()
For WEEKLY trigger types, gets the days of the week on which the schedule executes.
|
Date |
getEndDate()
Gets the end date and time of the schedule that specifies when the schedule stops executing.
|
int |
getInterval()
Gets the interval number for the schedule.
|
int |
getNumOccurrences()
Gets the number of times to execute the schedule.
|
boolean |
getRepeatForever()
Indicates whether to repeat the schedule indefinitely.
|
Date |
getStartDate()
Gets the start date and time of the schedule.
|
ScheduleTrigger.TriggerType |
getTriggerType()
Gets the trigger type for the schedule.
|
int |
hashCode() |
void |
setDaysOfWeek(Set<ScheduleTrigger.DayOfWeek> daysOfWeek)
Sets the days of the week.
|
void |
setEndDate(Date endDate)
Sets the end date and time of the schedule.
|
void |
setInterval(int interval)
Sets the interval number for the schedule.
|
void |
setNumOccurrences(int numOccurrences)
Sets the number of times to execute the schedule.
|
void |
setRepeatForever(boolean repeatForever)
Sets whether to repeat the schedule indefinitely.
|
void |
setStartDate(Date startDate)
Sets the start date and time of the schedule.
|
void |
setTriggerType(ScheduleTrigger.TriggerType triggerType)
Sets the trigger type for the schedule.
|
String |
toString() |
public Date getStartDate()
public void setStartDate(Date startDate)
startDate
- the start date and time.public Date getEndDate()
public void setEndDate(Date endDate)
endDate
- the end date.public boolean getRepeatForever()
public void setRepeatForever(boolean repeatForever)
repeatForever
- the indicator to repeat forever.public int getInterval()
public void setInterval(int interval)
interval
- The interval to set.public ScheduleTrigger.TriggerType getTriggerType()
public void setTriggerType(ScheduleTrigger.TriggerType triggerType)
triggerType
- the trigger type.public int getNumOccurrences()
public void setNumOccurrences(int numOccurrences)
numOccurrences
- the number of times.public Set<ScheduleTrigger.DayOfWeek> getDaysOfWeek()
public void setDaysOfWeek(Set<ScheduleTrigger.DayOfWeek> daysOfWeek)
daysOfWeek
- the days of the week.Copyright (c) 2020, SAS Institute Inc., Cary, NC, USA