com.novell.nds.dirxml.util
Class CronSchedule.Field

java.lang.Object
  extended by com.novell.nds.dirxml.util.CronSchedule.Field
Enclosing class:
CronSchedule

public abstract static class CronSchedule.Field
extends Object

Class representing one field of a crontab schedule specification. The concrete instantiations for Field represent the following 5 crontab fields:

crontab schedule fields
Fieldminimummaximum
Minute059
Hour023
Day of the month131
Month of the year112
Day of the week06


Method Summary
 void addScheduleRange(int start, int end)
          Add a range of scheduled values to those values already scheduled.
 void addScheduleValue(int value)
          Add a single value to those already scheduled.
 void addScheduleValues(int[] values)
          Add several values to be scheduled to those already scheduled.
 boolean allScheduled()
          Return true if all in-range values for this field are scheduled.
 int getMax()
          Return the maximum allowable value for field.
 int getMaxScheduled()
          Return the maximum in-range value that is scheduled by this Field instance.
 int getMin()
          Return the minimum allowable value for field.
 int getMinScheduled()
          Return the minimum in-range value that is scheduled by this Field instance.
 Iterator getScheduledValues()
          Return an Iterator that will iterate over all scheduled values in this Field instance.
 boolean inRange(int checkValue)
          Return true if the passed value falls in the allowable range for this field.
abstract  boolean isScheduled(Calendar time)
          Return true if that part of date/time represented by the passed Calendar instance corresponding to this Field is scheduled.
 boolean isScheduled(int checkValue)
          Return true if the passed value is in the scheduled specification for this Field instance.
 void parse(String spec)
           
 void reset()
          Reset this Field to the equivalent of "*".
 void setScheduleRange(int start, int end)
          Set a range of scheduled values.
 void setScheduleValue(int value)
          Set a single value to be scheduled.
 void setScheduleValues(int[] values)
          Set several values to be scheduled.
 String toString()
          Return the String representation for this Field instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getMin

public int getMin()
Return the minimum allowable value for field.

Returns:
minimum value

getMax

public int getMax()
Return the maximum allowable value for field.

Returns:
maximum value

toString

public String toString()
Return the String representation for this Field instance.

Examples:


parse

public void parse(String spec)
           throws CronSchedule.SpecException
Throws:
CronSchedule.SpecException

reset

public void reset()
Reset this Field to the equivalent of "*". Note that this means all in-range values are scheduled, not that no in-range values are scheduled.


setScheduleRange

public void setScheduleRange(int start,
                             int end)
                      throws CronSchedule.SpecException
Set a range of scheduled values. This clears any previously set scheduled values.

Parameters:
start - beginning of range
end - end (inclusive) of range
Throws:
CronSchedule.SpecException - thrown if start or end are out-of-range.

addScheduleRange

public void addScheduleRange(int start,
                             int end)
                      throws CronSchedule.SpecException
Add a range of scheduled values to those values already scheduled.

Parameters:
start - beginning of range
end - end (inclusive) of range
Throws:
CronSchedule.SpecException - thrown if start or end are out-of-range.

setScheduleValue

public void setScheduleValue(int value)
                      throws CronSchedule.SpecException
Set a single value to be scheduled. This clears any existing scheduled values.

Parameters:
value - the value to be set
Throws:
CronSchedule.SpecException - thrown if value is out-of-range.

addScheduleValue

public void addScheduleValue(int value)
                      throws CronSchedule.SpecException
Add a single value to those already scheduled.

Parameters:
value - the value to be set
Throws:
CronSchedule.SpecException - thrown if value is out-of-range.

setScheduleValues

public void setScheduleValues(int[] values)
                       throws CronSchedule.SpecException
Set several values to be scheduled. This clears any existing scheduled values.

Parameters:
values - a non-null array of zero or more values
Throws:
CronSchedule.SpecException - thrown if any element of values is out-of-range.

addScheduleValues

public void addScheduleValues(int[] values)
                       throws CronSchedule.SpecException
Add several values to be scheduled to those already scheduled.

Parameters:
values - a non-null array of zero or more values
Throws:
CronSchedule.SpecException - thrown if any element of values is out-of-range.

allScheduled

public boolean allScheduled()
Return true if all in-range values for this field are scheduled. Corresponds to a specification of "*" (among other possibilities).

Returns:
true if all in-range values for this field are scheduled.

inRange

public boolean inRange(int checkValue)
Return true if the passed value falls in the allowable range for this field.

Parameters:
checkValue - value to check
Returns:
true if passed value is in range.

isScheduled

public boolean isScheduled(int checkValue)
Return true if the passed value is in the scheduled specification for this Field instance.

Example: For a day-of-the-week specification of "1-5", the passed value 3 will return true.

Parameters:
checkValue - value to check
Returns:
true if passed value is scheduled by this Field.

isScheduled

public abstract boolean isScheduled(Calendar time)
Return true if that part of date/time represented by the passed Calendar instance corresponding to this Field is scheduled.

Example: For a day-of-the-week specification of "1-5", the passed value corresponding to May 30, 2006 10:41 will return true (since May 30, 2006 is a Tuesday).

Parameters:
time - Calendar instance to check.
Returns:
true if passed value is scheduled by this Field.

getMinScheduled

public int getMinScheduled()
Return the minimum in-range value that is scheduled by this Field instance.

Returns:
minimum scheduled value

getMaxScheduled

public int getMaxScheduled()
Return the maximum in-range value that is scheduled by this Field instance.

Returns:
maximum scheduled value

getScheduledValues

public Iterator getScheduledValues()
Return an Iterator that will iterate over all scheduled values in this Field instance.

Returns:
Iterator instance whose next() method returns Integer objects.