Class ScheduleTrigger

  • All Implemented Interfaces:
    java.io.Serializable

    public class ScheduleTrigger
    extends java.lang.Object
    implements java.io.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:
    Serialized Form
    • Constructor Detail

      • ScheduleTrigger

        public ScheduleTrigger()
    • Method Detail

      • getStartDate

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

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

        public java.util.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​(java.util.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 java.util.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​(java.util.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 java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object