org.quartz
Class DailyTimeIntervalScheduleBuilder

java.lang.Object
  extended by org.quartz.ScheduleBuilder<DailyTimeIntervalTrigger>
      extended by org.quartz.DailyTimeIntervalScheduleBuilder

public class DailyTimeIntervalScheduleBuilder
extends ScheduleBuilder<DailyTimeIntervalTrigger>

A ScheduleBuilder implementation 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, TriggerKey and the various ScheduleBuilder implementations.

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

Field Summary
static Set<Integer> ALL_DAYS_OF_THE_WEEK
          A set of all days of the week.
static Set<Integer> MONDAY_THROUGH_FRIDAY
          A set of the business days of the week (for locales similar to the USA).
static Set<Integer> SATURDAY_AND_SUNDAY
          A set of the weekend days of the week (for locales similar to the USA).
 
Constructor Summary
protected DailyTimeIntervalScheduleBuilder()
           
 
Method Summary
 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.
static DailyTimeIntervalScheduleBuilder dailyTimeIntervalSchedule()
          Create a DailyTimeIntervalScheduleBuilder.
 DailyTimeIntervalScheduleBuilder endingDailyAfterCount(int count)
          Calculate and set the endTimeOfDay using count, interval and starTimeOfDay.
 DailyTimeIntervalScheduleBuilder endingDailyAt(TimeOfDay timeOfDay)
          Set the startTimeOfDay for this trigger to end firing each day at the given time.
 DailyTimeIntervalScheduleBuilder onDaysOfTheWeek(Integer... onDaysOfWeek)
          Set the trigger to fire on the given days of the week.
 DailyTimeIntervalScheduleBuilder onDaysOfTheWeek(Set<Integer> onDaysOfWeek)
          Set the trigger to fire on the given days of the week.
 DailyTimeIntervalScheduleBuilder onEveryDay()
          Set the trigger to fire on all days of the week.
 DailyTimeIntervalScheduleBuilder onMondayThroughFriday()
          Set the trigger to fire on the days from Monday through Friday.
 DailyTimeIntervalScheduleBuilder onSaturdayAndSunday()
          Set the trigger to fire on the days Saturday and Sunday.
 DailyTimeIntervalScheduleBuilder startingDailyAt(TimeOfDay timeOfDay)
          Set the trigger to begin firing each day at the given time.
 DailyTimeIntervalScheduleBuilder withInterval(int timeInterval, DateBuilder.IntervalUnit unit)
          Specify the time unit and interval for the Trigger to be produced.
 DailyTimeIntervalScheduleBuilder withIntervalInHours(int intervalInHours)
          Specify an interval in the IntervalUnit.HOUR that the produced Trigger will repeat at.
 DailyTimeIntervalScheduleBuilder withIntervalInMinutes(int intervalInMinutes)
          Specify an interval in the IntervalUnit.MINUTE that the produced Trigger will repeat at.
 DailyTimeIntervalScheduleBuilder withIntervalInSeconds(int intervalInSeconds)
          Specify an interval in the IntervalUnit.SECOND that the produced Trigger will repeat at.
 DailyTimeIntervalScheduleBuilder withMisfireHandlingInstructionDoNothing()
          If the Trigger misfires, use the DailyTimeIntervalTrigger.MISFIRE_INSTRUCTION_DO_NOTHING instruction.
 DailyTimeIntervalScheduleBuilder withMisfireHandlingInstructionFireAndProceed()
          If the Trigger misfires, use the DailyTimeIntervalTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW instruction.
 DailyTimeIntervalScheduleBuilder withMisfireHandlingInstructionIgnoreMisfires()
          If the Trigger misfires, use the Trigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY instruction.
 DailyTimeIntervalScheduleBuilder withRepeatCount(int repeatCount)
          Set number of times for interval to repeat.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALL_DAYS_OF_THE_WEEK

public static final Set<Integer> ALL_DAYS_OF_THE_WEEK
A set of all days of the week. The set contains all values between Calendar.SUNDAY and Calendar.SATURDAY (the integers from 1 through 7).


MONDAY_THROUGH_FRIDAY

public static final Set<Integer> MONDAY_THROUGH_FRIDAY
A set of the business days of the week (for locales similar to the USA). The set contains all values between Calendar.MONDAY and Calendar.FRIDAY (the integers from 2 through 6).


SATURDAY_AND_SUNDAY

public static final Set<Integer> SATURDAY_AND_SUNDAY
A set of the weekend days of the week (for locales similar to the USA). The set contains Calendar.SATURDAY and Calendar.SUNDAY

Constructor Detail

DailyTimeIntervalScheduleBuilder

protected DailyTimeIntervalScheduleBuilder()
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:
build in class ScheduleBuilder<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 are DateBuilder.IntervalUnit.SECOND, DateBuilder.IntervalUnit.MINUTE, and DateBuilder.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(Set<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 by Calendar.SUNDAY - Calendar.SATURDAY.
Returns:
the updated DailyTimeIntervalScheduleBuilder

onDaysOfTheWeek

public DailyTimeIntervalScheduleBuilder onDaysOfTheWeek(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 by Calendar.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 the Trigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY instruction.

Returns:
the updated DailyTimeIntervalScheduleBuilder
See Also:
Trigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY

withMisfireHandlingInstructionDoNothing

public DailyTimeIntervalScheduleBuilder withMisfireHandlingInstructionDoNothing()
If the Trigger misfires, use the DailyTimeIntervalTrigger.MISFIRE_INSTRUCTION_DO_NOTHING instruction.

Returns:
the updated DailyTimeIntervalScheduleBuilder
See Also:
DailyTimeIntervalTrigger.MISFIRE_INSTRUCTION_DO_NOTHING

withMisfireHandlingInstructionFireAndProceed

public DailyTimeIntervalScheduleBuilder withMisfireHandlingInstructionFireAndProceed()
If the Trigger misfires, use the DailyTimeIntervalTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW instruction.

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


Copyright 2001-2019, Terracotta, Inc.