Style Intelligence v12.0

inetsoft.sree.schedule
Class TimeCondition

java.lang.Object
  extended by inetsoft.sree.schedule.TimeCondition
All Implemented Interfaces:
ScheduleCondition, inetsoft.util.XMLSerializable, Serializable

public class TimeCondition
extends Object
implements ScheduleCondition, inetsoft.util.XMLSerializable

TimeCondition is time based schedule condition. It's possible to specify time in a number of different formats: exact time and day, day of month, day of week, and week of month. Time condition and be repeating condition (other than exact time and day). If a time condition is declared to be repeating, the associated task will be rescheduled at the next cycle after it's run.

See Also:
Serialized Form

Field Summary
static int AT
          Time condition type for exact time.
static int DAY_OF_MONTH
          Time condition type for day of month.
static int DAY_OF_WEEK
          Time condition type for day of week.
static int EVERY_DAY
          Time condition type for every day.
static int EVERY_HOUR
          Hour condition type for every month.
static int EVERY_MONTH
          Time condition type for every month.
static int EVERY_WEEK
          Time condition type for every week.
static int LAST_DAY_OF_MONTH
          Last day of a month.
static int WEEK_OF_MONTH
          Time condition type for week of month.
static int WEEK_OF_YEAR
          Time condition type for week of year.
 
Constructor Summary
TimeCondition()
          Create a default time condition.
 
Method Summary
static TimeCondition at(Date time)
          Create a time condition at exact time and date.
static TimeCondition at(int hour, int minute, int second)
          Create a time condition at specified time everyday.
static TimeCondition atDayOfMonth(int day_of_month, int hour, int minute, int second)
          Create a time condition at day of month.
static TimeCondition atDayOfWeek(int day_of_week, int hour, int minute, int second)
          Create a time condition at day of week.
static TimeCondition atDaysOfWeek(int[] days_of_week, int hour, int minute, int second)
          Create a time condition at days of week.
static TimeCondition atHours(int[] days_of_week, int hour, int minute, int second)
          Create a time condition at hours.
static TimeCondition atWeekOfMonth(int week_of_month, int day_of_week, int hour, int minute, int second)
          Create a time condition at week of month.
static TimeCondition atWeekOfYear(int week_of_year, int day_of_week, int hour, int minute, int second)
          Create a time condition at week of year.
 boolean check(long curr)
          Check the condition.
protected  boolean containsIn(int[] arr, int n)
          Check if the array contains the specified element.
 boolean equals(Object val)
           
 Date getDate()
          Get the specified time and day.
 int getDayOfMonth()
          Get day of month.
 int getDayOfWeek()
          Get day of week.
 int[] getDaysOfWeek()
          Get days of week.
 int getHour()
          Get hour of day.
protected  int getHour(int hour, int diff)
          Get the hour.
 int getHourEnd()
          Get end hour of day.
 float getHourlyInterval()
          Get the interval of hour.
protected  int getHourOffset()
           
 int getInterval()
          Get the interval.
 int getMinute()
          Get minute.
 int getMinuteEnd()
          Get end minute.
protected  String getMonthName(int month)
          Get the text month name.
 int[] getMonthsOfYear()
          Get months of year.
 long getRetryTime(long curr)
          Get the next time to retry the condition.
 int getSecond()
          Get second.
 int getSecondEnd()
          Get end second.
 TimeZone getTimeZone()
          Get the time zone of this time condition.
 int getType()
          Get type of this condition.
protected  String getWeekDayName(int day)
          Get the text week day name.
 int getWeekOfMonth()
          Get week of month.
 int getWeekOfYear()
          Get week of year.
 boolean isWeekdayOnly()
          Get if the condition would be skipped if the day is not weekday.
 void parseXML(Element tag)
          Parse itself from an xml file.
 void setDate(Date date)
          Sets the date and time at which the task should be executed.
 void setDayOfMonth(int dayOfMonth)
          Sets the day of the month on which the task should be executed.
 void setDayOfWeek(int dayOfWeek)
          Sets the week day on which the task should be executed.
 void setDaysOfWeek(int[] days_of_week)
          Set days of week.
 void setHour(int hour)
          Sets the hour of the day at which the task should be executed.
 void setHourEnd(int hour)
          Sets the end hour of the day at which the task should be executed.
 void setHourlyInterval(float hourlyInterval)
          Set the interval of hour to repeat the condition.
 void setInterval(int interval)
          Set the interval of days or weeks to repeat the condition.
 void setMinute(int minute)
          Sets the minute of the hour at which the task should be executed.
 void setMinuteEnd(int minute)
          Sets the end minute of the hour at which the task should be executed.
 void setMonthsOfYear(int[] months_of_year)
          Set months of year.
 void setSecond(int second)
          Sets the second at which the task should be executed.
 void setSecondEnd(int second)
          Sets the end second at which the task should be executed.
 void setTimeZone(TimeZone tz)
          Set the timezone of this server.
 void setType(int type)
          Sets the type of this condition.
 void setWeekdayOnly(boolean weekdayOnly)
          Set if the condition should be skipped if the day is Saturday or Sunday.
 void setWeekOfMonth(int weekOfMonth)
          Sets the week of the month in which the task should be executed.
 void setWeekOfYear(int weekOfYear)
          Sets the week of the year in which the task should be executed.
 String toString()
           
protected  void writeAttributes(PrintWriter writer)
           
 void writeXML(PrintWriter writer)
          Write itself to an xml file.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

AT

public static final int AT
Time condition type for exact time.

See Also:
Constant Field Values

EVERY_DAY

public static final int EVERY_DAY
Time condition type for every day.

See Also:
Constant Field Values

DAY_OF_MONTH

public static final int DAY_OF_MONTH
Time condition type for day of month.

See Also:
Constant Field Values

DAY_OF_WEEK

public static final int DAY_OF_WEEK
Time condition type for day of week.

See Also:
Constant Field Values

WEEK_OF_MONTH

public static final int WEEK_OF_MONTH
Time condition type for week of month.

See Also:
Constant Field Values

WEEK_OF_YEAR

public static final int WEEK_OF_YEAR
Time condition type for week of year.

See Also:
Constant Field Values

EVERY_WEEK

public static final int EVERY_WEEK
Time condition type for every week.

See Also:
Constant Field Values

EVERY_MONTH

public static final int EVERY_MONTH
Time condition type for every month.

See Also:
Constant Field Values

EVERY_HOUR

public static final int EVERY_HOUR
Hour condition type for every month.

See Also:
Constant Field Values

LAST_DAY_OF_MONTH

public static final int LAST_DAY_OF_MONTH
Last day of a month. Other days can be derived from this value. For example, second day of end of month is LAST_DAY_OF_MONTH-1.

See Also:
Constant Field Values
Constructor Detail

TimeCondition

public TimeCondition()
Create a default time condition.

Method Detail

getType

public int getType()
Get type of this condition.


setType

public void setType(int type)
Sets the type of this condition.

Parameters:
type - the condition type.

at

public static TimeCondition at(Date time)
Create a time condition at exact time and date.

Parameters:
time - date and time of this condition.

at

public static TimeCondition at(int hour,
                               int minute,
                               int second)
Create a time condition at specified time everyday.

Parameters:
hour - hour of day.
minute - minute in the hour.
second - second in the minute.

atDayOfMonth

public static TimeCondition atDayOfMonth(int day_of_month,
                                         int hour,
                                         int minute,
                                         int second)
Create a time condition at day of month.

Parameters:
day_of_month - day of month.
hour - hour of day.
minute - minute in the hour.
second - second in the minute.

atDayOfWeek

public static TimeCondition atDayOfWeek(int day_of_week,
                                        int hour,
                                        int minute,
                                        int second)
Create a time condition at day of week.

Parameters:
day_of_week - day of week.
hour - hour of day.
minute - minute in the hour.
second - second in the minute.

atDaysOfWeek

public static TimeCondition atDaysOfWeek(int[] days_of_week,
                                         int hour,
                                         int minute,
                                         int second)
Create a time condition at days of week.

Parameters:
days_of_week - day of week.
hour - hour of day.
minute - minute in the hour.
second - second in the minute.

atHours

public static TimeCondition atHours(int[] days_of_week,
                                    int hour,
                                    int minute,
                                    int second)
Create a time condition at hours.

Parameters:
days_of_week - day of week.
hour - hour of day.
minute - minute in the hour.
second - second in the minute.

atWeekOfMonth

public static TimeCondition atWeekOfMonth(int week_of_month,
                                          int day_of_week,
                                          int hour,
                                          int minute,
                                          int second)
Create a time condition at week of month.

Parameters:
week_of_month - week of month.
day_of_week - day of week.
hour - hour of day.
minute - minute in the hour.
second - second in the minute.

atWeekOfYear

public static TimeCondition atWeekOfYear(int week_of_year,
                                         int day_of_week,
                                         int hour,
                                         int minute,
                                         int second)
Create a time condition at week of year.

Parameters:
week_of_year - week of year.
day_of_week - day of week.
hour - hour of day.
minute - minute in the hour.
second - second in the minute.

setTimeZone

public void setTimeZone(TimeZone tz)
Set the timezone of this server.

Parameters:
tz - time zone.

getTimeZone

public TimeZone getTimeZone()
Get the time zone of this time condition.


check

public boolean check(long curr)
Check the condition.

Specified by:
check in interface ScheduleCondition
Parameters:
curr - current time.
Returns:
true if the condition is met.

getRetryTime

public long getRetryTime(long curr)
Get the next time to retry the condition.

Specified by:
getRetryTime in interface ScheduleCondition
Parameters:
curr - current time.
Returns:
the next time to retry. Negative value to stop retry.

toString

public String toString()
Overrides:
toString in class Object

getDate

public Date getDate()
Get the specified time and day.

Returns:
date or null if not exact date.

setDate

public void setDate(Date date)
Sets the date and time at which the task should be executed.

Parameters:
date - the date and time.

getDayOfMonth

public int getDayOfMonth()
Get day of month.

Returns:
day of month or -1 if not specified.

setDayOfMonth

public void setDayOfMonth(int dayOfMonth)
Sets the day of the month on which the task should be executed.

Parameters:
dayOfMonth - the day of the month.

getDayOfWeek

public int getDayOfWeek()
Get day of week.

Returns:
day of week or -1 if not specified.

setDayOfWeek

public void setDayOfWeek(int dayOfWeek)
Sets the week day on which the task should be executed.

Parameters:
dayOfWeek - the week day.

getWeekOfMonth

public int getWeekOfMonth()
Get week of month.

Returns:
week of month or -1 if not specified.

setWeekOfMonth

public void setWeekOfMonth(int weekOfMonth)
Sets the week of the month in which the task should be executed.

Parameters:
weekOfMonth - the week of the month.

getWeekOfYear

public int getWeekOfYear()
Get week of year.

Returns:
week of year or -1 if not specified.

setWeekOfYear

public void setWeekOfYear(int weekOfYear)
Sets the week of the year in which the task should be executed.

Parameters:
weekOfYear - the week of the year.

getHour

public int getHour()
Get hour of day.


setHour

public void setHour(int hour)
Sets the hour of the day at which the task should be executed.

Parameters:
hour - the hour of the day.

getMinute

public int getMinute()
Get minute.


setMinute

public void setMinute(int minute)
Sets the minute of the hour at which the task should be executed.

Parameters:
minute - the minute of the hour.

getSecond

public int getSecond()
Get second.


setSecond

public void setSecond(int second)
Sets the second at which the task should be executed.

Parameters:
second - the second value.

getHourEnd

public int getHourEnd()
Get end hour of day.


setHourEnd

public void setHourEnd(int hour)
Sets the end hour of the day at which the task should be executed.

Parameters:
hour - the end hour of the day.

getMinuteEnd

public int getMinuteEnd()
Get end minute.


setMinuteEnd

public void setMinuteEnd(int minute)
Sets the end minute of the hour at which the task should be executed.

Parameters:
minute - the end minute of the hour.

getSecondEnd

public int getSecondEnd()
Get end second.


setSecondEnd

public void setSecondEnd(int second)
Sets the end second at which the task should be executed.

Parameters:
second - the end second value.

getInterval

public int getInterval()
Get the interval.


setInterval

public void setInterval(int interval)
Set the interval of days or weeks to repeat the condition.


getHourlyInterval

public float getHourlyInterval()
Get the interval of hour.


setHourlyInterval

public void setHourlyInterval(float hourlyInterval)
Set the interval of hour to repeat the condition.


isWeekdayOnly

public boolean isWeekdayOnly()
Get if the condition would be skipped if the day is not weekday.


setWeekdayOnly

public void setWeekdayOnly(boolean weekdayOnly)
Set if the condition should be skipped if the day is Saturday or Sunday.


getDaysOfWeek

public int[] getDaysOfWeek()
Get days of week.


setDaysOfWeek

public void setDaysOfWeek(int[] days_of_week)
Set days of week.


getMonthsOfYear

public int[] getMonthsOfYear()
Get months of year.


setMonthsOfYear

public void setMonthsOfYear(int[] months_of_year)
Set months of year.


getHour

protected int getHour(int hour,
                      int diff)
Get the hour.


writeXML

public void writeXML(PrintWriter writer)
Write itself to an xml file.

Specified by:
writeXML in interface inetsoft.util.XMLSerializable

getHourOffset

protected int getHourOffset()

writeAttributes

protected void writeAttributes(PrintWriter writer)

parseXML

public void parseXML(Element tag)
              throws Exception
Parse itself from an xml file.

Specified by:
parseXML in interface inetsoft.util.XMLSerializable
Throws:
Exception

getWeekDayName

protected String getWeekDayName(int day)
Get the text week day name.

Parameters:
day - day of week.

getMonthName

protected String getMonthName(int month)
Get the text month name.

Parameters:
month - month of year.

equals

public boolean equals(Object val)
Overrides:
equals in class Object

containsIn

protected boolean containsIn(int[] arr,
                             int n)
Check if the array contains the specified element.


Copyright © 1996-2014 InetSoft Technology Corp. All Rights Reserved.