com.cometway.util
Class Schedule

java.lang.Object
  extended by com.cometway.util.Schedule
All Implemented Interfaces:
ISchedule

public class Schedule
extends java.lang.Object
implements ISchedule

This class implements ISchedule. There is a set of fields which are public that represent what this schedule is. These can be set by individually or you can use the parser to parse A schedule string (see bottom for syntax). Fields which are not used must remain null. Be very careful when setting the fields individually, the getNextDate() method is very picky about how the fields are set. The getScheduleString() method returns a string which is guaranteed to be parsable by the Schedule parser. You can pass a TimeZone object into the constructor and this Schedule will take place in that time zone.

 DateTime Schedule Notation.
 
 date = mm/dd/yyyy
 time = hh:mm:ss

 [starting startDateTime]
 [every n[y|m|w|d]] | [on [[SU][MO][TU][WE][TH][FI][SA]] | [startDay-endDay]]]
 [between startTime-endTime every n[h|m|s]] |
 [at time1, time2, time3, ...]
 [until endDateTime]

 [starting startDateTime]
 [[every n[y|m|w|d]] | [on [[SU][MO][TU][WE][TH][FR][SA] | [startDay-endDay]]]]
 [[between startTime-endTime every n[h|m|s]] | [at time1,time2,time3]]
 [until endDateTime]
 


Field Summary
 java.util.Vector atTimes
          atTimes: This is a vector of Date objects which hold hours,minutes,and seconds of times to schedule.
static int CUSTOM
           
 boolean[] dayMap
          dayMap[]: This is the days of the week, true=Schedule on this day OK, false=No Schedules on this day
 java.util.Date endDate
          endDate: This is when to end this schedule, time values are not valid.
 java.util.Date endTime
          endTime: This is the ending time, hours,minutes,seconds.
static int EVERY_12_HOURS
           
static int EVERY_3_HOURS
           
static int EVERY_DAY
           
static int EVERY_HALF_HOUR
           
static int EVERY_HOUR
           
static int EVERY_MINUTE
          These are static constants
static int EVERY_TEN_MINUTES
           
static int EVERY_WEEK
           
 int everyDate
          everyDate: This is the number of iterations to make of everyDateType
 int everyDateType
          everyDateType: This is either y,m,w,d (kYears, kMonths, kWeeks, kDays)
 int everyTime
          everyTime: This is like everyDate, except iterations on time, not dates
 int everyTimeType
          everyTimeType: This is either h,m,s (kHours,kMinutes,kSeconds)
 boolean isValid
           
static int kDays
           
static int kHours
           
static int kMinutes
           
static int kMonths
           
static int kSeconds
           
static int kWeeks
           
static int kYears
           
 int maximumLatency
          maximumLatency: This is the maximum number of milliseconds this schedule can be delayed.
 java.util.Date startDate
          startDate: The Year,Month,Week,and Date of the starting Date.
 java.util.Date startTime
          startTime: This is the Hour,Minutes,Seconds of the starting time, date values are not valid
 
Constructor Summary
Schedule()
          You get a Schedule class that is not valid, with TimeZone set to default.
Schedule(java.lang.String input)
          This does the parse for you and sets timezone to host's default.
Schedule(java.lang.String input, java.util.TimeZone tz)
          This does the parse for you and sets the timezone to whatever is passed in.
 
Method Summary
protected  void debug(java.lang.String s)
           
protected  void error(java.lang.String s)
           
protected  void error(java.lang.String s, java.lang.Exception e)
           
 long getMaximumLatency()
          Returns the maximum number of milliseconds each event in this schedule can be delayed before timing out.
 java.util.Date getNextDate(java.util.Date startingAt)
          This returns the next date something is supposed to happen according to the schedule
 java.util.Date getNextDate(java.util.Date startingAt, int recurse)
          This returns the next date something is supposed to happen according to the schedule
 java.util.Date getNextTime(java.util.Date startingAt, java.util.Date dateReference)
          This returns a date with useless information about dates, but valid info on time
 java.lang.String getScheduleString()
          This is the same as toString() except this is parsable and can be reused by another schedule
 int getScheduleType()
           
 boolean isValid()
          This returns the validity of the current schedule
static void main(java.lang.String[] args)
           
protected static void print(java.lang.String s)
           
 void setMaximumLatency(int milliseconds)
           
 boolean setSchedule(java.lang.String input)
          This resets the schedule, removing the current settings, then parses the Schedule String and sets the state variables.
 void setTimeZone(java.util.TimeZone tz)
          This sets the timezone for this schedule.
 java.lang.String toString()
          This returns an Enlgish description of the Schedule
 void update(com.cometway.util.Schedule.pNode pStartDate, com.cometway.util.Schedule.pNode pEveryDate, com.cometway.util.Schedule.pNode pEveryDateType, com.cometway.util.Schedule.pNode pDayMap, com.cometway.util.Schedule.pNode pStartTime, com.cometway.util.Schedule.pNode pEndTime, com.cometway.util.Schedule.pNode pEveryTime, com.cometway.util.Schedule.pNode pEveryTimeType, com.cometway.util.Schedule.pNode pAtTimes, com.cometway.util.Schedule.pNode pEndDate)
          This function parses the data in each node and stores the information in the appropriate type in the appropriate field.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

startDate

public java.util.Date startDate
startDate: The Year,Month,Week,and Date of the starting Date. Time values are not valid


everyDate

public int everyDate
everyDate: This is the number of iterations to make of everyDateType


everyDateType

public int everyDateType
everyDateType: This is either y,m,w,d (kYears, kMonths, kWeeks, kDays)


dayMap

public boolean[] dayMap
dayMap[]: This is the days of the week, true=Schedule on this day OK, false=No Schedules on this day


startTime

public java.util.Date startTime
startTime: This is the Hour,Minutes,Seconds of the starting time, date values are not valid


endTime

public java.util.Date endTime
endTime: This is the ending time, hours,minutes,seconds. Date values are not valid


everyTime

public int everyTime
everyTime: This is like everyDate, except iterations on time, not dates


everyTimeType

public int everyTimeType
everyTimeType: This is either h,m,s (kHours,kMinutes,kSeconds)


atTimes

public java.util.Vector atTimes
atTimes: This is a vector of Date objects which hold hours,minutes,and seconds of times to schedule. Date values are not valid.


endDate

public java.util.Date endDate
endDate: This is when to end this schedule, time values are not valid.


maximumLatency

public int maximumLatency
maximumLatency: This is the maximum number of milliseconds this schedule can be delayed.


EVERY_MINUTE

public static final int EVERY_MINUTE
These are static constants

See Also:
Constant Field Values

EVERY_TEN_MINUTES

public static final int EVERY_TEN_MINUTES
See Also:
Constant Field Values

EVERY_HALF_HOUR

public static final int EVERY_HALF_HOUR
See Also:
Constant Field Values

EVERY_HOUR

public static final int EVERY_HOUR
See Also:
Constant Field Values

EVERY_3_HOURS

public static final int EVERY_3_HOURS
See Also:
Constant Field Values

EVERY_12_HOURS

public static final int EVERY_12_HOURS
See Also:
Constant Field Values

EVERY_DAY

public static final int EVERY_DAY
See Also:
Constant Field Values

EVERY_WEEK

public static final int EVERY_WEEK
See Also:
Constant Field Values

CUSTOM

public static final int CUSTOM
See Also:
Constant Field Values

kYears

public static final int kYears
See Also:
Constant Field Values

kMonths

public static final int kMonths
See Also:
Constant Field Values

kWeeks

public static final int kWeeks
See Also:
Constant Field Values

kDays

public static final int kDays
See Also:
Constant Field Values

kHours

public static final int kHours
See Also:
Constant Field Values

kMinutes

public static final int kMinutes
See Also:
Constant Field Values

kSeconds

public static final int kSeconds
See Also:
Constant Field Values

isValid

public boolean isValid
Constructor Detail

Schedule

public Schedule()
You get a Schedule class that is not valid, with TimeZone set to default.


Schedule

public Schedule(java.lang.String input)
This does the parse for you and sets timezone to host's default.


Schedule

public Schedule(java.lang.String input,
                java.util.TimeZone tz)
This does the parse for you and sets the timezone to whatever is passed in.

Method Detail

isValid

public boolean isValid()
This returns the validity of the current schedule

Specified by:
isValid in interface ISchedule
Returns:
Returns the validity of the schedule

setSchedule

public boolean setSchedule(java.lang.String input)
This resets the schedule, removing the current settings, then parses the Schedule String and sets the state variables.

Specified by:
setSchedule in interface ISchedule
Parameters:
input - This string is parsed as the schedule description
Returns:
This says whether it worked or not

setTimeZone

public void setTimeZone(java.util.TimeZone tz)
This sets the timezone for this schedule. In order for the fields to be valid, the data must be reparsed. The isValid flag is set to false when this method is called.


getNextDate

public java.util.Date getNextDate(java.util.Date startingAt)
This returns the next date something is supposed to happen according to the schedule

Specified by:
getNextDate in interface ISchedule
Parameters:
staringAt - This is the reference date and time which to base results
Returns:
This returns the next Date which something is supposed to happen

getNextDate

public java.util.Date getNextDate(java.util.Date startingAt,
                                  int recurse)
This returns the next date something is supposed to happen according to the schedule

Parameters:
staringAt - This is the reference date and time which to base results
recurse - A panic detector.
Returns:
This returns the next Date which something is supposed to happen

getNextTime

public java.util.Date getNextTime(java.util.Date startingAt,
                                  java.util.Date dateReference)
This returns a date with useless information about dates, but valid info on time

Parameters:
startingAt - This is the reference to try to exceed
dateReference - This is the date reference to use for comparison
Returns:
returns a date with only valid info on time

toString

public java.lang.String toString()
This returns an Enlgish description of the Schedule

Overrides:
toString in class java.lang.Object
Returns:
This is a string of the description in english

getScheduleString

public java.lang.String getScheduleString()
This is the same as toString() except this is parsable and can be reused by another schedule

Specified by:
getScheduleString in interface ISchedule
Returns:
This is a string of the schedule description parsable by another schedule

update

public void update(com.cometway.util.Schedule.pNode pStartDate,
                   com.cometway.util.Schedule.pNode pEveryDate,
                   com.cometway.util.Schedule.pNode pEveryDateType,
                   com.cometway.util.Schedule.pNode pDayMap,
                   com.cometway.util.Schedule.pNode pStartTime,
                   com.cometway.util.Schedule.pNode pEndTime,
                   com.cometway.util.Schedule.pNode pEveryTime,
                   com.cometway.util.Schedule.pNode pEveryTimeType,
                   com.cometway.util.Schedule.pNode pAtTimes,
                   com.cometway.util.Schedule.pNode pEndDate)
This function parses the data in each node and stores the information in the appropriate type in the appropriate field.


main

public static void main(java.lang.String[] args)

getMaximumLatency

public long getMaximumLatency()
Description copied from interface: ISchedule
Returns the maximum number of milliseconds each event in this schedule can be delayed before timing out.

Specified by:
getMaximumLatency in interface ISchedule
Returns:
the maximum number of milliseconds the schedule can be delayed.

setMaximumLatency

public void setMaximumLatency(int milliseconds)

getScheduleType

public int getScheduleType()

print

protected static void print(java.lang.String s)

error

protected void error(java.lang.String s)

error

protected void error(java.lang.String s,
                     java.lang.Exception e)

debug

protected void debug(java.lang.String s)