Package helma.util

Class CronJob

java.lang.Object
helma.util.CronJob

public class CronJob extends Object
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
    Constructor
    Description
    Create an empty CronJob.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    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
    Determines if this CronJob applies to the given date.
    Get this entry's function
    Get this entry's name
    long
    Get this entry's timeout
    static 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
     
    void
     
    void
     
    void
     
    void
     
    void
     
    void
     
    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 function
    void
    Set this entry's name
    void
    setTimeout(long timeout)
    Set this entry's timeout
    static List
    sort(List list)
     
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • CronJob

      public CronJob(String name)
      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"

      The value of each of those lists can also be an asterisk (*), which tells the cron system to disregard the given list when determining if a cron entry applies to a specific time -- for instance setting the year-list to * would cause the system to not take the current year into consideration. If a given list is not specified at all, it's the same as specifying it and giving it a value of *.

    • parse

      public static List parse(Properties props)
    • sort

      public static List sort(List list)
    • parseYear

      public void parseYear(String value)
    • parseMonth

      public void parseMonth(String value)
    • parseDay

      public void parseDay(String day)
    • parseWeekDay

      public void parseWeekDay(String weekday)
    • parseHour

      public void parseHour(String hour)
    • parseMinute

      public void parseMinute(String minute)
    • parseTimeout

      public void parseTimeout(String timeout)
    • nextFullMinute

      public static long nextFullMinute()
    • millisToNextFullMinute

      public static long millisToNextFullMinute()
    • appliesToDate

      public boolean appliesToDate(Date date)
      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

      public void setName(String name)
      Set this entry's name
    • getName

      public String getName()
      Get this entry's name
    • setFunction

      public void setFunction(String function)
      Set this entry's function
    • getFunction

      public String 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

      public String toString()
      Overrides:
      toString in class Object