public class RecurringTimeEvent extends RecurringEvent
System.currentTimeMillis()
, and the time between occurences is given in milliseconds. If the time that
the event occurs is before start()
is called, the event occurs as soon as it is called, and will reoccur
repeatedly in order to "catch-up". See Timer.scheduleAtFixedRate(java.util.TimerTask,Date,long)
for a description of this.System.currentTimeMillis()
Modifier and Type | Field and Description |
---|---|
private long |
firstTime
The first time this event should occur.
|
private EventTask |
task
Recorded TimerTask needed if this TimeEvent is canceled.
|
private long |
timeBetweenOcurrences
long indicating the number of milliseconds between
occurrences of this event. |
DEFAULT_PRIORITY, FIRE_EVENT, HIGHEST_PRIORITY
Constructor and Description |
---|
RecurringTimeEvent(String newType,
PolicyAgentInterface agent,
long newFirstTime,
long newTimeBetweenOccurrences)
Creates a new RecurringTimeEvent that first occurs at the given time and
repeats at the given rate.
|
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancels the timer task so it will not get queued for execution
|
void |
start()
Starts the timer so that this event can occur.
|
void |
start(boolean queueOnlyIfNotAlreadyQueued)
Starts the timer so that this event can occur.
|
delete, isRecurring, toString
clone, compareTo, fireEvent, getEventType, getID, getOwnerConversationID, getParameter, getPriority, getQueueTime, hasFired, keySet, setOwnerConversationID, setParameter, setParameters, setPriority, setQueueTime
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addObserver, countObservers, deleteObserver
private long firstTime
System.currentTimeMillis()
.private long timeBetweenOcurrences
long
indicating the number of milliseconds between
occurrences of this event.public RecurringTimeEvent(String newType, PolicyAgentInterface agent, long newFirstTime, long newTimeBetweenOccurrences)
newType
- The type of the new event.agent
- The agent that this event will be queued tonewFirstTime
- The time when this event should first occur.newTimeBetweenOccurrences
- The time in milliseconds between this
event's occurrences.public void start()
Timer.scheduleAtFixedRate(TimerTask, Date, long)
to
schedule the event.start
in interface Event
start
in class RecurringEvent
public void start(boolean queueOnlyIfNotAlreadyQueued)
Timer.scheduleAtFixedRate(TimerTask, Date, long)
to
schedule the event.public void cancel()
cancel
in class RecurringEvent