Package com.jalios.jdring
Class AlarmEntry
- java.lang.Object
-
- com.jalios.jdring.AlarmEntry
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<java.lang.Object>
- Direct Known Subclasses:
MailFetcherAlarmEntry
public class AlarmEntry extends java.lang.Object implements java.lang.Comparable<java.lang.Object>, java.io.SerializableThis class contains the attributes of an alarm.- Author:
- Olivier Dedieu, David Sims, Simon Bécot, Jim Lerner, Ralph Schaer
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description longalarmTimeintdayOfMonthintdayOfWeekinthourbooleanisRelativebooleanisRepetitiveAlarmListenerlistenerintminuteintmonthintyear
-
Constructor Summary
Constructors Constructor Description AlarmEntry(int delay, boolean isRepetitive, AlarmListener listener)Creates a new AlarmEntry.AlarmEntry(int minute, int hour, int dayOfMonth, int month, int dayOfWeek, int year, AlarmListener listener)Creates a new AlarmEntry.AlarmEntry(Schedule schedule, AlarmListener listener)Creates a new AlarmEntry.AlarmEntry(java.lang.String schedule, AlarmListener listener)Creates a new AlarmEntry from a (simplified) cron-like schedule.AlarmEntry(java.util.Date date, AlarmListener listener)Creates a new AlarmEntry.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(java.lang.Object obj)Compares this AlarmEntry with the specified AlarmEntry for order.booleanequals(java.lang.Object obj)Indicates whether some other AlarmEntry is "equal to" this one.AlarmListenergetListener()java.util.DategetNextAlarmDate()Returns the next alarm date for this entry.java.lang.StringtoString()Returns a string representation of this alarm.voidupdateAlarmTime()Updates the alarm time for repetitive alarms.
-
-
-
Field Detail
-
minute
public int minute
-
hour
public int hour
-
dayOfMonth
public int dayOfMonth
-
month
public int month
-
dayOfWeek
public int dayOfWeek
-
year
public int year
-
isRelative
public boolean isRelative
-
isRepetitive
public boolean isRepetitive
-
alarmTime
public long alarmTime
-
listener
public transient AlarmListener listener
-
-
Constructor Detail
-
AlarmEntry
public AlarmEntry(java.util.Date date, AlarmListener listener) throws PastDateExceptionCreates a new AlarmEntry.- Parameters:
date- the alarm date to be added.listener- the alarm listener.- Throws:
PastDateException- if the alarm date is in the past (or less than 1 second closed to the current date).
-
AlarmEntry
public AlarmEntry(int delay, boolean isRepetitive, AlarmListener listener) throws PastDateExceptionCreates a new AlarmEntry.- Parameters:
delay- the alarm delay in minute (relative to now).isRepetitive-trueif the alarm must be reactivated,falseotherwise.listener- the alarm listener.- Throws:
PastDateException- if the alarm date is in the past (or less than 1 second closed to the current date).
-
AlarmEntry
public AlarmEntry(int minute, int hour, int dayOfMonth, int month, int dayOfWeek, int year, AlarmListener listener) throws PastDateExceptionCreates a new AlarmEntry.- Parameters:
minute- minute of the alarm. Allowed values 0-59.hour- hour of the alarm. Allowed values 0-23.dayOfMonth- day of month of the alarm (-1 if every day). This attribute is exclusive withdayOfWeek. Allowed values 1-31.month- month of the alarm (-1 if every month). Allowed values 0-11 (0 = January, 1 = February, ...).java.util.Calendarconstants can be used.dayOfWeek- day of week of the alarm (-1 if every day). This attribute is exclusive withdayOfMonth. Allowed values 1-7 (1 = Sunday, 2 = Monday, ...).java.util.Calendarconstants can be used.year- year of the alarm. When this field is not set (i.e. -1) the alarm is repetitive (i.e. it is rescheduled when reached).listener- the alarm listener.- Throws:
PastDateException- if the alarm date is in the past (or less than 1 second closed to the current date).
-
AlarmEntry
public AlarmEntry(Schedule schedule, AlarmListener listener) throws PastDateException
Creates a new AlarmEntry.- Parameters:
schedule-Schedulelinked to this alarmlistener- the alarm listener.- Throws:
PastDateException- if the alarm date is in the past (or less than 1 second closed to the current date).
-
AlarmEntry
public AlarmEntry(java.lang.String schedule, AlarmListener listener) throws PastDateException, java.text.ParseExceptionCreates a new AlarmEntry from a (simplified) cron-like schedule. Schedule format:Minute Hour DayOfMonth Month DayOfWeek YearAsterisks (*) specify when the listener is to be called in every instance of the value of the field. For instance, an asterisk in the Month field would mean that the listener should be called every month. Example:30 10 * * * *: Every days at 10h3030 10 * * 2 *: Every monday at 10h3030 10 1 * * *: The first of the month at 10h30
- Parameters:
schedule- the schedule string in the cron format.listener- the alarm listener.- Throws:
PastDateException- if the alarm date is in the past (or less than 1 second closed to the current date).java.text.ParseException- if the schedule is not a valid schedule string
-
-
Method Detail
-
updateAlarmTime
public void updateAlarmTime()
Updates the alarm time for repetitive alarms.
-
toString
public java.lang.String toString()
Returns a string representation of this alarm.- Overrides:
toStringin classjava.lang.Object- Returns:
- the string.
-
compareTo
public int compareTo(java.lang.Object obj)
Compares this AlarmEntry with the specified AlarmEntry for order.- Specified by:
compareToin interfacejava.lang.Comparable<java.lang.Object>- Parameters:
obj- the AlarmEntry with which to compare.- Returns:
- a negative integer, zero, or a positive integer as this AlarmEntry is less than, equal to, or greater than the given AlarmEntry.
- Throws:
java.lang.ClassCastException- if the specified Object's type prevents it from being compared to this AlarmEntry.
-
equals
public boolean equals(java.lang.Object obj)
Indicates whether some other AlarmEntry is "equal to" this one.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- the AlarmEntry with which to compare.- Returns:
trueif this AlarmEntry has the samealarmTimeas thealarmTimeof the obj argument;falseotherwise.
-
getNextAlarmDate
public java.util.Date getNextAlarmDate()
Returns the next alarm date for this entry.- Returns:
- the next alarm date for this entry.
- Since:
- jcms-5.7.2
-
getListener
public AlarmListener getListener()
- Returns:
- the listener
-
-