Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.quartz
Class DateIntervalTrigger

    java.lang.Object
      org.quartz.Trigger
          org.quartz.DateIntervalTrigger

All Implemented Interfaces:
  Serializable, Cloneable, Comparable

    public class DateIntervalTrigger

extends Trigger

A concrete ``Trigger`` that is used to fire a ``JobDetail`` based upon repeating calendar time intervals.

The trigger will fire every N (see `setRepeatInterval(int)` ) units of calendar time (see `setRepeatIntervalUnit(IntervalUnit)`) as specified in the trigger's definition. This trigger can achieve schedules that are not possible with `SimpleTrigger` (e.g because months are not a fixed number of seconds) or `CronTrigger` (e.g. because "every 5 months" is not an even divisor of 12).

If you use an interval unit of `MONTH` then care should be taken when setting a `startTime` value that is on a day near the end of the month. For example, if you choose a start time that occurs on January 31st, and have a trigger with unit `MONTH` and interval `1`, then the next fire time will be February 28th, and the next time after that will be March 28th - and essentially each subsequent firing will occur on the 28th of the month, even if a 31st day exists. If you want a trigger that always fires on the last day of the month - regardless of the number of days in the month, you should use `CronTrigger`.

Since:
  1.7
Author:
  James House
See Also:
  `Trigger`, `CronTrigger`, `SimpleTrigger`, `NthIncludedDayTrigger`, `TriggerUtils`, Serialized Form

Nested Class Summary
`static class` | `DateIntervalTrigger.IntervalUnit`

Field Summary
`static int` | `MISFIRE_INSTRUCTION_DO_NOTHING` Instructs the ``Scheduler`` that upon a mis-fire situation, the ``DateIntervalTrigger`` wants to have it's next-fire-time updated to the next time in the schedule after the current time (taking into account any associated ``Calendar``, but it does not want to be fired now.
`static int` | `MISFIRE_INSTRUCTION_FIRE_ONCE_NOW` Instructs the ``Scheduler`` that upon a mis-fire situation, the ``DateIntervalTrigger`` wants to be fired now by `Scheduler`.

Fields inherited from class org.quartz.Trigger
`DEFAULT_PRIORITY, INSTRUCTION_DELETE_TRIGGER, INSTRUCTION_NOOP, INSTRUCTION_RE_EXECUTE_JOB, INSTRUCTION_SET_ALL_JOB_TRIGGERS_COMPLETE, INSTRUCTION_SET_ALL_JOB_TRIGGERS_ERROR, INSTRUCTION_SET_TRIGGER_COMPLETE, INSTRUCTION_SET_TRIGGER_ERROR, MISFIRE_INSTRUCTION_SMART_POLICY, STATE_BLOCKED, STATE_COMPLETE, STATE_ERROR, STATE_NONE, STATE_NORMAL, STATE_PAUSED`

Constructor Summary
`DateIntervalTrigger()` Create a `DateIntervalTrigger` with no settings.
`DateIntervalTrigger(String name, Date startTime, Date endTime, DateIntervalTrigger.IntervalUnit intervalUnit, int repeatInterval)` Create a `DateIntervalTrigger` that will occur at the given time, and repeat at the the given interval until the given end time.
`DateIntervalTrigger(String name, DateIntervalTrigger.IntervalUnit intervalUnit, int repeatInterval)` Create a `DateIntervalTrigger` that will occur immediately, and repeat at the the given interval.
`DateIntervalTrigger(String name, String group, Date startTime, Date endTime, DateIntervalTrigger.IntervalUnit intervalUnit, int repeatInterval)` Create a `DateIntervalTrigger` that will occur at the given time, and repeat at the the given interval until the given end time.
`DateIntervalTrigger(String name, String group, DateIntervalTrigger.IntervalUnit intervalUnit, int repeatInterval)` Create a `DateIntervalTrigger` that will occur immediately, and repeat at the the given interval.
`DateIntervalTrigger(String name, String group, String jobName, String jobGroup, Date startTime, Date endTime, DateIntervalTrigger.IntervalUnit intervalUnit, int repeatInterval)` Create a `DateIntervalTrigger` that will occur at the given time, fire the identified `Job` and repeat at the the given interval until the given end time.

Method Summary
`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.
`int` | `executionComplete(JobExecutionContext context, JobExecutionException result)` Called after the ``Scheduler`` has executed the ``JobDetail`` associated with the `Trigger` in order to get the final instruction code from the trigger.
`Date` | `getEndTime()` Get the time at which the `DateIntervalTrigger` should quit repeating.
`Date` | `getFinalFireTime()` Returns the final time at which the `DateIntervalTrigger` will fire, if there is no end time set, null will be returned.
`Date` | `getFireTimeAfter(Date afterTime)` Returns the next time at which the `DateIntervalTrigger` will fire, after the given time.
`protected Date` | `getFireTimeAfter(Date afterTime, boolean ignoreEndTime)`
`Date` | `getNextFireTime()` Returns the next time at which the `Trigger` is scheduled to fire.
`Date` | `getPreviousFireTime()` Returns the previous time at which the `DateIntervalTrigger` fired.
`int` | `getRepeatInterval()` Get the 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.
`DateIntervalTrigger.IntervalUnit` | `getRepeatIntervalUnit()` Get the interval unit - the time unit on with the interval applies.
`Date` | `getStartTime()` Get the time at which the `DateIntervalTrigger` should occur.
`int` | `getTimesTriggered()` Get the number of times the `DateIntervalTrigger` has already fired.
`boolean` | `mayFireAgain()` Determines whether or not the `DateIntervalTrigger` will occur again.
`void` | `setEndTime(Date endTime)` Set the time at which the `DateIntervalTrigger` should quit repeating (and be automatically deleted).
`void` | `setNextFireTime(Date nextFireTime)` Set the next time at which the `DateIntervalTrigger` should fire.
`void` | `setPreviousFireTime(Date previousFireTime)` Set the previous time at which the `DateIntervalTrigger` fired.
`void` | `setRepeatInterval(int repeatInterval)` set the 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.
`void` | `setRepeatIntervalUnit(DateIntervalTrigger.IntervalUnit intervalUnit)` Set the interval unit - the time unit on with the interval applies.
`void` | `setStartTime(Date startTime)` Set the time at which the `DateIntervalTrigger` should occur.
`void` | `setTimesTriggered(int timesTriggered)` Set the number of times the `DateIntervalTrigger` has already fired.
`void` | `triggered(Calendar calendar)` Called when the ``Scheduler`` has decided to 'fire' the trigger (execute the associated `Job`), in order to give the `Trigger` a chance to update itself for its next triggering (if any).
`void` | `updateAfterMisfire(Calendar cal)` Updates the `DateIntervalTrigger`'s state based on the MISFIRE_INSTRUCTION_XXX that was selected when the `DateIntervalTrigger` was created.
`void` | `updateWithNewCalendar(Calendar calendar, long misfireThreshold)` This method should not be used by the Quartz client.
`void` | `validate()` Validates whether the properties of the `JobDetail` are valid for submission into a `Scheduler`.
`protected boolean` | `validateMisfireInstruction(int misfireInstruction)`

Methods inherited from class org.quartz.Trigger
`addTriggerListener, clearAllTriggerListeners, clone, compareTo, equals, getCalendarName, getDescription, getFireInstanceId, getFullJobName, getFullName, getGroup, getJobDataMap, getJobGroup, getJobName, getKey, getMisfireInstruction, getName, getPriority, getTriggerListenerNames, hashCode, isVolatile, removeTriggerListener, setCalendarName, setDescription, setFireInstanceId, setGroup, setJobDataMap, setJobGroup, setJobName, setMisfireInstruction, setName, setPriority, setVolatility, toString`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### MISFIRE_INSTRUCTION_FIRE_ONCE_NOW

    public static final int MISFIRE_INSTRUCTION_FIRE_ONCE_NOW

  Instructs the ``Scheduler`` that upon a mis-fire situation, the ``DateIntervalTrigger`` wants to be fired now by `Scheduler`.

  See Also:
    Constant Field Values

### MISFIRE_INSTRUCTION_DO_NOTHING

    public static final int MISFIRE_INSTRUCTION_DO_NOTHING

  Instructs the ``Scheduler`` that upon a mis-fire situation, the ``DateIntervalTrigger`` wants to have it's next-fire-time updated to the next time in the schedule after the current time (taking into account any associated ``Calendar``, but it does not want to be fired now.

  See Also:
    Constant Field Values

Constructor Detail

### DateIntervalTrigger

    public DateIntervalTrigger()

  Create a `DateIntervalTrigger` with no settings.

### DateIntervalTrigger

    public DateIntervalTrigger(String name,
                               DateIntervalTrigger.IntervalUnit intervalUnit,
                               int repeatInterval)

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

### DateIntervalTrigger

    public DateIntervalTrigger(String name,
                               String group,
                               DateIntervalTrigger.IntervalUnit intervalUnit,
                               int repeatInterval)

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

### DateIntervalTrigger

    public DateIntervalTrigger(String name,
                               Date startTime,
                               Date endTime,
                               DateIntervalTrigger.IntervalUnit intervalUnit,
                               int repeatInterval)

  Create a `DateIntervalTrigger` that will occur at the given time, and repeat at the 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.

### DateIntervalTrigger

    public DateIntervalTrigger(String name,
                               String group,
                               Date startTime,
                               Date endTime,
                               DateIntervalTrigger.IntervalUnit intervalUnit,
                               int repeatInterval)

  Create a `DateIntervalTrigger` that will occur at the given time, and repeat at the 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.

### DateIntervalTrigger

    public DateIntervalTrigger(String name,
                               String group,
                               String jobName,
                               String jobGroup,
                               Date startTime,
                               Date endTime,
                               DateIntervalTrigger.IntervalUnit intervalUnit,
                               int repeatInterval)

  Create a `DateIntervalTrigger` that will occur at the given time, fire the identified `Job` and repeat at the 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 Date getStartTime()

  Get the time at which the `DateIntervalTrigger` should occur.

  Specified by:
    `getStartTime` in class `Trigger`

### setStartTime

    public void setStartTime(Date startTime)

  Set the time at which the `DateIntervalTrigger` should occur.

  Specified by:
    `setStartTime` in class `Trigger`
  Throws:
    `IllegalArgumentException` - if startTime is `null`.

### getEndTime

    public Date getEndTime()

  Get the time at which the `DateIntervalTrigger` should quit repeating.

  Specified by:
    `getEndTime` in class `Trigger`
  See Also:
    `getFinalFireTime()`

### setEndTime

    public void setEndTime(Date endTime)

  Set the time at which the `DateIntervalTrigger` should quit repeating (and be automatically deleted).

  Specified by:
    `setEndTime` in class `Trigger`
  Throws:
    `IllegalArgumentException` - if endTime is before start time.
  See Also:
    `TriggerUtils.computeEndTimeToAllowParticularNumberOfFirings(Trigger, Calendar, int)`

### getRepeatIntervalUnit

    public DateIntervalTrigger.IntervalUnit getRepeatIntervalUnit()

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

### setRepeatIntervalUnit

    public void setRepeatIntervalUnit(DateIntervalTrigger.IntervalUnit intervalUnit)

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

### getRepeatInterval

    public int getRepeatInterval()

  Get the 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.

### setRepeatInterval

    public void setRepeatInterval(int repeatInterval)

  set the 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:
    `IllegalArgumentException` - if repeatInterval is < 1

### getTimesTriggered

    public int getTimesTriggered()

  Get the number of times the `DateIntervalTrigger` has already fired.

### setTimesTriggered

    public void setTimesTriggered(int timesTriggered)

  Set the number of times the `DateIntervalTrigger` has already fired.

### validateMisfireInstruction

    protected boolean validateMisfireInstruction(int misfireInstruction)

  Specified by:
    `validateMisfireInstruction` in class `Trigger`

### 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 class `Trigger`

### triggered

    public void triggered(Calendar calendar)

  Called when the ``Scheduler`` has decided to 'fire' the trigger (execute the associated `Job`), in order to give the `Trigger` a chance to update itself for its next triggering (if any).

  Specified by:
    `triggered` in class `Trigger`
  See Also:
    `executionComplete(JobExecutionContext, JobExecutionException)`

### updateWithNewCalendar

    public void updateWithNewCalendar(Calendar calendar,
                                      long misfireThreshold)

  Description copied from class: `Trigger`

  This method should not be used by the Quartz client.

  To be implemented by the concrete class.

  The implementation should update the `Trigger`'s state based on the given new version of the associated `Calendar` (the state should be updated so that it's next fire time is appropriate given the Calendar's new settings).

  Specified by:
    `updateWithNewCalendar` in class `Trigger`
  See Also:
    `Trigger.updateWithNewCalendar(org.quartz.Calendar, long)`

### computeFirstFireTime

    public 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 class `Trigger`
  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`).

### executionComplete

    public int executionComplete(JobExecutionContext context,
                                 JobExecutionException result)

  Called after the ``Scheduler`` has executed the ``JobDetail`` associated with the `Trigger` in order to get the final instruction code from the trigger.

  Specified by:
    `executionComplete` in class `Trigger`
  Parameters:
    `context` - is the `JobExecutionContext` that was used by the `Job`'s`execute(xx)` method.
    `result` - is the `JobExecutionException` thrown by the `Job`, if any (may be null).
  Returns:
    one of the Trigger.INSTRUCTION_XXX constants.
  See Also:
    `Trigger.INSTRUCTION_NOOP`, `Trigger.INSTRUCTION_RE_EXECUTE_JOB`, `Trigger.INSTRUCTION_DELETE_TRIGGER`, `Trigger.INSTRUCTION_SET_TRIGGER_COMPLETE`, `triggered(Calendar)`

### getNextFireTime

    public 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 class `Trigger`
  See Also:
    `TriggerUtils.computeFireTimesBetween(Trigger, Calendar, Date, Date)`

### getPreviousFireTime

    public 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 class `Trigger`

### setNextFireTime

    public void setNextFireTime(Date nextFireTime)

  Set the next time at which the `DateIntervalTrigger` should fire.

  This method should not be invoked by client code.

### setPreviousFireTime

    public void setPreviousFireTime(Date previousFireTime)

  Set the previous time at which the `DateIntervalTrigger` fired.

  This method should not be invoked by client code.

### getFireTimeAfter

    public Date getFireTimeAfter(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 class `Trigger`

### getFireTimeAfter

    protected Date getFireTimeAfter(Date afterTime,
                                    boolean ignoreEndTime)

### getFinalFireTime

    public 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 class `Trigger`

### mayFireAgain

    public boolean mayFireAgain()

  Determines whether or not the `DateIntervalTrigger` will occur again.

  Specified by:
    `mayFireAgain` in class `Trigger`

### validate

    public void validate()
                  throws SchedulerException

  Validates whether the properties of the `JobDetail` are valid for submission into a `Scheduler`.

  Overrides:
    `validate` in class `Trigger`
  Throws:
    `IllegalStateException` - if a required property (such as Name, Group, Class) is not set.
    `SchedulerException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 2001-2012, Terracotta, Inc.