Class CalendarIntervalTriggerImpl

    • Constructor Detail

      • CalendarIntervalTriggerImpl

        public CalendarIntervalTriggerImpl()

        Create a DateIntervalTrigger with no settings.

      • CalendarIntervalTriggerImpl

        public CalendarIntervalTriggerImpl​(java.lang.String name,
                                           DateBuilder.IntervalUnit intervalUnit,
                                           int repeatInterval)

        Create a DateIntervalTrigger that will occur immediately, and repeat at the given interval.

      • CalendarIntervalTriggerImpl

        public CalendarIntervalTriggerImpl​(java.lang.String name,
                                           java.lang.String group,
                                           DateBuilder.IntervalUnit intervalUnit,
                                           int repeatInterval)

        Create a DateIntervalTrigger that will occur immediately, and repeat at the given interval.

      • CalendarIntervalTriggerImpl

        public CalendarIntervalTriggerImpl​(java.lang.String name,
                                           java.util.Date startTime,
                                           java.util.Date endTime,
                                           DateBuilder.IntervalUnit intervalUnit,
                                           int repeatInterval)

        Create a DateIntervalTrigger that will occur at the given time, and repeat at the given interval until the given end time.

        Parameters:
        startTime - A Date set to the time for the Trigger to fire.
        endTime - A Date set to the time for the Trigger to quit repeat firing.
        intervalUnit - The repeat interval unit (minutes, days, months, etc).
        repeatInterval - The number of milliseconds to pause between the repeat firing.
      • CalendarIntervalTriggerImpl

        public CalendarIntervalTriggerImpl​(java.lang.String name,
                                           java.lang.String group,
                                           java.util.Date startTime,
                                           java.util.Date endTime,
                                           DateBuilder.IntervalUnit intervalUnit,
                                           int repeatInterval)

        Create a DateIntervalTrigger that will occur at the given time, and repeat at the given interval until the given end time.

        Parameters:
        startTime - A Date set to the time for the Trigger to fire.
        endTime - A Date set to the time for the Trigger to quit repeat firing.
        intervalUnit - The repeat interval unit (minutes, days, months, etc).
        repeatInterval - The number of milliseconds to pause between the repeat firing.
      • CalendarIntervalTriggerImpl

        public CalendarIntervalTriggerImpl​(java.lang.String name,
                                           java.lang.String group,
                                           java.lang.String jobName,
                                           java.lang.String jobGroup,
                                           java.util.Date startTime,
                                           java.util.Date endTime,
                                           DateBuilder.IntervalUnit intervalUnit,
                                           int repeatInterval)

        Create a DateIntervalTrigger that will occur at the given time, fire the identified Job and repeat at the given interval until the given end time.

        Parameters:
        startTime - A Date set to the time for the Trigger to fire.
        endTime - A Date set to the time for the Trigger to quit repeat firing.
        intervalUnit - The repeat interval unit (minutes, days, months, etc).
        repeatInterval - The number of milliseconds to pause between the repeat firing.
    • Method Detail

      • getStartTime

        public java.util.Date getStartTime()

        Get the time at which the DateIntervalTrigger should occur.

        Specified by:
        getStartTime in interface Trigger
      • setStartTime

        public void setStartTime​(java.util.Date startTime)

        Set the time at which the DateIntervalTrigger should occur.

        Specified by:
        setStartTime in interface MutableTrigger
        Throws:
        java.lang.IllegalArgumentException - if startTime is null.
      • getEndTime

        public java.util.Date getEndTime()

        Get the time at which the DateIntervalTrigger should quit repeating.

        Specified by:
        getEndTime in interface Trigger
        See Also:
        getFinalFireTime()
      • setRepeatIntervalUnit

        public void setRepeatIntervalUnit​(DateBuilder.IntervalUnit intervalUnit)

        Set the interval unit - the time unit on with the interval applies.

      • getRepeatInterval

        public int getRepeatInterval()
        Description copied from interface: CalendarIntervalTrigger

        Get the time interval that will be added to the DateIntervalTrigger's fire time (in the set repeat interval unit) in order to calculate the time of the next trigger repeat.

        Specified by:
        getRepeatInterval in interface CalendarIntervalTrigger
      • setRepeatInterval

        public void setRepeatInterval​(int repeatInterval)

        set the time interval that will be added to the DateIntervalTrigger's fire time (in the set repeat interval unit) in order to calculate the time of the next trigger repeat.

        Throws:
        java.lang.IllegalArgumentException - if repeatInterval is < 1
      • getTimeZone

        public java.util.TimeZone getTimeZone()
        Description copied from interface: CalendarIntervalTrigger

        Gets the time zone within which time calculations related to this trigger will be performed.

        If null, the system default TimeZone will be used.

        Specified by:
        getTimeZone in interface CalendarIntervalTrigger
      • setTimeZone

        public void setTimeZone​(java.util.TimeZone timeZone)

        Sets the time zone within which time calculations related to this trigger will be performed.

        Parameters:
        timeZone - the desired TimeZone, or null for the system default.
      • isPreserveHourOfDayAcrossDaylightSavings

        public boolean isPreserveHourOfDayAcrossDaylightSavings()
        If intervals are a day or greater, this property (set to true) will cause the firing of the trigger to always occur at the same time of day, (the time of day of the startTime) regardless of daylight saving time transitions. Default value is false.

        For example, without the property set, your trigger may have a start time of 9:00 am on March 1st, and a repeat interval of 2 days. But after the daylight saving transition occurs, the trigger may start firing at 8:00 am every other day.

        If however, the time of day does not exist on a given day to fire (e.g. 2:00 am in the United States on the days of daylight saving transition), the trigger will go ahead and fire one hour off on that day, and then resume the normal hour on other days. If you wish for the trigger to never fire at the "wrong" hour, then you should set the property skipDayIfHourDoesNotExist.

        Specified by:
        isPreserveHourOfDayAcrossDaylightSavings in interface CalendarIntervalTrigger
        See Also:
        isSkipDayIfHourDoesNotExist(), getStartTime(), getTimeZone()
      • setPreserveHourOfDayAcrossDaylightSavings

        public void setPreserveHourOfDayAcrossDaylightSavings​(boolean preserveHourOfDayAcrossDaylightSavings)
      • isSkipDayIfHourDoesNotExist

        public boolean isSkipDayIfHourDoesNotExist()
        If intervals are a day or greater, and preserveHourOfDayAcrossDaylightSavings property is set to true, and the hour of the day does not exist on a given day for which the trigger would fire, the day will be skipped and the trigger advanced a second interval if this property is set to true. Defaults to false.

        CAUTION! If you enable this property, and your hour of day happens to be that of daylight savings transition (e.g. 2:00 am in the United States) and the trigger's interval would have had the trigger fire on that day, then you may actually completely miss a firing on the day of transition if that hour of day does not exist on that day! In such a case the next fire time of the trigger will be computed as double (if the interval is 2 days, then a span of 4 days between firings will occur).

        Specified by:
        isSkipDayIfHourDoesNotExist in interface CalendarIntervalTrigger
        See Also:
        isPreserveHourOfDayAcrossDaylightSavings()
      • setSkipDayIfHourDoesNotExist

        public void setSkipDayIfHourDoesNotExist​(boolean skipDayIfHourDoesNotExist)
      • setTimesTriggered

        public void setTimesTriggered​(int timesTriggered)

        Set the number of times the DateIntervalTrigger has already fired.

      • updateAfterMisfire

        public void updateAfterMisfire​(Calendar cal)

        Updates the DateIntervalTrigger's state based on the MISFIRE_INSTRUCTION_XXX that was selected when the DateIntervalTrigger was created.

        If the misfire instruction is set to MISFIRE_INSTRUCTION_SMART_POLICY, then the following scheme will be used:

        • The instruction will be interpreted as MISFIRE_INSTRUCTION_FIRE_ONCE_NOW
        Specified by:
        updateAfterMisfire in interface OperableTrigger
      • computeFirstFireTime

        public java.util.Date computeFirstFireTime​(Calendar calendar)

        Called by the scheduler at the time a Trigger is first added to the scheduler, in order to have the Trigger compute its first fire time, based on any associated calendar.

        After this method has been called, getNextFireTime() should return a valid answer.

        Specified by:
        computeFirstFireTime in interface OperableTrigger
        Returns:
        the first time at which the Trigger will be fired by the scheduler, which is also the same value getNextFireTime() will return (until after the first firing of the Trigger).
      • getNextFireTime

        public java.util.Date getNextFireTime()

        Returns the next time at which the Trigger is scheduled to fire. If the trigger will not fire again, null will be returned. Note that the time returned can possibly be in the past, if the time that was computed for the trigger to next fire has already arrived, but the scheduler has not yet been able to fire the trigger (which would likely be due to lack of resources e.g. threads).

        The value returned is not guaranteed to be valid until after the Trigger has been added to the scheduler.

        Specified by:
        getNextFireTime in interface Trigger
        See Also:
        TriggerUtils.computeFireTimesBetween(org.quartz.spi.OperableTrigger, Calendar, java.util.Date, java.util.Date)
      • getPreviousFireTime

        public java.util.Date getPreviousFireTime()

        Returns the previous time at which the DateIntervalTrigger fired. If the trigger has not yet fired, null will be returned.

        Specified by:
        getPreviousFireTime in interface Trigger
      • setNextFireTime

        public void setNextFireTime​(java.util.Date nextFireTime)

        Set the next time at which the DateIntervalTrigger should fire.

        This method should not be invoked by client code.

        Specified by:
        setNextFireTime in interface OperableTrigger
      • setPreviousFireTime

        public void setPreviousFireTime​(java.util.Date previousFireTime)

        Set the previous time at which the DateIntervalTrigger fired.

        This method should not be invoked by client code.

        Specified by:
        setPreviousFireTime in interface OperableTrigger
      • getFireTimeAfter

        public java.util.Date getFireTimeAfter​(java.util.Date afterTime)

        Returns the next time at which the DateIntervalTrigger will fire, after the given time. If the trigger will not fire after the given time, null will be returned.

        Specified by:
        getFireTimeAfter in interface Trigger
      • getFireTimeAfter

        protected java.util.Date getFireTimeAfter​(java.util.Date afterTime,
                                                  boolean ignoreEndTime)
      • getFinalFireTime

        public java.util.Date getFinalFireTime()

        Returns the final time at which the DateIntervalTrigger will fire, if there is no end time set, null will be returned.

        Note that the return time may be in the past.

        Specified by:
        getFinalFireTime in interface Trigger
      • mayFireAgain

        public boolean mayFireAgain()

        Determines whether or not the DateIntervalTrigger will occur again.

        Specified by:
        mayFireAgain in interface Trigger