org.mbari.siam.distributed
Class ScheduleSpecifier

java.lang.Object
  extended by org.mbari.siam.distributed.ScheduleSpecifier
All Implemented Interfaces:
java.io.Serializable, Importable

public class ScheduleSpecifier
extends java.lang.Object
implements java.io.Serializable, Importable

The ScheduleSpecifier class implements the portion of a schedule (entry) that specifies at what times the job portion of the schedule is to be executed.

See Also:
Serialized Form

Nested Class Summary
protected  class ScheduleSpecifier.FieldSpec
          Token information parsed into FieldSpec (interpreted by adjustRelative() and adjustAbsolute())
protected  class ScheduleSpecifier.Range
          Class describing a range (#-#|#)
 
Field Summary
static java.lang.String[] _dayNames
          Names of days of the week
protected static org.apache.log4j.Logger _logger
          Log4j logger
static java.lang.String[] _monthNames
          Names of months
static int CYCLES
          Position of CYCLES field in schedule entry
static int DAYS
          Position of DAYS field in schedule entry
static int DAYS_OF_MONTH
          Position of DAYS_OF_MONTH field in schedule entry
static int DAYS_OF_WEEK
          Position of DAYS_OF_WEEK field in schedule entry
static int DAYS_OF_YEAR
          Position of DAYS_OF_YEAR field in schedule entry
static java.lang.String DEFAULT_DISPLAY_NAME
          Default value of DISPLAY_NAME field
static java.lang.String DEFAULT_JOB
          Default value of JOB field
static java.lang.String DEFAULT_SCHEDULE_NAME
           
static int DISPLAY_NAME
          Position of DISPLAY_NAME field in schedule entry
static int HOURS
          Position of HOURS field in schedule entry
static int JOB
          Position of JOB field in schedule entry
static int MAX_DAY_OF_MONTH
          Max day of month
static int MAX_DAY_OF_WEEK
          Max day of week
static int MAX_DAY_OF_YEAR
          Max day of year day
static int MAX_FIELD
          Number of fields
static int MAX_HOUR
          Max hour
static int MAX_MINUTE
          Max minute
static int MAX_MONTH
          Max month
static int MAX_SECOND
          Max second
static int MIN_DAY_OF_MONTH
          Min day of month
static int MIN_DAY_OF_WEEK
          Min day of week
static int MIN_DAY_OF_YEAR
          Min day of year
static int MIN_HOUR
          Min hour
static int MIN_LENGTH
          Min length of valid entry 10 fields + 9 whitespace
static int MIN_MINUTE
          Min minute
static int MIN_MONTH
          Min month
static int MIN_SECOND
          Min second
static int MINUTES
          Position of MINUTES field in schedule entry
static int MONTHS
          Position of MONTHS field in schedule entry
static long MS_PER_DAY
          ms per day
static long MS_PER_HOUR
          ms per hour
static long MS_PER_MINUTE
          ms per minute
static long MS_PER_SECOND
          ms per second
static long S_PER_DAY
          s per day
static int SCHEDULE_TIME
          Time fields only
static int SCHEDULE_TYPE
          Position of SCHEDULE_TYPE field in schedule entry
static int SECONDS
          Position of SECONDS field in schedule entry
static int TIME_ZONE
          Position of TIME_ZONE field in schedule entry
 
Constructor Summary
ScheduleSpecifier()
          Default vanilla constructor
ScheduleSpecifier(long periodMsec)
          Construct simple (relative schedule) Specifier from period Only exection period is computed.
ScheduleSpecifier(java.lang.String spec)
          Construct Specifier from schedule entry string
 
Method Summary
 void computePeriod()
          Compute period of execution (for relative schedules)
protected  int dayIndex(java.lang.String name)
          dayIndex() compares token to day names and returns the (numeric) day or -1 if not a day name.
 boolean equals(ScheduleSpecifier schedule)
          Compare two ScheduleEntries
 java.lang.Object fromString(java.lang.String mnemonic)
          Parse from string; fulfills Importable interface
 java.lang.String get(int field)
          Get a field
 boolean[] getBDaysOfMonth()
          Get _bDaysOfMonth field
 boolean[] getBDaysOfWeek()
          Get _bDaysOfWeek field
 boolean[] getBDaysOfYear()
          Get _bDaysOfYear field
 boolean[] getBHours()
          Get _bHours field
 boolean[] getBMinutes()
          Get _bMinutes field
 boolean[] getBMonths()
          Get _bMonths field
 boolean[] getBSeconds()
          Get _bSeconds field
 java.lang.String getCycles()
          Get _cycles field
 java.lang.String getDays()
          Get _days field
 java.lang.String getDaysOfMonth()
          Get _daysOfMonth field
 java.lang.String getDaysOfWeek()
          Get _daysOfWeek field
 java.lang.String getDaysOfYear()
          Get _daysOfYear field
 java.lang.String getDisplayName()
          Get _displayName field
 java.lang.String getFieldName(int position)
          Get name of field
 java.lang.String getHours()
          Get _hours field
 java.lang.String getJob()
          Get _job field
 java.lang.String getLine()
          Get _line field
 long getLongCycles()
          Get _longCycles field
protected  long getLongIndex(java.lang.String token)
          getLongIndex() checks token for numeric or name and returns index or -1 if no match is found.
 java.lang.String getMinutes()
          Get _minutes field
 java.lang.String getMonths()
          Get _Months field
 long getPeriod()
          Get _period field
 java.lang.String getScheduleTime()
          Get schedule time part of line (no job)
 java.lang.String getScheduleType()
          Get _scheduleType field
 java.lang.String getSeconds()
          Get _seconds field
 java.lang.String getTimeZone()
          Get _timeZone field
 java.util.TimeZone getTZ()
          Get _tzTimezone
protected  void initInterval(long intervalMillis)
          Set up a (relative) schedule specifier given a sample interval in milliseconds.
 boolean isAbsolute()
          Get _bAbsolute field
 boolean isRelative()
          Get _bRelative field
 boolean isSelectedTime(java.util.Calendar calendar)
          Compare calendar to mask/schedule boolean arrays
protected  long longIndex(java.lang.String token)
          longIndex() checks token to see if it's a valid numeric index (>=0) Returns number if valid, -1 if invalid.
static void main(java.lang.String[] args)
          Eine Kleine test code
protected  int monthIndex(java.lang.String name)
          monthIndex() compares token to month names and returns the (numeric) month or -1 if not a month name.
protected  int numberIndex(java.lang.String token)
          numberIndex() checks token to see if it's a valid numeric index (>=0) Returns number if valid, -1 if invalid.
static void parse(ScheduleSpecifier thisOne, java.lang.String line)
          parse a line from the schedule file.
protected  ScheduleSpecifier.FieldSpec parseToken(java.lang.String token, long maxRange)
          Parse a single token into a FieldSpec representation.
 boolean[] processToken(ScheduleSpecifier.FieldSpec fieldSpec, boolean[] barray)
          Interpret token; fill out operation masks
 void set(int field, java.lang.String spec)
          Set field (re-parse spec and set field accordingly)
 void setBAbsolute(boolean bAbsolute)
          Set _bAbsolute field
 void setBDaysOfMonth(boolean[] daysOfMonth)
          Set _bDaysOfMonth field
 void setBDaysOfWeek(boolean[] daysOfWeek)
          Set _bDaysOfWeek field
 void setBDaysOfYear(boolean[] daysOfYear)
          Set _bDaysOfYear field
 void setBHours(boolean[] hours)
          Set _bHours field
 void setBMinutes(boolean[] minutes)
          Set _bMinutes field
 void setBMonths(boolean[] months)
          Set _bMonths field
 void setBRelative(boolean bRelative)
          Set _bRelative field
 void setBScheduleType(java.lang.String type)
          Set _BScheduleType field
 void setBSeconds(boolean[] seconds)
          Set _bSeconds field
 void setCycles(java.lang.String cycles)
          Set _cycles field
 void setDays(java.lang.String days)
          Set _days field
 void setDaysOfMonth(java.lang.String daysOfMonth)
          Set _daysOfMonth field
 void setDaysOfWeek(java.lang.String daysOfWeek)
          Set _daysOfWeek field
 void setDaysOfYear(java.lang.String daysOfYear)
          Set _daysOfYear field
 void setDisplayName(java.lang.String displayName)
          Set _displayName field
 void setHours(java.lang.String hours)
          Set _hours field
 void setJob(java.lang.String job)
          Set _job field
 void setLine(java.lang.String line)
          Set _Line field
 void setLongCycles(long cycles)
          Set _longCycles field
 void setMinutes(java.lang.String minutes)
          Set _minutes field
 void setMonths(java.lang.String months)
          Set _Months field
 void setScheduleType(java.lang.String type)
          Set _scheduleType field
 void setSeconds(java.lang.String seconds)
          Set _seconds field
 void setTimeZone(java.lang.String timeZone)
          Set _timeZone field
 java.lang.String toString()
          toString() convert schedule entry to string Note: The output order is important since the parse() method must be able use this exported form of the ScheduleSpecifier.
 void validateTimezone(java.lang.String timezone)
          Checks _timezone field to see if it's valid
 java.lang.String[] validValues()
          Return array of valid string values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_SCHEDULE_NAME

public static final java.lang.String DEFAULT_SCHEDULE_NAME
See Also:
Constant Field Values

_logger

protected static org.apache.log4j.Logger _logger
Log4j logger


MIN_LENGTH

public static final int MIN_LENGTH
Min length of valid entry 10 fields + 9 whitespace

See Also:
Constant Field Values

MAX_DAY_OF_YEAR

public static final int MAX_DAY_OF_YEAR
Max day of year day

See Also:
Constant Field Values

MIN_DAY_OF_YEAR

public static final int MIN_DAY_OF_YEAR
Min day of year

See Also:
Constant Field Values

MAX_MONTH

public static final int MAX_MONTH
Max month

See Also:
Constant Field Values

MIN_MONTH

public static final int MIN_MONTH
Min month

See Also:
Constant Field Values

MAX_DAY_OF_MONTH

public static final int MAX_DAY_OF_MONTH
Max day of month

See Also:
Constant Field Values

MIN_DAY_OF_MONTH

public static final int MIN_DAY_OF_MONTH
Min day of month

See Also:
Constant Field Values

MAX_DAY_OF_WEEK

public static final int MAX_DAY_OF_WEEK
Max day of week

See Also:
Constant Field Values

MIN_DAY_OF_WEEK

public static final int MIN_DAY_OF_WEEK
Min day of week

See Also:
Constant Field Values

MAX_HOUR

public static final int MAX_HOUR
Max hour

See Also:
Constant Field Values

MIN_HOUR

public static final int MIN_HOUR
Min hour

See Also:
Constant Field Values

MAX_MINUTE

public static final int MAX_MINUTE
Max minute

See Also:
Constant Field Values

MIN_MINUTE

public static final int MIN_MINUTE
Min minute

See Also:
Constant Field Values

MAX_SECOND

public static final int MAX_SECOND
Max second

See Also:
Constant Field Values

MIN_SECOND

public static final int MIN_SECOND
Min second

See Also:
Constant Field Values

MS_PER_SECOND

public static final long MS_PER_SECOND
ms per second

See Also:
Constant Field Values

MS_PER_MINUTE

public static final long MS_PER_MINUTE
ms per minute

See Also:
Constant Field Values

MS_PER_HOUR

public static final long MS_PER_HOUR
ms per hour

See Also:
Constant Field Values

MS_PER_DAY

public static final long MS_PER_DAY
ms per day

See Also:
Constant Field Values

S_PER_DAY

public static final long S_PER_DAY
s per day

See Also:
Constant Field Values

SCHEDULE_TYPE

public static final int SCHEDULE_TYPE
Position of SCHEDULE_TYPE field in schedule entry

See Also:
Constant Field Values

SECONDS

public static final int SECONDS
Position of SECONDS field in schedule entry

See Also:
Constant Field Values

MINUTES

public static final int MINUTES
Position of MINUTES field in schedule entry

See Also:
Constant Field Values

HOURS

public static final int HOURS
Position of HOURS field in schedule entry

See Also:
Constant Field Values

DAYS

public static final int DAYS
Position of DAYS field in schedule entry

See Also:
Constant Field Values

MONTHS

public static final int MONTHS
Position of MONTHS field in schedule entry

See Also:
Constant Field Values

DAYS_OF_WEEK

public static final int DAYS_OF_WEEK
Position of DAYS_OF_WEEK field in schedule entry

See Also:
Constant Field Values

DAYS_OF_MONTH

public static final int DAYS_OF_MONTH
Position of DAYS_OF_MONTH field in schedule entry

See Also:
Constant Field Values

DAYS_OF_YEAR

public static final int DAYS_OF_YEAR
Position of DAYS_OF_YEAR field in schedule entry

See Also:
Constant Field Values

TIME_ZONE

public static final int TIME_ZONE
Position of TIME_ZONE field in schedule entry

See Also:
Constant Field Values

CYCLES

public static final int CYCLES
Position of CYCLES field in schedule entry

See Also:
Constant Field Values

JOB

public static final int JOB
Position of JOB field in schedule entry

See Also:
Constant Field Values

DISPLAY_NAME

public static final int DISPLAY_NAME
Position of DISPLAY_NAME field in schedule entry

See Also:
Constant Field Values

MAX_FIELD

public static final int MAX_FIELD
Number of fields

See Also:
Constant Field Values

SCHEDULE_TIME

public static final int SCHEDULE_TIME
Time fields only

See Also:
Constant Field Values

_dayNames

public static final java.lang.String[] _dayNames
Names of days of the week


_monthNames

public static final java.lang.String[] _monthNames
Names of months


DEFAULT_JOB

public static final java.lang.String DEFAULT_JOB
Default value of JOB field

See Also:
Constant Field Values

DEFAULT_DISPLAY_NAME

public static final java.lang.String DEFAULT_DISPLAY_NAME
Default value of DISPLAY_NAME field

See Also:
Constant Field Values
Constructor Detail

ScheduleSpecifier

public ScheduleSpecifier()
Default vanilla constructor


ScheduleSpecifier

public ScheduleSpecifier(java.lang.String spec)
                  throws ScheduleParseException
Construct Specifier from schedule entry string

Throws:
ScheduleParseException

ScheduleSpecifier

public ScheduleSpecifier(long periodMsec)
                  throws ScheduleParseException
Construct simple (relative schedule) Specifier from period Only exection period is computed. No masks are set.

Throws:
ScheduleParseException
Method Detail

initInterval

protected void initInterval(long intervalMillis)
                     throws ScheduleParseException
Set up a (relative) schedule specifier given a sample interval in milliseconds.

Throws:
ScheduleParseException

getFieldName

public java.lang.String getFieldName(int position)
Get name of field


getScheduleType

public java.lang.String getScheduleType()
Get _scheduleType field


setScheduleType

public void setScheduleType(java.lang.String type)
                     throws ScheduleParseException
Set _scheduleType field

Throws:
ScheduleParseException

setBScheduleType

public void setBScheduleType(java.lang.String type)
Set _BScheduleType field


isRelative

public boolean isRelative()
Get _bRelative field


setBRelative

public void setBRelative(boolean bRelative)
Set _bRelative field


isAbsolute

public boolean isAbsolute()
Get _bAbsolute field


setBAbsolute

public void setBAbsolute(boolean bAbsolute)
Set _bAbsolute field


getBMonths

public boolean[] getBMonths()
Get _bMonths field


setBMonths

public void setBMonths(boolean[] months)
Set _bMonths field


getBDaysOfMonth

public boolean[] getBDaysOfMonth()
Get _bDaysOfMonth field


setBDaysOfMonth

public void setBDaysOfMonth(boolean[] daysOfMonth)
Set _bDaysOfMonth field


getBDaysOfYear

public boolean[] getBDaysOfYear()
Get _bDaysOfYear field


setBDaysOfYear

public void setBDaysOfYear(boolean[] daysOfYear)
Set _bDaysOfYear field


getBDaysOfWeek

public boolean[] getBDaysOfWeek()
Get _bDaysOfWeek field


setBDaysOfWeek

public void setBDaysOfWeek(boolean[] daysOfWeek)
Set _bDaysOfWeek field


getBHours

public boolean[] getBHours()
Get _bHours field


setBHours

public void setBHours(boolean[] hours)
Set _bHours field


getBMinutes

public boolean[] getBMinutes()
Get _bMinutes field


setBMinutes

public void setBMinutes(boolean[] minutes)
Set _bMinutes field


getBSeconds

public boolean[] getBSeconds()
Get _bSeconds field


setBSeconds

public void setBSeconds(boolean[] seconds)
Set _bSeconds field


getLongCycles

public long getLongCycles()
Get _longCycles field


setLongCycles

public void setLongCycles(long cycles)
Set _longCycles field


getTimeZone

public java.lang.String getTimeZone()
Get _timeZone field


setTimeZone

public void setTimeZone(java.lang.String timeZone)
                 throws ScheduleParseException
Set _timeZone field

Throws:
ScheduleParseException

getTZ

public java.util.TimeZone getTZ()
Get _tzTimezone


getMonths

public java.lang.String getMonths()
Get _Months field


setMonths

public void setMonths(java.lang.String months)
               throws ScheduleParseException
Set _Months field

Throws:
ScheduleParseException

getDays

public java.lang.String getDays()
Get _days field


setDays

public void setDays(java.lang.String days)
             throws ScheduleParseException
Set _days field

Throws:
ScheduleParseException

getDaysOfYear

public java.lang.String getDaysOfYear()
Get _daysOfYear field


setDaysOfYear

public void setDaysOfYear(java.lang.String daysOfYear)
                   throws ScheduleParseException
Set _daysOfYear field

Throws:
ScheduleParseException

getDaysOfMonth

public java.lang.String getDaysOfMonth()
Get _daysOfMonth field


setDaysOfMonth

public void setDaysOfMonth(java.lang.String daysOfMonth)
                    throws ScheduleParseException
Set _daysOfMonth field

Throws:
ScheduleParseException

getDaysOfWeek

public java.lang.String getDaysOfWeek()
Get _daysOfWeek field


setDaysOfWeek

public void setDaysOfWeek(java.lang.String daysOfWeek)
                   throws ScheduleParseException
Set _daysOfWeek field

Throws:
ScheduleParseException

getHours

public java.lang.String getHours()
Get _hours field


setHours

public void setHours(java.lang.String hours)
              throws ScheduleParseException
Set _hours field

Throws:
ScheduleParseException

getMinutes

public java.lang.String getMinutes()
Get _minutes field


setMinutes

public void setMinutes(java.lang.String minutes)
                throws ScheduleParseException
Set _minutes field

Throws:
ScheduleParseException

getSeconds

public java.lang.String getSeconds()
Get _seconds field


setSeconds

public void setSeconds(java.lang.String seconds)
                throws ScheduleParseException
Set _seconds field

Throws:
ScheduleParseException

getCycles

public java.lang.String getCycles()
Get _cycles field


setCycles

public void setCycles(java.lang.String cycles)
               throws ScheduleParseException
Set _cycles field

Throws:
ScheduleParseException

getPeriod

public long getPeriod()
Get _period field


getJob

public java.lang.String getJob()
Get _job field


setJob

public void setJob(java.lang.String job)
Set _job field


getDisplayName

public java.lang.String getDisplayName()
Get _displayName field


setDisplayName

public void setDisplayName(java.lang.String displayName)
Set _displayName field


getLine

public java.lang.String getLine()
Get _line field


setLine

public void setLine(java.lang.String line)
Set _Line field


getScheduleTime

public java.lang.String getScheduleTime()
Get schedule time part of line (no job)


parse

public static void parse(ScheduleSpecifier thisOne,
                         java.lang.String line)
                  throws ScheduleParseException
parse a line from the schedule file.

Throws:
ScheduleParseException

get

public java.lang.String get(int field)
Get a field


set

public void set(int field,
                java.lang.String spec)
         throws ScheduleParseException
Set field (re-parse spec and set field accordingly)

Throws:
ScheduleParseException

parseToken

protected ScheduleSpecifier.FieldSpec parseToken(java.lang.String token,
                                                 long maxRange)
                                          throws ScheduleParseException
Parse a single token into a FieldSpec representation. (Token is the token to be parsed (1-3,*,10/2 etc.)) Interpretation is left to other methods, depending on whether the schedule entry is absolute or relative.

Throws:
ScheduleParseException

processToken

public boolean[] processToken(ScheduleSpecifier.FieldSpec fieldSpec,
                              boolean[] barray)
Interpret token; fill out operation masks


validateTimezone

public void validateTimezone(java.lang.String timezone)
                      throws ScheduleParseException
Checks _timezone field to see if it's valid

Throws:
ScheduleParseException

getLongIndex

protected long getLongIndex(java.lang.String token)
getLongIndex() checks token for numeric or name and returns index or -1 if no match is found.


numberIndex

protected int numberIndex(java.lang.String token)
numberIndex() checks token to see if it's a valid numeric index (>=0) Returns number if valid, -1 if invalid.


longIndex

protected long longIndex(java.lang.String token)
longIndex() checks token to see if it's a valid numeric index (>=0) Returns number if valid, -1 if invalid.


dayIndex

protected int dayIndex(java.lang.String name)
dayIndex() compares token to day names and returns the (numeric) day or -1 if not a day name.


monthIndex

protected int monthIndex(java.lang.String name)
monthIndex() compares token to month names and returns the (numeric) month or -1 if not a month name.


toString

public java.lang.String toString()
toString() convert schedule entry to string Note: The output order is important since the parse() method must be able use this exported form of the ScheduleSpecifier.

Overrides:
toString in class java.lang.Object

equals

public boolean equals(ScheduleSpecifier schedule)
Compare two ScheduleEntries


isSelectedTime

public boolean isSelectedTime(java.util.Calendar calendar)
Compare calendar to mask/schedule boolean arrays


computePeriod

public void computePeriod()
Compute period of execution (for relative schedules)


fromString

public java.lang.Object fromString(java.lang.String mnemonic)
                            throws InvalidPropertyException
Parse from string; fulfills Importable interface

Specified by:
fromString in interface Importable
Throws:
InvalidPropertyException

validValues

public java.lang.String[] validValues()
Return array of valid string values.


main

public static void main(java.lang.String[] args)
Eine Kleine test code



Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.