Class DailyTimeIntervalScheduleBuilder
- java.lang.Object
-
- org.quartz.ScheduleBuilder<DailyTimeIntervalTrigger>
-
- org.quartz.DailyTimeIntervalScheduleBuilder
-
public class DailyTimeIntervalScheduleBuilder extends ScheduleBuilder<DailyTimeIntervalTrigger>
AScheduleBuilderimplementation that build schedule for DailyTimeIntervalTrigger.This builder provide an extra convenient method for you to set the trigger's endTimeOfDay. You may use either endingDailyAt() or endingDailyAfterCount() to set the value. The later will auto calculate your endTimeOfDay by using the interval, intervalUnit and startTimeOfDay to perform the calculation.
When using endingDailyAfterCount(), you should note that it is used to calculating endTimeOfDay. So if your startTime on the first day is already pass by a time that would not add up to the count you expected, until the next day comes. Remember that DailyTimeIntervalTrigger will use startTimeOfDay and endTimeOfDay as fresh per each day!
Quartz provides a builder-style API for constructing scheduling-related entities via a Domain-Specific Language (DSL). The DSL can best be utilized through the usage of static imports of the methods on the classes
TriggerBuilder,JobBuilder,DateBuilder,JobKey,TriggerKeyand the variousScheduleBuilderimplementations.Client code can then use the DSL to write code such as this:
JobDetail job = newJob(MyJob.class) .withIdentity("myJob") .build(); Trigger trigger = newTrigger() .withIdentity(triggerKey("myTrigger", "myTriggerGroup")) .withSchedule(onDaysOfTheWeek(MONDAY, THURSDAY)) .startAt(futureDate(10, MINUTES)) .build(); scheduler.scheduleJob(job, trigger);- Since:
- 2.1.0
- Author:
- James House, Zemian Deng <[email protected]>
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.Set<java.lang.Integer>ALL_DAYS_OF_THE_WEEKA set of all days of the week.static java.util.Set<java.lang.Integer>MONDAY_THROUGH_FRIDAYA set of the business days of the week (for locales similar to the USA).static java.util.Set<java.lang.Integer>SATURDAY_AND_SUNDAYA set of the weekend days of the week (for locales similar to the USA).
-
Constructor Summary
Constructors Modifier Constructor Description protectedDailyTimeIntervalScheduleBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MutableTriggerbuild()Build the actual Trigger -- NOT intended to be invoked by end users, but will rather be invoked by a TriggerBuilder which this ScheduleBuilder is given to.static DailyTimeIntervalScheduleBuilderdailyTimeIntervalSchedule()Create a DailyTimeIntervalScheduleBuilder.DailyTimeIntervalScheduleBuilderendingDailyAfterCount(int count)Calculate and set the endTimeOfDay using count, interval and starTimeOfDay.DailyTimeIntervalScheduleBuilderendingDailyAt(TimeOfDay timeOfDay)Set the startTimeOfDay for this trigger to end firing each day at the given time.DailyTimeIntervalScheduleBuilderonDaysOfTheWeek(java.lang.Integer... onDaysOfWeek)Set the trigger to fire on the given days of the week.DailyTimeIntervalScheduleBuilderonDaysOfTheWeek(java.util.Set<java.lang.Integer> onDaysOfWeek)Set the trigger to fire on the given days of the week.DailyTimeIntervalScheduleBuilderonEveryDay()Set the trigger to fire on all days of the week.DailyTimeIntervalScheduleBuilderonMondayThroughFriday()Set the trigger to fire on the days from Monday through Friday.DailyTimeIntervalScheduleBuilderonSaturdayAndSunday()Set the trigger to fire on the days Saturday and Sunday.DailyTimeIntervalScheduleBuilderstartingDailyAt(TimeOfDay timeOfDay)Set the trigger to begin firing each day at the given time.DailyTimeIntervalScheduleBuilderwithInterval(int timeInterval, DateBuilder.IntervalUnit unit)Specify the time unit and interval for the Trigger to be produced.DailyTimeIntervalScheduleBuilderwithIntervalInHours(int intervalInHours)Specify an interval in the IntervalUnit.HOUR that the produced Trigger will repeat at.DailyTimeIntervalScheduleBuilderwithIntervalInMinutes(int intervalInMinutes)Specify an interval in the IntervalUnit.MINUTE that the produced Trigger will repeat at.DailyTimeIntervalScheduleBuilderwithIntervalInSeconds(int intervalInSeconds)Specify an interval in the IntervalUnit.SECOND that the produced Trigger will repeat at.DailyTimeIntervalScheduleBuilderwithMisfireHandlingInstructionDoNothing()If the Trigger misfires, use theDailyTimeIntervalTrigger.MISFIRE_INSTRUCTION_DO_NOTHINGinstruction.DailyTimeIntervalScheduleBuilderwithMisfireHandlingInstructionFireAndProceed()If the Trigger misfires, use theDailyTimeIntervalTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOWinstruction.DailyTimeIntervalScheduleBuilderwithMisfireHandlingInstructionIgnoreMisfires()If the Trigger misfires, use theTrigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICYinstruction.DailyTimeIntervalScheduleBuilderwithRepeatCount(int repeatCount)Set number of times for interval to repeat.
-
-
-
Field Detail
-
ALL_DAYS_OF_THE_WEEK
public static final java.util.Set<java.lang.Integer> ALL_DAYS_OF_THE_WEEK
A set of all days of the week. The set contains all values betweenCalendar.SUNDAYandCalendar.SATURDAY(the integers from 1 through 7).
-
MONDAY_THROUGH_FRIDAY
public static final java.util.Set<java.lang.Integer> MONDAY_THROUGH_FRIDAY
A set of the business days of the week (for locales similar to the USA). The set contains all values betweenCalendar.MONDAYandCalendar.FRIDAY(the integers from 2 through 6).
-
SATURDAY_AND_SUNDAY
public static final java.util.Set<java.lang.Integer> SATURDAY_AND_SUNDAY
A set of the weekend days of the week (for locales similar to the USA). The set containsCalendar.SATURDAYandCalendar.SUNDAY
-
-
Method Detail
-
dailyTimeIntervalSchedule
public static DailyTimeIntervalScheduleBuilder dailyTimeIntervalSchedule()
Create a DailyTimeIntervalScheduleBuilder.- Returns:
- the new DailyTimeIntervalScheduleBuilder
-
build
public MutableTrigger build()
Build the actual Trigger -- NOT intended to be invoked by end users, but will rather be invoked by a TriggerBuilder which this ScheduleBuilder is given to.- Specified by:
buildin classScheduleBuilder<DailyTimeIntervalTrigger>- See Also:
TriggerBuilder.withSchedule(ScheduleBuilder)
-
withInterval
public DailyTimeIntervalScheduleBuilder withInterval(int timeInterval, DateBuilder.IntervalUnit unit)
Specify the time unit and interval for the Trigger to be produced.- Parameters:
timeInterval- the interval at which the trigger should repeat.unit- the time unit (IntervalUnit) of the interval. The only intervals that are valid for this type of trigger areDateBuilder.IntervalUnit.SECOND,DateBuilder.IntervalUnit.MINUTE, andDateBuilder.IntervalUnit.HOUR.- Returns:
- the updated DailyTimeIntervalScheduleBuilder
- See Also:
DailyTimeIntervalTrigger.getRepeatInterval(),DailyTimeIntervalTrigger.getRepeatIntervalUnit()
-
withIntervalInSeconds
public DailyTimeIntervalScheduleBuilder withIntervalInSeconds(int intervalInSeconds)
Specify an interval in the IntervalUnit.SECOND that the produced Trigger will repeat at.- Parameters:
intervalInSeconds- the number of seconds at which the trigger should repeat.- Returns:
- the updated DailyTimeIntervalScheduleBuilder
- See Also:
DailyTimeIntervalTrigger.getRepeatInterval(),DailyTimeIntervalTrigger.getRepeatIntervalUnit()
-
withIntervalInMinutes
public DailyTimeIntervalScheduleBuilder withIntervalInMinutes(int intervalInMinutes)
Specify an interval in the IntervalUnit.MINUTE that the produced Trigger will repeat at.- Parameters:
intervalInMinutes- the number of minutes at which the trigger should repeat.- Returns:
- the updated CalendarIntervalScheduleBuilder
- See Also:
DailyTimeIntervalTrigger.getRepeatInterval(),DailyTimeIntervalTrigger.getRepeatIntervalUnit()
-
withIntervalInHours
public DailyTimeIntervalScheduleBuilder withIntervalInHours(int intervalInHours)
Specify an interval in the IntervalUnit.HOUR that the produced Trigger will repeat at.- Parameters:
intervalInHours- the number of hours at which the trigger should repeat.- Returns:
- the updated DailyTimeIntervalScheduleBuilder
- See Also:
DailyTimeIntervalTrigger.getRepeatInterval(),DailyTimeIntervalTrigger.getRepeatIntervalUnit()
-
onDaysOfTheWeek
public DailyTimeIntervalScheduleBuilder onDaysOfTheWeek(java.util.Set<java.lang.Integer> onDaysOfWeek)
Set the trigger to fire on the given days of the week.- Parameters:
onDaysOfWeek- a Set containing the integers representing the days of the week, per the values 1-7 as defined byCalendar.SUNDAY-Calendar.SATURDAY.- Returns:
- the updated DailyTimeIntervalScheduleBuilder
-
onDaysOfTheWeek
public DailyTimeIntervalScheduleBuilder onDaysOfTheWeek(java.lang.Integer... onDaysOfWeek)
Set the trigger to fire on the given days of the week.- Parameters:
onDaysOfWeek- a variable length list of Integers representing the days of the week, per the values 1-7 as defined byCalendar.SUNDAY-Calendar.SATURDAY.- Returns:
- the updated DailyTimeIntervalScheduleBuilder
-
onMondayThroughFriday
public DailyTimeIntervalScheduleBuilder onMondayThroughFriday()
Set the trigger to fire on the days from Monday through Friday.- Returns:
- the updated DailyTimeIntervalScheduleBuilder
-
onSaturdayAndSunday
public DailyTimeIntervalScheduleBuilder onSaturdayAndSunday()
Set the trigger to fire on the days Saturday and Sunday.- Returns:
- the updated DailyTimeIntervalScheduleBuilder
-
onEveryDay
public DailyTimeIntervalScheduleBuilder onEveryDay()
Set the trigger to fire on all days of the week.- Returns:
- the updated DailyTimeIntervalScheduleBuilder
-
startingDailyAt
public DailyTimeIntervalScheduleBuilder startingDailyAt(TimeOfDay timeOfDay)
Set the trigger to begin firing each day at the given time.- Returns:
- the updated DailyTimeIntervalScheduleBuilder
-
endingDailyAt
public DailyTimeIntervalScheduleBuilder endingDailyAt(TimeOfDay timeOfDay)
Set the startTimeOfDay for this trigger to end firing each day at the given time.- Returns:
- the updated DailyTimeIntervalScheduleBuilder
-
endingDailyAfterCount
public DailyTimeIntervalScheduleBuilder endingDailyAfterCount(int count)
Calculate and set the endTimeOfDay using count, interval and starTimeOfDay. This means that these must be set before this method is call.- Returns:
- the updated DailyTimeIntervalScheduleBuilder
-
withMisfireHandlingInstructionIgnoreMisfires
public DailyTimeIntervalScheduleBuilder withMisfireHandlingInstructionIgnoreMisfires()
If the Trigger misfires, use theTrigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICYinstruction.- Returns:
- the updated DailyTimeIntervalScheduleBuilder
- See Also:
Trigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY
-
withMisfireHandlingInstructionDoNothing
public DailyTimeIntervalScheduleBuilder withMisfireHandlingInstructionDoNothing()
If the Trigger misfires, use theDailyTimeIntervalTrigger.MISFIRE_INSTRUCTION_DO_NOTHINGinstruction.- Returns:
- the updated DailyTimeIntervalScheduleBuilder
- See Also:
DailyTimeIntervalTrigger.MISFIRE_INSTRUCTION_DO_NOTHING
-
withMisfireHandlingInstructionFireAndProceed
public DailyTimeIntervalScheduleBuilder withMisfireHandlingInstructionFireAndProceed()
If the Trigger misfires, use theDailyTimeIntervalTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOWinstruction.- Returns:
- the updated DailyTimeIntervalScheduleBuilder
- See Also:
DailyTimeIntervalTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW
-
withRepeatCount
public DailyTimeIntervalScheduleBuilder withRepeatCount(int repeatCount)
Set number of times for interval to repeat.Note: if you want total count = 1 (at start time) + repeatCount
- Returns:
- the new DailyTimeIntervalScheduleBuilder
-
-