com.novell.nds.dirxml.util
Class CronSchedule

java.lang.Object
  extended by com.novell.nds.dirxml.util.CronSchedule

public class CronSchedule
extends Object

Class to represent the schedule portion of a crontab-style specification.

See Also:
crontab manpage

Nested Class Summary
static class CronSchedule.Field
          Class representing one field of a crontab schedule specification.
static class CronSchedule.SpecException
          Exception class thrown to indicate a problem with a crontab schedule specification.
 
Constructor Summary
CronSchedule()
          Create a CronSchedule instance.
CronSchedule(String spec)
          Construct a CronSchedule instance according to the passed crontab-style specification.
 
Method Summary
 CronSchedule.Field getDaysOfMonth()
          Return the Field instance containing the "days-of-the-month" schedule.
 CronSchedule.Field getDaysOfWeek()
          Return the Field instance containing the "day-of-the-week" schedule.
 CronSchedule.Field getHours()
          Return the Field instance containing the "hours" schedule.
 CronSchedule.Field getMinutes()
          Return the Field instance containing the "minutes" schedule.
 CronSchedule.Field getMonths()
          Return the Field instance containing the "month-of-the-year" schedule.
 Calendar getNextScheduledTime()
          Return a Calendar instance representing the next instant in time that is scheduled by this CronSchedule instance.
 Calendar getNextScheduledTime(Calendar start)
          Return a Calendar instance representing the next instant in time after the passed time that is scheduled by this CronSchedule instance.
 boolean isScheduled(Calendar time)
          Return true if the passed time is scheduled by this CronSchedule instance.
 void reset()
          Set this instance to the equivalent of "* * * * *".
 String toString()
          Return a string representation of this CronSchedule instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CronSchedule

public CronSchedule()
Create a CronSchedule instance. The created instance is the same as if it had been created by

new CronSchedule("* * * * *")


CronSchedule

public CronSchedule(String spec)
             throws CronSchedule.SpecException
Construct a CronSchedule instance according to the passed crontab-style specification. The passed specification must have the 5 schedule fields defined by crontab.

Parameters:
spec - schedule specification
Throws:
CronSchedule.SpecException - thrown if there is something wrong with the specification string.
Method Detail

reset

public void reset()
Set this instance to the equivalent of "* * * * *".


getMinutes

public CronSchedule.Field getMinutes()
Return the Field instance containing the "minutes" schedule.

Returns:
Field containing minutes

getHours

public CronSchedule.Field getHours()
Return the Field instance containing the "hours" schedule.

Returns:
Field containing hours

getDaysOfMonth

public CronSchedule.Field getDaysOfMonth()
Return the Field instance containing the "days-of-the-month" schedule.

Returns:
Field containing days-of-the-month

getMonths

public CronSchedule.Field getMonths()
Return the Field instance containing the "month-of-the-year" schedule.

Returns:
Field containing month-of-the-year

getDaysOfWeek

public CronSchedule.Field getDaysOfWeek()
Return the Field instance containing the "day-of-the-week" schedule.

Returns:
Field containing day-of-the-week

isScheduled

public boolean isScheduled(Calendar time)
Return true if the passed time is scheduled by this CronSchedule instance.

Parameters:
time - time to check
Returns:
true if scheduled

getNextScheduledTime

public Calendar getNextScheduledTime()
Return a Calendar instance representing the next instant in time that is scheduled by this CronSchedule instance.

This is a convenience method; it behaves as the following:
getNextScheduledTime(Calendar.getInstance())

Returns:
Calendar instance representing the next scheduled time.

getNextScheduledTime

public Calendar getNextScheduledTime(Calendar start)
Return a Calendar instance representing the next instant in time after the passed time that is scheduled by this CronSchedule instance.

Parameters:
start - time from which to calculate the next scheduled time
Returns:
Calendar instance representing the next scheduled time after the passed reference time.

toString

public String toString()
Return a string representation of this CronSchedule instance. This will, in general, be the same string that was used to construct the instance.

Overrides:
toString in class Object
Returns:
crontab-style string