public class DailyTimeIntervalTrigger extends AbstractTrigger<DailyTimeIntervalTrigger> implements IDailyTimeIntervalTrigger
IJobDetail based upon daily repeating
time intervals.
The trigger will fire every N (see setRepeatInterval(int) ) seconds,
minutes or hours (see setRepeatIntervalUnit(EIntervalUnit)) during a
given time window on specified days of the week.
For example#1, a trigger can be set to fire every 72 minutes between 8:00 and 11:00 everyday. It's fire times would be 8:00, 9:12, 10:24, then next day would repeat: 8:00, 9:12, 10:24 again.
For example#2, a trigger can be set to fire every 23 minutes between 9:20 and 16:47 Monday through Friday.
On each day, the starting fire time is reset to startTimeOfDay value, and then it will add repeatInterval value to it until the endTimeOfDay is reached. If you set daysOfWeek values, then fire time will only occur during those week days period. Again, remember this trigger will reset fire time each day with startTimeOfDay, regardless of your interval or endTimeOfDay!
The default values for fields if not set are: startTimeOfDay defaults to 00:00:00, the endTimeOfDay default to 23:59:59, and daysOfWeek is default to every day. The startTime default to current time-stamp now, while endTime has not value.
If startTime is before startTimeOfDay, then startTimeOfDay will be used and startTime has no affect other than to specify the first day of firing. Else if startTime is after startTimeOfDay, then the first fire time for that day will be the next interval after the startTime. For example, if you set startingTimeOfDay=9am, endingTimeOfDay=11am, interval=15 mins, and startTime=9:33am, then the next fire time will be 9:45pm. Note also that if you do not set startTime value, the trigger builder will default to current time, and current time maybe before or after the startTimeOfDay! So be aware how you set your startTime.
This trigger also supports "repeatCount" feature to end the trigger fire time after a certain number of count is reached. Just as the SimpleTrigger, setting repeatCount=0 means trigger will fire once only! Setting any positive count then the trigger will repeat count + 1 times. Unlike SimpleTrigger, the default value of repeatCount of this trigger is set to REPEAT_INDEFINITELY instead of 0 though.
IDailyTimeIntervalTrigger,
DailyTimeIntervalScheduleBuilderITrigger.ECompletedExecutionInstruction, ITrigger.EMisfireInstruction, ITrigger.ETriggerStateREPEAT_INDEFINITELYDEFAULT_PRIORITY| Constructor and Description |
|---|
DailyTimeIntervalTrigger()
Create a
DailyTimeIntervalTrigger with no settings. |
DailyTimeIntervalTrigger(DailyTimeIntervalTrigger aOther) |
DailyTimeIntervalTrigger(String name,
Date startTime,
Date endTime,
LocalTime startTimeOfDay,
LocalTime endTimeOfDay,
EIntervalUnit intervalUnit,
int repeatInterval)
Create a
DailyTimeIntervalTrigger that will occur at the given
time, and repeat at the the given interval until the given end time. |
DailyTimeIntervalTrigger(String name,
LocalTime startTimeOfDay,
LocalTime endTimeOfDay,
EIntervalUnit intervalUnit,
int repeatInterval)
Create a
DailyTimeIntervalTrigger that will occur immediately,
and repeat at the the given interval. |
DailyTimeIntervalTrigger(String name,
String group,
Date startTime,
Date endTime,
LocalTime startTimeOfDay,
LocalTime endTimeOfDay,
EIntervalUnit intervalUnit,
int repeatInterval)
Create a
DailyTimeIntervalTrigger that will occur at the given
time, and repeat at the the given interval until the given end time. |
DailyTimeIntervalTrigger(String name,
String group,
LocalTime startTimeOfDay,
LocalTime endTimeOfDay,
EIntervalUnit intervalUnit,
int repeatInterval)
Create a
DailyTimeIntervalTrigger that will occur immediately,
and repeat at the the given interval. |
DailyTimeIntervalTrigger(String name,
String group,
String jobName,
String jobGroup,
Date startTime,
Date endTime,
LocalTime startTimeOfDay,
LocalTime endTimeOfDay,
EIntervalUnit intervalUnit,
int repeatInterval)
Create a
DailyTimeIntervalTrigger that will occur at the given
time, fire the identified Job and repeat at the the given
interval until the given end time. |
| Modifier and Type | Method and Description |
|---|---|
Date |
computeFirstFireTime(ICalendar 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. |
boolean |
equals(Object o)
Trigger equality is based upon the equality of the TriggerKey.
|
DailyTimeIntervalTrigger |
getClone() |
Set<DayOfWeek> |
getDaysOfWeek()
The days of the week upon which to fire.
|
Date |
getEndTime()
Get the time at which the
Trigger should quit repeating -
regardless of any remaining repeats (based on the trigger's particular
repeat settings). |
LocalTime |
getEndTimeOfDay()
The time of day to complete firing at the given interval.
|
Date |
getFinalFireTime()
Returns the final time at which the
DailyTimeIntervalTrigger
will fire, if there is no end time set, null will be returned. |
Date |
getFireTimeAfter(Date aAfterTime)
Returns the next time at which the
DailyTimeIntervalTrigger
will fire, after the given time. |
Date |
getNextFireTime()
Returns the next time at which the
Trigger is scheduled to
fire. |
Date |
getPreviousFireTime()
Returns the previous time at which the
DailyTimeIntervalTrigger fired. |
int |
getRepeatCount()
Get the the number of times for interval this trigger should repeat, after
which it will be automatically deleted.
|
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. |
EIntervalUnit |
getRepeatIntervalUnit()
Get the interval unit - the time unit on with the interval applies.
|
IScheduleBuilder<DailyTimeIntervalTrigger> |
getScheduleBuilder()
Get a
IScheduleBuilder that is configured to produce a schedule
identical to this trigger's schedule. |
Date |
getStartTime()
Get the time at which the
Trigger should occur. |
LocalTime |
getStartTimeOfDay()
The time of day to start firing at the given interval.
|
int |
getTimesTriggered()
Get the number of times the
DateIntervalTrigger has already
fired. |
int |
hashCode() |
boolean |
mayFireAgain()
Determines whether or not the
DailyTimeIntervalTrigger will
occur again. |
void |
setDaysOfWeek(Set<DayOfWeek> daysOfWeek) |
void |
setEndTime(Date endTime)
Set the time at which the
Trigger should quit repeating -
regardless of any remaining repeats (based on the trigger's particular
repeat settings). |
void |
setEndTimeOfDay(LocalTime aEndTimeOfDay) |
void |
setNextFireTime(Date nextFireTime)
Set the next time at which the
DailyTimeIntervalTrigger should
fire. |
void |
setPreviousFireTime(Date previousFireTime)
Set the previous time at which the
DailyTimeIntervalTrigger
fired. |
void |
setRepeatCount(int repeatCount) |
void |
setRepeatInterval(int repeatInterval)
set the the time interval that will be added to the
DailyTimeIntervalTrigger's fire time (in the set repeat
interval unit) in order to calculate the time of the next trigger repeat. |
void |
setRepeatIntervalUnit(EIntervalUnit intervalUnit)
Set the interval unit - the time unit on with the interval applies.
|
void |
setStartTime(Date startTime)
The time at which the trigger's scheduling should start.
|
void |
setStartTimeOfDay(LocalTime startTimeOfDay) |
void |
setTimesTriggered(int timesTriggered)
Set the number of times the
DailyTimeIntervalTrigger has
already fired. |
void |
triggered(ICalendar calendar)
Called when the
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(ICalendar cal)
Updates the
DailyTimeIntervalTrigger's state based on the
MISFIRE_INSTRUCTION_XXX that was selected when the
DailyTimeIntervalTrigger was created. |
void |
updateWithNewCalendar(ICalendar 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(ITrigger.EMisfireInstruction misfireInstruction) |
compareTo, executionComplete, getCalendarName, getDescription, getFireInstanceId, getFullJobName, getFullName, getGroup, getJobDataMap, getJobGroup, getJobKey, getJobName, getKey, getMisfireInstruction, getName, getPriority, getTriggerBuilder, setCalendarName, setDescription, setFireInstanceId, setGroup, setJobDataMap, setJobGroup, setJobKey, setJobName, setKey, setMisfireInstruction, setName, setPriority, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetTriggerBuildercompareTo, getCalendarName, getDescription, getJobDataMap, getJobKey, getKey, getMisfireInstruction, getPrioritypublic DailyTimeIntervalTrigger(@Nonnull DailyTimeIntervalTrigger aOther)
public DailyTimeIntervalTrigger()
DailyTimeIntervalTrigger with no settings.public DailyTimeIntervalTrigger(String name, LocalTime startTimeOfDay, LocalTime endTimeOfDay, EIntervalUnit intervalUnit, int repeatInterval)
Create a DailyTimeIntervalTrigger that will occur immediately,
and repeat at the the given interval.
startTimeOfDay - The LocalTime that the repeating should begin
occurring.endTimeOfDay - The LocalTime that the repeating should stop occurring.intervalUnit - The repeat interval unit. The only intervals that are valid for this
type of trigger are EIntervalUnit.SECOND,
EIntervalUnit.MINUTE, and EIntervalUnit.HOUR.IllegalArgumentException - if an invalid IntervalUnit is given, or the repeat interval is zero
or less.public DailyTimeIntervalTrigger(String name, String group, LocalTime startTimeOfDay, LocalTime endTimeOfDay, EIntervalUnit intervalUnit, int repeatInterval)
Create a DailyTimeIntervalTrigger that will occur immediately,
and repeat at the the given interval.
startTimeOfDay - The LocalTime that the repeating should begin
occurring.endTimeOfDay - The LocalTime that the repeating should stop occurring.intervalUnit - The repeat interval unit. The only intervals that are valid for this
type of trigger are EIntervalUnit.SECOND,
EIntervalUnit.MINUTE, and EIntervalUnit.HOUR.IllegalArgumentException - if an invalid IntervalUnit is given, or the repeat interval is zero
or less.public DailyTimeIntervalTrigger(String name, Date startTime, Date endTime, LocalTime startTimeOfDay, LocalTime endTimeOfDay, EIntervalUnit intervalUnit, int repeatInterval)
Create a DailyTimeIntervalTrigger that will occur at the given
time, and repeat at the the given interval until the given end time.
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.startTimeOfDay - The LocalTime that the repeating should begin
occurring.endTimeOfDay - The LocalTime that the repeating should stop occurring.intervalUnit - The repeat interval unit. The only intervals that are valid for this
type of trigger are EIntervalUnit.SECOND,
EIntervalUnit.MINUTE, and EIntervalUnit.HOUR.repeatInterval - The number of milliseconds to pause between the repeat firing.IllegalArgumentException - if an invalid IntervalUnit is given, or the repeat interval is zero
or less.public DailyTimeIntervalTrigger(String name, String group, Date startTime, Date endTime, LocalTime startTimeOfDay, LocalTime endTimeOfDay, EIntervalUnit intervalUnit, int repeatInterval)
Create a DailyTimeIntervalTrigger that will occur at the given
time, and repeat at the the given interval until the given end time.
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.startTimeOfDay - The LocalTime that the repeating should begin
occurring.endTimeOfDay - The LocalTime that the repeating should stop occurring.intervalUnit - The repeat interval unit. The only intervals that are valid for this
type of trigger are EIntervalUnit.SECOND,
EIntervalUnit.MINUTE, and EIntervalUnit.HOUR.repeatInterval - The number of milliseconds to pause between the repeat firing.IllegalArgumentException - if an invalid IntervalUnit is given, or the repeat interval is zero
or less.public DailyTimeIntervalTrigger(String name, String group, String jobName, String jobGroup, Date startTime, Date endTime, LocalTime startTimeOfDay, LocalTime endTimeOfDay, EIntervalUnit intervalUnit, int repeatInterval)
Create a DailyTimeIntervalTrigger that will occur at the given
time, fire the identified Job and repeat at the the given
interval until the given end time.
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.startTimeOfDay - The LocalTime that the repeating should begin
occurring.endTimeOfDay - The LocalTime that the repeating should stop occurring.intervalUnit - The repeat interval unit. The only intervals that are valid for this
type of trigger are EIntervalUnit.SECOND,
EIntervalUnit.MINUTE, and EIntervalUnit.HOUR.repeatInterval - The number of milliseconds to pause between the repeat firing.IllegalArgumentException - if an invalid IntervalUnit is given, or the repeat interval is zero
or less.@Nonnull public final Date getStartTime()
ITriggerTrigger should occur.getStartTime in interface ITriggernull depending on the implementationpublic final void setStartTime(@Nonnull Date startTime)
IMutableTriggersetStartTime in interface IMutableTriggerstartTime - start time@Nullable public final Date getEndTime()
ITriggerTrigger should quit repeating -
regardless of any remaining repeats (based on the trigger's particular
repeat settings).getEndTime in interface ITriggernull.ITrigger.getFinalFireTime()public final void setEndTime(@Nullable Date endTime)
IMutableTrigger
Set the time at which the Trigger should quit repeating -
regardless of any remaining repeats (based on the trigger's particular
repeat settings).
setEndTime in interface IMutableTriggerTriggerUtils.computeEndTimeToAllowParticularNumberOfFirings(IOperableTrigger,com.helger.quartz.ICalendar,int)public EIntervalUnit getRepeatIntervalUnit()
IDailyTimeIntervalTriggerEIntervalUnit.SECOND, EIntervalUnit.MINUTE, and
EIntervalUnit.HOUR.getRepeatIntervalUnit in interface IDailyTimeIntervalTriggerpublic void setRepeatIntervalUnit(EIntervalUnit intervalUnit)
Set the interval unit - the time unit on with the interval applies.
intervalUnit - The repeat interval unit. The only intervals that are valid for this
type of trigger are EIntervalUnit.SECOND,
EIntervalUnit.MINUTE, and EIntervalUnit.HOUR.public int getRepeatInterval()
IDailyTimeIntervalTriggerDateIntervalTrigger's fire time (in the set repeat interval
unit) in order to calculate the time of the next trigger repeat.getRepeatInterval in interface IDailyTimeIntervalTriggerpublic void setRepeatInterval(int repeatInterval)
set the the time interval that will be added to the
DailyTimeIntervalTrigger's fire time (in the set repeat
interval unit) in order to calculate the time of the next trigger repeat.
IllegalArgumentException - if repeatInterval is < 0public int getTimesTriggered()
IDailyTimeIntervalTriggerDateIntervalTrigger has already
fired.getTimesTriggered in interface IDailyTimeIntervalTriggerpublic void setTimesTriggered(int timesTriggered)
Set the number of times the DailyTimeIntervalTrigger has
already fired.
protected boolean validateMisfireInstruction(ITrigger.EMisfireInstruction misfireInstruction)
validateMisfireInstruction in class AbstractTrigger<DailyTimeIntervalTrigger>public void updateAfterMisfire(ICalendar cal)
Updates the DailyTimeIntervalTrigger's state based on the
MISFIRE_INSTRUCTION_XXX that was selected when the
DailyTimeIntervalTrigger was created.
If the misfire instruction is set to MISFIRE_INSTRUCTION_SMART_POLICY, then
the following scheme will be used:
MISFIRE_INSTRUCTION_FIRE_ONCE_NOWupdateAfterMisfire in interface IOperableTriggerpublic void triggered(ICalendar calendar)
IScheduler 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).triggered in interface IOperableTriggerAbstractTrigger.executionComplete(com.helger.quartz.IJobExecutionContext,
com.helger.quartz.JobExecutionException)public void updateWithNewCalendar(ICalendar calendar, long misfireThreshold)
IOperableTriggerTrigger'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).updateWithNewCalendar in interface IOperableTriggerIOperableTrigger.updateWithNewCalendar(com.helger.quartz.ICalendar,
long)public Date computeFirstFireTime(ICalendar 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.
computeFirstFireTime in interface IOperableTriggerTrigger will be fired by
the scheduler, which is also the same value
getNextFireTime() will return (until after the first
firing of the Trigger).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.
getNextFireTime in interface ITriggerTriggerUtils.computeFireTimesBetween(com.helger.quartz.spi.IOperableTrigger,
ICalendar, Date, Date)public Date getPreviousFireTime()
Returns the previous time at which the
DailyTimeIntervalTrigger fired. If the trigger has not yet
fired, null will be returned.
getPreviousFireTime in interface ITriggerpublic void setNextFireTime(Date nextFireTime)
Set the next time at which the DailyTimeIntervalTrigger should
fire.
This method should not be invoked by client code.
setNextFireTime in interface IOperableTriggerpublic void setPreviousFireTime(Date previousFireTime)
Set the previous time at which the DailyTimeIntervalTrigger
fired.
This method should not be invoked by client code.
setPreviousFireTime in interface IOperableTriggerpublic Date getFireTimeAfter(@Nullable Date aAfterTime)
Returns the next time at which the DailyTimeIntervalTrigger
will fire, after the given time. If the trigger will not fire after the
given time, null will be returned.
getFireTimeAfter in interface ITriggeraAfterTime - after timepublic Date getFinalFireTime()
Returns the final time at which the DailyTimeIntervalTrigger
will fire, if there is no end time set, null will be returned.
Note that the return time may be in the past.
getFinalFireTime in interface ITriggerpublic boolean mayFireAgain()
Determines whether or not the DailyTimeIntervalTrigger will
occur again.
mayFireAgain in interface ITriggerpublic void validate()
throws SchedulerException
Validates whether the properties of the JobDetail are valid
for submission into a Scheduler.
validate in interface IOperableTriggervalidate in class AbstractTrigger<DailyTimeIntervalTrigger>IllegalStateException - if a required property (such as Name, Group, Class) is not set.SchedulerExceptionpublic Set<DayOfWeek> getDaysOfWeek()
IDailyTimeIntervalTriggergetDaysOfWeek in interface IDailyTimeIntervalTriggerpublic LocalTime getStartTimeOfDay()
IDailyTimeIntervalTriggergetStartTimeOfDay in interface IDailyTimeIntervalTriggerpublic void setStartTimeOfDay(LocalTime startTimeOfDay)
public LocalTime getEndTimeOfDay()
getEndTimeOfDay in interface IDailyTimeIntervalTriggerpublic void setEndTimeOfDay(LocalTime aEndTimeOfDay)
public IScheduleBuilder<DailyTimeIntervalTrigger> getScheduleBuilder()
IScheduleBuilder that is configured to produce a schedule
identical to this trigger's schedule.getScheduleBuilder in interface ITriggergetScheduleBuilder in class AbstractTrigger<DailyTimeIntervalTrigger>AbstractTrigger.getTriggerBuilder()public int getRepeatCount()
IDailyTimeIntervalTriggergetRepeatCount in interface IDailyTimeIntervalTriggerIDailyTimeIntervalTrigger.REPEAT_INDEFINITELYpublic void setRepeatCount(int repeatCount)
@Nonnull public DailyTimeIntervalTrigger getClone()
getClone in interface com.helger.commons.lang.ICloneable<DailyTimeIntervalTrigger>getClone in interface ITriggergetClone in interface IMutableTriggergetClone in interface IOperableTriggerpublic boolean equals(Object o)
AbstractTriggerequals in interface ITriggerequals in class AbstractTrigger<DailyTimeIntervalTrigger>public int hashCode()
hashCode in class AbstractTrigger<DailyTimeIntervalTrigger>Copyright © 2016–2021 Philip Helger. All rights reserved.