Class ScheduleTrigger

java.lang.Object
com.sas.lsaf.schedule.ScheduleTrigger
All Implemented Interfaces:
Serializable

public class ScheduleTrigger extends Object implements Serializable
The class that defines when a schedule runs.

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 = new ArrayList();
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:
    • Constructor Details

      • ScheduleTrigger

        public ScheduleTrigger()
    • Method Details

      • getStartDate

        public Date getStartDate()
        Gets the start date and time of the schedule.
        Returns:
        The start date and time.
      • setStartDate

        public void setStartDate(Date startDate)
        Sets the start date and time of the schedule.
        Parameters:
        startDate - the start date and time.
      • getEndDate

        public Date getEndDate()
        Gets the end date and time of the schedule that specifies when the schedule stops executing.
        Returns:
        The end date and time.
      • setEndDate

        public void setEndDate(Date endDate)
        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

        public ScheduleTrigger.TriggerType getTriggerType()
        Gets the trigger type for the schedule.
        Returns:
        The trigger type.
      • setTriggerType

        public void setTriggerType(ScheduleTrigger.TriggerType triggerType)
        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

        public Set<ScheduleTrigger.DayOfWeek> 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

        public void setDaysOfWeek(Set<ScheduleTrigger.DayOfWeek> daysOfWeek)
        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()
        Overrides:
        hashCode in class Object
      • equals

        public boolean equals(Object obj)
        Overrides:
        equals in class Object
      • toString

        public String toString()
        Overrides:
        toString in class Object