public class TimeEvent extends NonRecurringEvent
System.currentTimeMillis()
. If the time that the event occurs is before
start()
is called, the event occurs as soon as it is called.System.currentTimeMillis()
Modifier and Type | Field and Description |
---|---|
private EventTask |
task
Recorded TimerTask needed if this TimeEvent is canceled.
|
private long |
time
The time the event occurs.
|
protected static Timer |
TIMER
This is a shared
Timer object that is used by all TimeEvents to
schedule the activations of events. |
DEFAULT_PRIORITY, FIRE_EVENT, HIGHEST_PRIORITY
Constructor and Description |
---|
TimeEvent(String newType,
PolicyAgentInterface agent,
long newTime)
Creates a new TimeEvent that occurs at the given time.
|
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.
|
isRecurring
clone, compareTo, delete, fireEvent, getEventType, getID, getOwnerConversationID, getParameter, getPriority, getQueueTime, hasFired, keySet, setOwnerConversationID, setParameter, setParameters, setPriority, setQueueTime, toString
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addObserver, countObservers, deleteObserver
protected static final Timer TIMER
Timer
object that is used by all TimeEvents to
schedule the activations of events. By sharing the timer object, all timer
events use only a single thread.private final long time
System.currentTimeMillis()
.public TimeEvent(String newType, PolicyAgentInterface agent, long newTime)
newType
- The type of the new event.agent
- The agent that this event will be queued to.newTime
- The time when this event should occur.public void start()
Timer.schedule(TimerTask, Date)
to schedule the event.start
in interface Event
start
in class NonRecurringEvent
public void cancel()