hudson.scheduler
Class CronTab

java.lang.Object
  extended by hudson.scheduler.CronTab

public final class CronTab
extends Object

Table for driving scheduled tasks.

Author:
Kohsuke Kawaguchi

Constructor Summary
CronTab(String format)
           
CronTab(String format, Hash hash)
           
CronTab(String format, int line)
          Deprecated. as of 1.448 Use CronTab(String, int, Hash)
CronTab(String format, int line, Hash hash)
           
 
Method Summary
 Calendar ceil(Calendar cal)
          See ceil(long).
 Calendar ceil(long t)
          Computes the nearest future timestamp that matches this cron tab.
 String checkSanity()
          Checks if this crontab entry looks reasonable, and if not, return an warning message.
 Calendar floor(Calendar cal)
          See floor(long) This method modifies the given calendar and returns the same object.
 Calendar floor(long t)
          Computes the nearest past timestamp that matched this cron tab.
static String hashify(String spec)
          Checks a prospective crontab specification to see if it could benefit from balanced hashes.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CronTab

public CronTab(String format)
        throws antlr.ANTLRException
Throws:
antlr.ANTLRException

CronTab

public CronTab(String format,
               Hash hash)
        throws antlr.ANTLRException
Throws:
antlr.ANTLRException

CronTab

public CronTab(String format,
               int line)
        throws antlr.ANTLRException
Deprecated. as of 1.448 Use CronTab(String, int, Hash)

Throws:
antlr.ANTLRException

CronTab

public CronTab(String format,
               int line,
               Hash hash)
        throws antlr.ANTLRException
Parameters:
hash - Used to spread out token like "@daily". Null to preserve the legacy behaviour of not spreading it out at all.
Throws:
antlr.ANTLRException
Method Detail

ceil

public Calendar ceil(long t)
Computes the nearest future timestamp that matches this cron tab.

More precisely, given the time 't', computes another smallest time x such that:

Note that if t already matches this cron, it's returned as is.


ceil

public Calendar ceil(Calendar cal)
See ceil(long). This method modifies the given calendar and returns the same object.


floor

public Calendar floor(long t)
Computes the nearest past timestamp that matched this cron tab.

More precisely, given the time 't', computes another smallest time x such that:

Note that if t already matches this cron, it's returned as is.


floor

public Calendar floor(Calendar cal)
See floor(long) This method modifies the given calendar and returns the same object.


toString

public String toString()
Overrides:
toString in class Object

checkSanity

@CheckForNull
public String checkSanity()
Checks if this crontab entry looks reasonable, and if not, return an warning message.

The point of this method is to catch syntactically correct but semantically suspicious combinations, like "* 0 * * *"


hashify

@CheckForNull
public static String hashify(String spec)
Checks a prospective crontab specification to see if it could benefit from balanced hashes.

Parameters:
spec - a (legal) spec
Returns:
a similar spec that uses a hash, if such a transformation is necessary; null if it is OK as is
Since:
1.509


Copyright © 2004-2013. All Rights Reserved.