Package helma.util
Class CronJob
java.lang.Object
helma.util.CronJob
A cron entry, derived from Protomatter's CronEntry class.
This class encapsulates a function call, a timeout value
and a specification for when the given event should be
delivered to the given topics. The specification of when
the event should be delivered is based on the UNIX cron
facility.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDay
(int day) Add a day of the month to the list of years this entry applies to.void
addHour
(int hour) Add an hour to the list of years this entry applies to.void
addMinute
(int minute) Add a minute to the list of years this entry applies to.void
addMonth
(int month) Add a month to the list of years this entry applies to.void
addWeekday
(int weekday) Add a weekday to the list of years this entry applies to.void
addYear
(int year) Add a year to the list of years this entry applies to.boolean
appliesToDate
(Date date) Determines if this CronJob applies to the given date.Get this entry's functiongetName()
Get this entry's namelong
Get this entry's timeoutstatic long
static CronJob
newJob
(String functionName, String year, String month, String day, String weekday, String hour, String minute) A method for parsing properties.static long
static List
parse
(Properties props) void
void
void
parseMinute
(String minute) void
parseMonth
(String value) void
parseTimeout
(String timeout) void
parseWeekDay
(String weekday) void
void
removeDay
(int day) Remove a day of the month from the list of years this entry applies to.void
removeHour
(int hour) Remove an hour from the list of years this entry applies to.void
removeMinute
(int minute) Remove a minute from the list of years this entry applies to.void
removeMonth
(int month) Remove a month from the list of years this entry applies to.void
removeWeekday
(int weekday) Remove a weekday from the list of years this entry applies to.void
removeYear
(int year) Remove a year from the list of years this entry applies to.void
setAllDays
(boolean set) Should the current day of the month be taken into consideration when deciding if this entry is applicable? If this is set to false (the default) then the values set with the addDay() and removeDay() are taken into consideration.void
setAllHours
(boolean set) Should the current hour be taken into consideration when deciding if this entry is applicable? If this is set to false (the default) then the values set with the addHour() and removeHour() are taken into consideration.void
setAllMinutes
(boolean set) Should the current minute be taken into consideration when deciding if this entry is applicable? If this is set to false (the default) then the values set with the addMinute() and removeMinute() are taken into consideration.void
setAllMonths
(boolean set) Should the current month be taken into consideration when deciding if this entry is applicable? If this is set to false (the default) then the values set with the addMonth() and removeMonth() are taken into consideration.void
setAllWeekdays
(boolean set) Should the current weekday be taken into consideration when deciding if this entry is applicable? If this is set to false (the default) then the values set with the addWeekday() and removeWeekday() are taken into consideration.void
setAllYears
(boolean set) Should the current year be taken into consideration when deciding if this entry is applicable? If this is set to false (the default) then the values set with the addYear() and removeYear() are taken into consideration.void
setFunction
(String function) Set this entry's functionvoid
Set this entry's namevoid
setTimeout
(long timeout) Set this entry's timeoutstatic List
toString()
-
Constructor Details
-
CronJob
Create an empty CronJob.
-
-
Method Details
-
newJob
public static CronJob newJob(String functionName, String year, String month, String day, String weekday, String hour, String minute) A method for parsing properties. It looks through the properties file for entries that look like this:cron.name1.function = functionname cron.name1.year = year-list cron.name1.month = month-list cron.name1.day = day-list cron.name1.weekday = weekday-list cron.name1.hour = hour-list cron.name1.minute = minute-list cron.name1.timeout = timeout-value
And delivers corresponding CronJob objects in a collection. The specified lists from above are:
- year-list
- This is a comma (,) separated list of individual years or of year ranges. Examples: "1999,2000" or "1999-2004,2005-2143,2650"
- month-list
- This is a comma (,) separated list of month names. Example: "january,march,may"
- day-list
- This is a comma (,) separated list of individual day-of-month numbers or of day-of-month ranges. Examples: "1,15" or "1-5,7,10-24"
- weekday-list
- This is a comma (,) separated list of weekday names names. Example: "monday,tuesday"
- hour-list
- This is a comma (,) separated list of individual hours-of-day (24-hour time) or of hour-of-day ranges. Examples: "12,15" or "8-17,19,20-22"
- minute-list
- This is a comma (,) separated list of individual minutes (during an hour) or of minute ranges. Examples: "0,15,30,45" or "0-5,8-14,23,28-32"
-
parse
-
sort
-
parseYear
-
parseMonth
-
parseDay
-
parseWeekDay
-
parseHour
-
parseMinute
-
parseTimeout
-
nextFullMinute
public static long nextFullMinute() -
millisToNextFullMinute
public static long millisToNextFullMinute() -
appliesToDate
Determines if this CronJob applies to the given date. Seconds and milliseconds in the date are ignored. -
addYear
public void addYear(int year) Add a year to the list of years this entry applies to. -
removeYear
public void removeYear(int year) Remove a year from the list of years this entry applies to. -
setAllYears
public void setAllYears(boolean set) Should the current year be taken into consideration when deciding if this entry is applicable? If this is set to false (the default) then the values set with the addYear() and removeYear() are taken into consideration. If this is set to true then the current year is not taken into consideration. -
addMonth
public void addMonth(int month) Add a month to the list of years this entry applies to. Month numbers are taken from the constants on the java.util.Calendar class. -
removeMonth
public void removeMonth(int month) Remove a month from the list of years this entry applies to. Month numbers are taken from the constants on the java.util.Calendar class. -
setAllMonths
public void setAllMonths(boolean set) Should the current month be taken into consideration when deciding if this entry is applicable? If this is set to false (the default) then the values set with the addMonth() and removeMonth() are taken into consideration. If this is set to true then the current month is not taken into consideration. -
addDay
public void addDay(int day) Add a day of the month to the list of years this entry applies to. -
removeDay
public void removeDay(int day) Remove a day of the month from the list of years this entry applies to. -
setAllDays
public void setAllDays(boolean set) Should the current day of the month be taken into consideration when deciding if this entry is applicable? If this is set to false (the default) then the values set with the addDay() and removeDay() are taken into consideration. If this is set to true then the current year is not taken into consideration. -
addWeekday
public void addWeekday(int weekday) Add a weekday to the list of years this entry applies to. Weekday numbers are taken from the constants on the java.util.Calendar class. -
removeWeekday
public void removeWeekday(int weekday) Remove a weekday from the list of years this entry applies to. Weekday numbers are taken from the constants on the java.util.Calendar class. -
setAllWeekdays
public void setAllWeekdays(boolean set) Should the current weekday be taken into consideration when deciding if this entry is applicable? If this is set to false (the default) then the values set with the addWeekday() and removeWeekday() are taken into consideration. If this is set to true then the current weekday is not taken into consideration. -
addHour
public void addHour(int hour) Add an hour to the list of years this entry applies to. -
removeHour
public void removeHour(int hour) Remove an hour from the list of years this entry applies to. -
setAllHours
public void setAllHours(boolean set) Should the current hour be taken into consideration when deciding if this entry is applicable? If this is set to false (the default) then the values set with the addHour() and removeHour() are taken into consideration. If this is set to true then the current hour is not taken into consideration. -
addMinute
public void addMinute(int minute) Add a minute to the list of years this entry applies to. -
removeMinute
public void removeMinute(int minute) Remove a minute from the list of years this entry applies to. -
setAllMinutes
public void setAllMinutes(boolean set) Should the current minute be taken into consideration when deciding if this entry is applicable? If this is set to false (the default) then the values set with the addMinute() and removeMinute() are taken into consideration. If this is set to true then the current minute is not taken into consideration. -
setName
Set this entry's name -
getName
Get this entry's name -
setFunction
Set this entry's function -
getFunction
Get this entry's function -
setTimeout
public void setTimeout(long timeout) Set this entry's timeout -
getTimeout
public long getTimeout()Get this entry's timeout -
toString
-