javatools.cron
Class CrontabEntry

java.lang.Object
  |
  +--javatools.cron.CrontabEntry
All Implemented Interfaces:
CrontabEntryInterface, java.io.Serializable

public class CrontabEntry
extends java.lang.Object
implements CrontabEntryInterface, java.io.Serializable

An implementation of the CrontabEntryInterface that implements Unix style Crontab events.

DESCRIPTION

A crontab file contains instructions to the Cron daemon of the general form: ``run this command at this time on this date''. Blank lines and leading spaces and tabs are ignored. Lines whose first non-space character is a pound-sign (#) are comments, and are ignored. Note that comments are not allowed on the same line as cron commands, since they will be taken to be part of the command. The format of a cron command is very much the V7 standard, with a number of upward-compatible extensions. Each line has five time and date fields, followed by a command. Commands are executed by Cron when the minute, hour, and month of year fields match the current time, and when at least one of the two day fields (day of month, or day of week) match the current time (see ``Note'' below). Note that this means that non-existant times, such as "missing hours" during daylight savings conversion, will never match, causing jobs scheduled during the "missing times" not to be run. Similarly, times that occur more than once (again, during daylight savings conversion) will cause matching jobs to be run twice. (Actually, I'm not sure this is true. Needs confirmation).

The time and date fields are:

minute 0-59 hour 0-23 day of month 0-31 month 0-12 (or names, see below) day of week 0-7 (0 or 7 is Sun, or use names)

(Note, I don't think 0 is accepted for dates and months. Needs checking).

A field may be an asterisk (*), which always stands for ``first-last''. Ranges of numbers are allowed. Ranges are two numbers separated with a hyphen. The specified range is inclusive. For example, 8-11 for an ``hours'' entry specifies execution at hours 8, 9, 10 and 11.

Lists are allowed. A list is a set of numbers (or ranges) separated by commas. Examples: ``1,2,5,9'', ``0-4,8-12''.

Step values can be used in conjunction with ranges. Following a range with ``/'' specifies skips of the number's value through the range. For example, ``0-23/2'' can be used in the hours field to specify command execution every other hour (the alternative in the V7 standard is ``0,2,4,6,8,10,12,14,16,18,20,22''). Steps are also permitted after an asterisk, so if you want to say ``every two hours'', just use ``*\/2''.

Names can also be used for the ``month'' and ``day of week'' fields. Use the first three letters of the particular day or month (case doesn't matter). Ranges or lists of names are allowed.

The ``sixth'' field (the rest of the line) specifies the command to be run. The entire command portion of the line, up to a newline or % character, will be executed. Percent-signs (%) in the command, unless escaped with backslash (\\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input. (Actually not true about % signs. Needs implementing).

Note: The day of a command's execution can be specified by two fields day of month, and day of week. If both fields are restricted (ie, aren't *), the command will be run when either field matches the current time. For example, ``30 4 1,15 * 5'' would cause a command to be run at 4:30 am on the 1st and 15th of each month, plus every Friday.

EXAMPLE CRON FILE

 # run five minutes after midnight, every day
 5 0 * * * com.foo.Task1
 # run at 2:15pm on the first of every month
 15 14 1 * * com.foo.Task1
 # run at 10 pm on weekdays
 0 22 * * 1-5 com.foo.Task1
 # run 23 minutes after midn, 2am, 4am ..., everyday
 23 0-23/2 * * * com.foo.Task1
 # run at 5 after 4 every sunday"
 5 4 * * sun com.foo.Task1
 

EXTENSIONS

When specifying day of week, both day 0 and day 7 will be considered Sunday. (Needs implementing). BSD and ATT seem to disagree about this. Lists and ranges are allowed to co-exist in the same field. "1-3,7-9" would be rejected by ATT or BSD cron -- they want to see "1-3" or "7,8,9" ONLY.

Ranges can include "steps", so "1-9/2" is the same as "1,3,5,7,9". Names of months or days of the week can be specified by name.

BUGS

I think the following bugs are now fixed, but I leave these reports here for the moment... I received the following bug report. What it boils down to is if you specify anything other than "*" for a week day but you don't specify a date then there is a problem. At least that is what I think it boils down to. It needs fixing but I havn't had time. Anyway here is the bug report...If I specify 0 1 * FEB SUN that should be executed only at 1h00 all the Sundays of February, the 10 first dates I get are wrong (start not the 3 February 2002, have some Saturday and some monday) see 1.bmp file. If I specify 0 1 31 * * that should be executed only at 1h00 all the 31 of each month, the 10 first dates I get are also wrong (the date that does not exist like the 31 February or the 31 june are returned in the next month, for example: 31 February is executed the 3 march) THIS is another bug report which may have been fixed but now I can't remember: But the bad new is that it does not work for the following entry: 0 1 29 FEB * (all the 29 february at 1h00 am) [the enternal problem of the leap-year !]. It enter in a infinite loop I think. The following entry work without problem: 0 0 28,29 JAN *.

See Also:
Serialized Form

Nested Class Summary
static class CrontabEntry.ParseSpec
          Describes a CrontabEntry time unit.
 
Field Summary
(package private)  java.lang.String[] args
           
(package private) static int ARRAY_ONE_BASED
          This a constant used to signify which fields are one based.
(package private) static int ARRAY_ZERO_BASED
          This a constant used to signify which fields are zero based.
(package private)  java.util.Calendar calDate
           
(package private)  java.util.Calendar calDay
           
(package private)  java.lang.String className
           
(package private)  boolean[] dateSet
           
static CrontabEntry.ParseSpec dateSpec
           
static java.lang.String[] dayAbbrev
           
static java.lang.String[] dayNames
           
static int DAYS_IN_MONTH
           
static int DAYS_IN_WEEK
           
(package private)  boolean[] daySet
           
static CrontabEntry.ParseSpec daySpec
           
static CrontabEntry.ParseSpec[] EXTENDED_STYLE
           
(package private)  java.util.Calendar from
           
static int HOURS_IN_DAY
           
(package private)  boolean[] hourSet
           
static CrontabEntry.ParseSpec hourSpec
           
(package private) static int INVALID
           
static int MILLIS_IN_SECOND
           
(package private)  boolean[] milliSecondSet
          When using UNIX_STYLE, milliSeconds and seconds will default to "0", but years will default to "*".
static CrontabEntry.ParseSpec milliSecondSpec
           
static int MINUTES_IN_HOUR
           
(package private)  boolean[] minuteSet
           
static CrontabEntry.ParseSpec minuteSpec
           
static java.lang.String[] monthAbbrev
           
static java.lang.String[] monthNames
           
static int MONTHS_IN_YEAR
           
(package private)  boolean[] monthSet
           
static CrontabEntry.ParseSpec monthSpec
           
(package private)  int rotate
           
static int SECONDS_IN_MINUTE
           
(package private)  boolean[] secondSet
           
static CrontabEntry.ParseSpec secondSpec
           
(package private)  java.lang.ThreadGroup threadGroup
           
static CrontabEntry.ParseSpec[] UNIX_STYLE
          Several styles of Crontab supported.
static CrontabEntry.ParseSpec[] UNIX_STYLE_AND_YEARS
           
static int yearArrayBase
          Our boolean array of years has to start at a particular year.
static int YEARS_IN_SPACE_TIME
           
(package private)  boolean[] yearSet
           
static CrontabEntry.ParseSpec yearSpec
           
 
Constructor Summary
CrontabEntry()
           
CrontabEntry(java.lang.ThreadGroup threadGroup)
           
CrontabEntry(java.lang.ThreadGroup threadGroup, java.lang.String line, CrontabEntry.ParseSpec[] style)
           
 
Method Summary
(package private)  java.lang.String ab2s(boolean[] array)
          Helper class for toString().
(package private)  java.lang.String as2s(java.lang.String[] array)
          Helper class for toString().
(package private) static int calcThisYear()
          Return this year as an integer.
(package private)  boolean conformsTo(boolean[] set, int tm)
           
(package private)  boolean dateConformsTo(java.util.Calendar date)
           
 void execute()
          Start a thread to execute the class.
(package private)  int findNext(int tm, boolean[] array, CrontabEntry.ParseSpec spec, java.util.Calendar cal)
          Find the next occurance of an event within this array.
 java.lang.String[] getArgs()
           
 boolean[] getArray(CrontabEntry.ParseSpec spec)
          Get one of the fields as a boolean array.
 java.lang.String getClassName()
           
 boolean[] getDatesArray()
          Get the dates value as an array
 java.lang.String getDatesString()
          Get the dates value as a String
 boolean[] getDaysArray()
          Get the days of week value as an array
 java.lang.String getDaysString()
          Get the days of week value as a String
 boolean[] getHoursArray()
          Get the hours value as an array
 java.lang.String getHoursString()
          Get the hours value as a String
 boolean[] getMilliSecondsArray()
          Get the milliSeconds value as an array
 java.lang.String getMilliSecondsString()
          Get the milliSeconds value as a String
 boolean[] getMinutesArray()
          Get the minutes value as an array
 java.lang.String getMinutesString()
          Get the minutes value as a String
 boolean[] getMonthsArray()
          Get the months value as an array
 java.lang.String getMonthsString()
          Get the months value as a String
 boolean[] getSecondsArray()
          Get the seconds value as an array
 java.lang.String getSecondsString()
          Get the seconds value as an String
 java.lang.String getString(CrontabEntry.ParseSpec spec)
          Get one of the fields as a String.
 boolean[] getYearsArray()
          Get the years value as an array
 java.lang.String getYearsString()
          Get the years value as a String
(package private) static boolean[] hackArray(boolean[] array, CrontabEntry.ParseSpec spec)
           
(package private) static boolean[] hackArray(boolean[] array, int arraySize)
          A couple of special cases greatly reduce our memory usage, and more importantly our processing time.
(package private) static boolean isSet(int n, boolean[] array, CrontabEntry.ParseSpec spec)
           
 boolean isSetDate(int n)
          Is date n scheduled for execution?
 boolean isSetDay(int n)
          Is day of week n scheduled for execution?
 boolean isSetHours(int n)
          Is hour n scheduled for execution?
 boolean isSetMilliSeconds(int n)
          Is milliSecond n scheduled for execution?
 boolean isSetMinutes(int n)
          Is minute n scheduled for execution?
 boolean isSetMonth(int n)
          Is month n scheduled for execution?
 boolean isSetSeconds(int n)
          Is second n scheduled for execution?
 boolean isSetYear(int n)
          Is year n scheduled for execution?
(package private)  boolean latterConforms(java.util.Calendar cal, CrontabEntry.ParseSpec spec)
           
(package private) static java.lang.String makeOne(int num, CrontabEntry.ParseSpec spec)
           
static java.lang.String makeString(boolean[] array, CrontabEntry.ParseSpec spec)
          Convert a boolean array into the corresponding Unix spec String.
(package private) static java.lang.String makeToken(int num, int first, int last, int step, CrontabEntry.ParseSpec spec)
           
 long nextEvent(long fromTime)
          When is the next event that occurs at or after fromTime? Note the tricky code caused by the arrays being zero based but Calendar using a 1-based system for DAY_OF_MONTH.
 void parse(java.lang.String str, CrontabEntry.ParseSpec[] style)
          Parses a string describing this crontab entry
(package private) static void parseRange(java.lang.String token, boolean[] array, int arrayBase, java.lang.String[] names)
          Parse a range which is one component of a list of comma separated values.
static boolean[] parseToken(java.lang.String token, CrontabEntry.ParseSpec spec)
           
(package private) static boolean[] parseToken(java.lang.String token, int arraySize, int arrayBase, java.lang.String[] names)
          Parse one component of the entry according to the Unix spec.
static boolean[] parseTokenHack(java.lang.String token, CrontabEntry.ParseSpec spec)
           
(package private) static boolean[] parseTokenHack(java.lang.String token, int arraySize, int arrayBase, java.lang.String[] names)
          Parse the token and do the special hackArray transformations.
 void set(boolean[] array, CrontabEntry.ParseSpec spec)
          Set one of the fields given a boolean array.
 void set(java.lang.String v, CrontabEntry.ParseSpec spec)
          Set one of the fields given a String.
 void setArgs(java.lang.String[] v)
           
 void setClassName(java.lang.String v)
           
 void setDates(boolean[] array)
          Set the dates of the month field given an array
 void setDates(java.lang.String v)
          Set the dates of the month field given a String
 void setDays(boolean[] array)
          Set the days of week field given an array
 void setDays(java.lang.String v)
          Set the days of week field given a String
 void setHours(boolean[] array)
          Set the hours field given an array
 void setHours(java.lang.String v)
          Set the hours field given a String
 void setMilliSeconds(boolean[] array)
          Set the milliSeconds field given a boolean array
 void setMilliSeconds(java.lang.String v)
          Set the milliSeconds field given a String
 void setMinutes(boolean[] array)
          Set the minutes field given an array
 void setMinutes(java.lang.String v)
          Set the minutes field given an array
 void setMonths(boolean[] array)
          Set the months field given an array
 void setMonths(java.lang.String v)
          Set the months field given a String
 void setSeconds(boolean[] array)
          Set the seconds field given an array
 void setSeconds(java.lang.String v)
          Set the seconds field given a String
 void setYears(boolean[] array)
          Set the years field given an array
 void setYears(java.lang.String v)
          Set the years field given a String
(package private) static int tokToIndex(java.lang.String[] names, java.lang.String tok, int arrayBase)
           
 java.lang.String toString()
           
(package private) static boolean[] unhackArray(boolean[] array, CrontabEntry.ParseSpec spec)
           
(package private) static boolean[] unhackArray(boolean[] array, int arraySize)
          This does the opposite of hackArray.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dayNames

public static final java.lang.String[] dayNames

monthNames

public static final java.lang.String[] monthNames

dayAbbrev

public static final java.lang.String[] dayAbbrev

monthAbbrev

public static final java.lang.String[] monthAbbrev

MILLIS_IN_SECOND

public static final int MILLIS_IN_SECOND
See Also:
Constant Field Values

SECONDS_IN_MINUTE

public static final int SECONDS_IN_MINUTE
See Also:
Constant Field Values

MINUTES_IN_HOUR

public static final int MINUTES_IN_HOUR
See Also:
Constant Field Values

HOURS_IN_DAY

public static final int HOURS_IN_DAY
See Also:
Constant Field Values

DAYS_IN_MONTH

public static final int DAYS_IN_MONTH
See Also:
Constant Field Values

DAYS_IN_WEEK

public static final int DAYS_IN_WEEK
See Also:
Constant Field Values

MONTHS_IN_YEAR

public static final int MONTHS_IN_YEAR
See Also:
Constant Field Values

YEARS_IN_SPACE_TIME

public static final int YEARS_IN_SPACE_TIME
See Also:
Constant Field Values

ARRAY_ONE_BASED

static final int ARRAY_ONE_BASED
This a constant used to signify which fields are one based. e.g. Dates

See Also:
Constant Field Values

ARRAY_ZERO_BASED

static final int ARRAY_ZERO_BASED
This a constant used to signify which fields are zero based. e.g. Hours and Minutes

See Also:
Constant Field Values

INVALID

static final int INVALID
See Also:
Constant Field Values

yearArrayBase

public static final int yearArrayBase
Our boolean array of years has to start at a particular year. Rather than hard code a certain year, we use this year as a base. (We can't schedule things in the past right?). Potential problem here is that if we serialize a CrontabEntry across a socket near the end of the year, the other end may use a different base. I guess this needs fixing.


milliSecondSpec

public static final CrontabEntry.ParseSpec milliSecondSpec

secondSpec

public static final CrontabEntry.ParseSpec secondSpec

minuteSpec

public static final CrontabEntry.ParseSpec minuteSpec

hourSpec

public static final CrontabEntry.ParseSpec hourSpec

dateSpec

public static final CrontabEntry.ParseSpec dateSpec

monthSpec

public static final CrontabEntry.ParseSpec monthSpec

daySpec

public static final CrontabEntry.ParseSpec daySpec

yearSpec

public static final CrontabEntry.ParseSpec yearSpec

UNIX_STYLE

public static final CrontabEntry.ParseSpec[] UNIX_STYLE
Several styles of Crontab supported. Traditional Unix style which is
 MIN HOUR DATE MONTH DAY command
 
Unix and years...
 MIN HOUR DATE MONTH YEAR DAY command
 
and extended style which is
 MILLISECOND SECOND MIN HOUR DATE MONTH YEAR DAY command
 


UNIX_STYLE_AND_YEARS

public static final CrontabEntry.ParseSpec[] UNIX_STYLE_AND_YEARS

EXTENDED_STYLE

public static final CrontabEntry.ParseSpec[] EXTENDED_STYLE

className

java.lang.String className

args

java.lang.String[] args

threadGroup

java.lang.ThreadGroup threadGroup

milliSecondSet

boolean[] milliSecondSet
When using UNIX_STYLE, milliSeconds and seconds will default to "0", but years will default to "*". (null is "*").


secondSet

boolean[] secondSet

minuteSet

boolean[] minuteSet

hourSet

boolean[] hourSet

dateSet

boolean[] dateSet

monthSet

boolean[] monthSet

yearSet

boolean[] yearSet

daySet

boolean[] daySet

rotate

int rotate

from

java.util.Calendar from

calDate

java.util.Calendar calDate

calDay

java.util.Calendar calDay
Constructor Detail

CrontabEntry

public CrontabEntry(java.lang.ThreadGroup threadGroup,
                    java.lang.String line,
                    CrontabEntry.ParseSpec[] style)
             throws CrontabParseException,
                    CrontabEmptyException

CrontabEntry

public CrontabEntry(java.lang.ThreadGroup threadGroup)

CrontabEntry

public CrontabEntry()
Method Detail

makeString

public static java.lang.String makeString(boolean[] array,
                                          CrontabEntry.ParseSpec spec)
Convert a boolean array into the corresponding Unix spec String. This function can handled "hacked" arrays.

Parameters:
array - Description of Parameter
spec - Description of Parameter
Returns:
Description of the Returned Value

parseToken

public static boolean[] parseToken(java.lang.String token,
                                   CrontabEntry.ParseSpec spec)
                            throws CrontabParseException
CrontabParseException

parseTokenHack

public static boolean[] parseTokenHack(java.lang.String token,
                                       CrontabEntry.ParseSpec spec)
                                throws CrontabParseException,
                                       CrontabEmptyException
CrontabParseException
CrontabEmptyException

isSet

static boolean isSet(int n,
                     boolean[] array,
                     CrontabEntry.ParseSpec spec)

calcThisYear

static int calcThisYear()
Return this year as an integer.

Returns:
Description of the Returned Value

makeOne

static java.lang.String makeOne(int num,
                                CrontabEntry.ParseSpec spec)

makeToken

static java.lang.String makeToken(int num,
                                  int first,
                                  int last,
                                  int step,
                                  CrontabEntry.ParseSpec spec)

hackArray

static boolean[] hackArray(boolean[] array,
                           CrontabEntry.ParseSpec spec)
                    throws CrontabEmptyException
CrontabEmptyException

unhackArray

static boolean[] unhackArray(boolean[] array,
                             CrontabEntry.ParseSpec spec)

parseToken

static boolean[] parseToken(java.lang.String token,
                            int arraySize,
                            int arrayBase,
                            java.lang.String[] names)
                     throws CrontabParseException
Parse one component of the entry according to the Unix spec.

Parameters:
token - a string of the form "range,range,..."
arrayBase - if 1 is the first valid value, pass "1", else pass 0.
arraySize - Description of Parameter
names - Description of Parameter
Returns:
Description of the Returned Value
Throws:
CrontabParseException - Description of Exception

parseTokenHack

static boolean[] parseTokenHack(java.lang.String token,
                                int arraySize,
                                int arrayBase,
                                java.lang.String[] names)
                         throws CrontabParseException,
                                CrontabEmptyException
Parse the token and do the special hackArray transformations.

Parameters:
token - Description of Parameter
arraySize - Description of Parameter
arrayBase - Description of Parameter
names - Description of Parameter
Returns:
Description of the Returned Value
Throws:
CrontabParseException - Description of Exception
CrontabEmptyException - Description of Exception

unhackArray

static boolean[] unhackArray(boolean[] array,
                             int arraySize)
This does the opposite of hackArray. i.e. it converts a possibly null reference or possibly shortened array into the full array. This is useful for passing the array back to the user of the class who doesn't want to know about these internal special cases.

Parameters:
array - Description of Parameter
arraySize - Description of Parameter
Returns:
Description of the Returned Value

hackArray

static boolean[] hackArray(boolean[] array,
                           int arraySize)
                    throws CrontabEmptyException
A couple of special cases greatly reduce our memory usage, and more importantly our processing time. Firstly, a null array is a shorthand for "*". Secondly, the array is shortened and any "missing" entries are assumed to be false. This is most useful for "0" only values. The Day/Date code relies on the "null array" special case being used.

Parameters:
array - Description of Parameter
arraySize - Description of Parameter
Returns:
Description of the Returned Value
Throws:
CrontabEmptyException - Description of Exception

tokToIndex

static int tokToIndex(java.lang.String[] names,
                      java.lang.String tok,
                      int arrayBase)
               throws CrontabParseException
Parameters:
arrayBase - if Calendar starts counting at one, pass "1", else pass "0"
names - Description of Parameter
tok - Description of Parameter
Returns:
Description of the Returned Value
Throws:
CrontabParseException - Description of Exception

parseRange

static void parseRange(java.lang.String token,
                       boolean[] array,
                       int arrayBase,
                       java.lang.String[] names)
                throws CrontabParseException
Parse a range which is one component of a list of comma separated values.

Parameters:
token - a string of the form "from-to/step".
arrayBase - if Calendar starts counting at one, pass "1", else pass "0"
array - Description of Parameter
names - Description of Parameter
Throws:
CrontabParseException - Description of Exception

set

public void set(java.lang.String v,
                CrontabEntry.ParseSpec spec)
         throws CrontabParseException,
                CrontabEmptyException
Set one of the fields given a String. Which field is set is determined by the particular ParseSpec object passed in.

Parameters:
v - Description of Parameter
spec - Description of Parameter
Throws:
CrontabParseException - Description of Exception
CrontabEmptyException - Description of Exception

set

public void set(boolean[] array,
                CrontabEntry.ParseSpec spec)
         throws CrontabEmptyException
Set one of the fields given a boolean array. Which field is set is determined by the particular ParseSpec object passed in.

Parameters:
array - Description of Parameter
spec - Description of Parameter
Throws:
CrontabEmptyException - Description of Exception

setMilliSeconds

public void setMilliSeconds(java.lang.String v)
                     throws CrontabParseException,
                            CrontabEmptyException
Set the milliSeconds field given a String

Parameters:
v - The new milliSeconds value
Throws:
CrontabParseException - Description of Exception
CrontabEmptyException - Description of Exception

setMilliSeconds

public void setMilliSeconds(boolean[] array)
                     throws CrontabEmptyException
Set the milliSeconds field given a boolean array

Parameters:
array - The new milliSeconds value
Throws:
CrontabEmptyException - Description of Exception

setSeconds

public void setSeconds(java.lang.String v)
                throws CrontabParseException,
                       CrontabEmptyException
Set the seconds field given a String

Parameters:
v - The new seconds value
Throws:
CrontabParseException - Description of Exception
CrontabEmptyException - Description of Exception

setSeconds

public void setSeconds(boolean[] array)
                throws CrontabEmptyException
Set the seconds field given an array

Parameters:
array - The new seconds value
Throws:
CrontabEmptyException - Description of Exception

setMinutes

public void setMinutes(java.lang.String v)
                throws CrontabParseException,
                       CrontabEmptyException
Set the minutes field given an array

Parameters:
v - The new minutes value
Throws:
CrontabParseException - Description of Exception
CrontabEmptyException - Description of Exception

setMinutes

public void setMinutes(boolean[] array)
                throws CrontabEmptyException
Set the minutes field given an array

Parameters:
array - The new minutes value
Throws:
CrontabEmptyException - Description of Exception

setHours

public void setHours(java.lang.String v)
              throws CrontabParseException,
                     CrontabEmptyException
Set the hours field given a String

Parameters:
v - The new hours value
Throws:
CrontabParseException - Description of Exception
CrontabEmptyException - Description of Exception

setHours

public void setHours(boolean[] array)
              throws CrontabEmptyException
Set the hours field given an array

Parameters:
array - The new hours value
Throws:
CrontabEmptyException - Description of Exception

setDates

public void setDates(java.lang.String v)
              throws CrontabParseException,
                     CrontabEmptyException
Set the dates of the month field given a String

Parameters:
v - The new dates value
Throws:
CrontabParseException - Description of Exception
CrontabEmptyException - Description of Exception

setDates

public void setDates(boolean[] array)
              throws CrontabEmptyException
Set the dates of the month field given an array

Parameters:
array - The new dates value
Throws:
CrontabEmptyException - Description of Exception

setMonths

public void setMonths(java.lang.String v)
               throws CrontabParseException,
                      CrontabEmptyException
Set the months field given a String

Parameters:
v - The new months value
Throws:
CrontabParseException - Description of Exception
CrontabEmptyException - Description of Exception

setMonths

public void setMonths(boolean[] array)
               throws CrontabEmptyException
Set the months field given an array

Parameters:
array - The new months value
Throws:
CrontabEmptyException - Description of Exception

setYears

public void setYears(java.lang.String v)
              throws CrontabParseException,
                     CrontabEmptyException
Set the years field given a String

Parameters:
v - The new years value
Throws:
CrontabParseException - Description of Exception
CrontabEmptyException - Description of Exception

setYears

public void setYears(boolean[] array)
              throws CrontabEmptyException
Set the years field given an array

Parameters:
array - The new years value
Throws:
CrontabEmptyException - Description of Exception

setDays

public void setDays(java.lang.String v)
             throws CrontabParseException,
                    CrontabEmptyException
Set the days of week field given a String

Parameters:
v - The new days value
Throws:
CrontabParseException - Description of Exception
CrontabEmptyException - Description of Exception

setDays

public void setDays(boolean[] array)
             throws CrontabEmptyException
Set the days of week field given an array

Parameters:
array - The new days value
Throws:
CrontabEmptyException - Description of Exception

setClassName

public void setClassName(java.lang.String v)

setArgs

public void setArgs(java.lang.String[] v)

getString

public java.lang.String getString(CrontabEntry.ParseSpec spec)
Get one of the fields as a String. Which field is got is determined by the particular ParseSpec object passed in.

Parameters:
spec - Description of Parameter
Returns:
The string value

getArray

public boolean[] getArray(CrontabEntry.ParseSpec spec)
Get one of the fields as a boolean array. Which field is got is determined by the particular ParseSpec object passed in.

Parameters:
spec - Description of Parameter
Returns:
The array value

isSetMilliSeconds

public boolean isSetMilliSeconds(int n)
Is milliSecond n scheduled for execution?

Parameters:
n - Description of Parameter
Returns:
The setMilliSeconds value

getMilliSecondsString

public java.lang.String getMilliSecondsString()
Get the milliSeconds value as a String

Returns:
The milliSecondsString value

getMilliSecondsArray

public boolean[] getMilliSecondsArray()
Get the milliSeconds value as an array

Returns:
The milliSecondsArray value

isSetSeconds

public boolean isSetSeconds(int n)
Is second n scheduled for execution?

Parameters:
n - Description of Parameter
Returns:
The setSeconds value

getSecondsString

public java.lang.String getSecondsString()
Get the seconds value as an String

Returns:
The secondsString value

getSecondsArray

public boolean[] getSecondsArray()
Get the seconds value as an array

Returns:
The secondsArray value

isSetMinutes

public boolean isSetMinutes(int n)
Is minute n scheduled for execution?

Parameters:
n - Description of Parameter
Returns:
The setMinutes value

getMinutesString

public java.lang.String getMinutesString()
Get the minutes value as a String

Returns:
The minutesString value

getMinutesArray

public boolean[] getMinutesArray()
Get the minutes value as an array

Returns:
The minutesArray value

isSetHours

public boolean isSetHours(int n)
Is hour n scheduled for execution?

Parameters:
n - Description of Parameter
Returns:
The setHours value

getHoursString

public java.lang.String getHoursString()
Get the hours value as a String

Returns:
The hoursString value

getHoursArray

public boolean[] getHoursArray()
Get the hours value as an array

Returns:
The hoursArray value

isSetDate

public boolean isSetDate(int n)
Is date n scheduled for execution?

Parameters:
n - Description of Parameter
Returns:
The setDate value

getDatesString

public java.lang.String getDatesString()
Get the dates value as a String

Returns:
The datesString value

getDatesArray

public boolean[] getDatesArray()
Get the dates value as an array

Returns:
The datesArray value

isSetMonth

public boolean isSetMonth(int n)
Is month n scheduled for execution?

Parameters:
n - Description of Parameter
Returns:
The setMonth value

getMonthsString

public java.lang.String getMonthsString()
Get the months value as a String

Returns:
The monthsString value

getMonthsArray

public boolean[] getMonthsArray()
Get the months value as an array

Returns:
The monthsArray value

isSetYear

public boolean isSetYear(int n)
Is year n scheduled for execution?

Parameters:
n - Description of Parameter
Returns:
The setYear value

getYearsString

public java.lang.String getYearsString()
Get the years value as a String

Returns:
The yearsString value

getYearsArray

public boolean[] getYearsArray()
Get the years value as an array

Returns:
The yearsArray value

isSetDay

public boolean isSetDay(int n)
Is day of week n scheduled for execution?

Parameters:
n - Description of Parameter
Returns:
The setDay value

getDaysString

public java.lang.String getDaysString()
Get the days of week value as a String

Returns:
The daysString value

getDaysArray

public boolean[] getDaysArray()
Get the days of week value as an array

Returns:
The daysArray value

getClassName

public java.lang.String getClassName()
Returns:
the class that the event calls when activated

getArgs

public java.lang.String[] getArgs()
Returns:
the arguments passed to the thread.

parse

public void parse(java.lang.String str,
                  CrontabEntry.ParseSpec[] style)
           throws CrontabParseException,
                  CrontabEmptyException
Parses a string describing this crontab entry

Parameters:
str - String describing the time table entry
style - Description of Parameter
Throws:
CrontabParseException - Description of Exception
CrontabEmptyException - Description of Exception
CrontabEntryException - Error parsing the string

execute

public void execute()
Start a thread to execute the class.

Specified by:
execute in interface CrontabEntryInterface

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

findNext

int findNext(int tm,
             boolean[] array,
             CrontabEntry.ParseSpec spec,
             java.util.Calendar cal)
       throws CrontabEmptyException
Find the next occurance of an event within this array. If we search past the end of the array and go back to the beginning then the "rotate" variable is set to 1, otherwise it is set to 0.

Parameters:
tm - Description of Parameter
array - Description of Parameter
Returns:
Description of the Returned Value
Throws:
CrontabEmptyException - Description of Exception

conformsTo

boolean conformsTo(boolean[] set,
                   int tm)

dateConformsTo

boolean dateConformsTo(java.util.Calendar date)

latterConforms

boolean latterConforms(java.util.Calendar cal,
                       CrontabEntry.ParseSpec spec)

nextEvent

public long nextEvent(long fromTime)
When is the next event that occurs at or after fromTime? Note the tricky code caused by the arrays being zero based but Calendar using a 1-based system for DAY_OF_MONTH.

Specified by:
nextEvent in interface CrontabEntryInterface
Parameters:
fromTime - Description of Parameter
Returns:
Description of the Returned Value

ab2s

java.lang.String ab2s(boolean[] array)
Helper class for toString(). formats an array of boolean.

Parameters:
array - Description of Parameter
Returns:
Description of the Returned Value

as2s

java.lang.String as2s(java.lang.String[] array)
Helper class for toString(). formats an array of Strings.

Parameters:
array - Description of Parameter
Returns:
Description of the Returned Value