com.indexdata.utils
Class CronLine

java.lang.Object
  extended by com.indexdata.utils.CronLine

public class CronLine
extends Object

A CronLine is an internal representation of the time specification as used by cron. It consists of 5 fields: min, hr, mday, month, wday. Each of these is a simple numerical String (but that can be changed later, if we ever want to implement advanced features like 14,45 or 2/5).

Author:
heikki

Field Summary
static int DAILY_PERIOD
           
static int DAY_OF_MONTH
           
static int DAY_OF_WEEK
           
static int HOUR
           
static int MINUTE
           
static int MONTH
           
static int MONTHLY_PERIOD
           
static int WEEKLY_PERIOD
           
static int YEARLY_PERIOD
           
 
Constructor Summary
CronLine(String line)
          Constructs a CronLine from a string representation of following format: "%d %d %d %d %d" applied to minute, hour, day-of-month, month, day-of-week
 
Method Summary
static CronLine createCronLine(Calendar cal)
           
static CronLine currentCronLine()
          Return a cron line that corresponds to current date and time.
 String get(int field)
          Returns value of a given cron field.
 boolean matches(CronLine pattern)
          Matches this cron line againts the parameter and returns true if the param is more general (contains wildcards) or equal.
 Date nextMatchingDate(Date offsetDate)
          Finds the next day that matches this CronLine, ignoring the time of day (hr,min,seconds,millis)
 int shortestPeriod()
          Checks the shortest period of the cron line.
 Date toDate()
          Converts cron entry to date;
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MINUTE

public static final int MINUTE
See Also:
Constant Field Values

HOUR

public static final int HOUR
See Also:
Constant Field Values

DAY_OF_MONTH

public static final int DAY_OF_MONTH
See Also:
Constant Field Values

MONTH

public static final int MONTH
See Also:
Constant Field Values

DAY_OF_WEEK

public static final int DAY_OF_WEEK
See Also:
Constant Field Values

DAILY_PERIOD

public static final int DAILY_PERIOD
See Also:
Constant Field Values

WEEKLY_PERIOD

public static final int WEEKLY_PERIOD
See Also:
Constant Field Values

MONTHLY_PERIOD

public static final int MONTHLY_PERIOD
See Also:
Constant Field Values

YEARLY_PERIOD

public static final int YEARLY_PERIOD
See Also:
Constant Field Values
Constructor Detail

CronLine

public CronLine(String line)
Constructs a CronLine from a string representation of following format: "%d %d %d %d %d" applied to minute, hour, day-of-month, month, day-of-week

Parameters:
line - For example: "55 23 * * 1" which means every Tuesday 23:55
Method Detail

matches

public boolean matches(CronLine pattern)
Matches this cron line againts the parameter and returns true if the param is more general (contains wildcards) or equal.

Parameters:
pattern - pattern to match against
Returns:
true/false

currentCronLine

public static CronLine currentCronLine()
Return a cron line that corresponds to current date and time.

Returns:
and instance of CronLine

createCronLine

public static CronLine createCronLine(Calendar cal)

toString

public String toString()
Overrides:
toString in class Object

shortestPeriod

public int shortestPeriod()
Checks the shortest period of the cron line.

Returns:
period in minutes

get

public String get(int field)
Returns value of a given cron field.

Parameters:
field - cron field number
Returns:

toDate

public Date toDate()
Converts cron entry to date;

Parameters:
cronLine -
Returns:

nextMatchingDate

public Date nextMatchingDate(Date offsetDate)
                      throws CronLineParseException
Finds the next day that matches this CronLine, ignoring the time of day (hr,min,seconds,millis)

Parameters:
offsetDate - The point in time from which the search for a matching date should start
Returns:
Throws:
CronLineParseException


Copyright © 2012. All Rights Reserved.