jasi.sim.basic.event
Class EventAdapter

java.lang.Object
  extended by jasi.sim.basic.event.EventAdapter

public final class EventAdapter
extends java.lang.Object

Basic implementation of methods and behavior for all simulation events. This class can be used, when simulation can not extend the class EventBean

See Also:
AbstractEventBean

Constructor Summary
EventAdapter(Event event, Id id)
          Construct an event.
 
Method Summary
 void addEventListener(EventListener listener)
          Add a model for this event.
 int compareTo(Event event, Event e)
          Compares that object with the specified object for order.
 boolean equals(Event event, java.lang.Object o)
          Indicates whether some other object is "equal to" that event.
 java.util.Collection<EventListener> getEventListeners()
          Get the unmodifiable collection of the event listeners for this event.
 Id getId()
          Retrieve the event's ID.
 int getPriority()
          Retrieve the event's priority.
 Time getTime()
          Retrieve the event's time.
 int hashCode(Event event)
          Returns a hash code value for that event.
 void imported()
          This event was pushed to a calendar.
 boolean isInitialized()
          Check, if this event has just been created.
 boolean isPopped()
          Check, if this event has already been popped and executed.
 boolean isPushed()
          Check, if this event has already been pushed to a calendar.
 Event popped(Event event)
          This event was popped from a calendar.
 Event pushed(Event event)
          This event was pushed to a calendar.
 void removeEventListener(EventListener listener)
          Remove a model for this event.
 void setId(Event event, Id id)
          Set the event's ID.
 void setPriority(Event event, int priority)
          Initialize the event's priority.
 void setTime(Event event, Time time)
          Initialize the event's time.
 java.lang.String toString(Event event)
          Returns a string representation of that event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventAdapter

public EventAdapter(Event event,
                    Id id)
Construct an event.

Parameters:
event - That event.
id - The ID.
Method Detail

imported

public void imported()
This event was pushed to a calendar. This method should only be called by the calendar, where this event has been added to.


pushed

public Event pushed(Event event)
This event was pushed to a calendar. This method should only be called by the calendar, where this event has been added to.

Parameters:
event - That event.
Returns:
This pushed event.

popped

public Event popped(Event event)
This event was popped from a calendar. All its listeners will be informed to handle or execute this event. Then the list of event listeners will be cleared.

Parameters:
event - That event.
Returns:
This popped event.

toString

public java.lang.String toString(Event event)
Returns a string representation of that event.

Parameters:
event - That event.
Returns:
The string.

hashCode

public int hashCode(Event event)
Returns a hash code value for that event. This method is supported for the benefit of hash tables.

Parameters:
event - That event.
Returns:
A hash code value for that event.

equals

public boolean equals(Event event,
                      java.lang.Object o)
Indicates whether some other object is "equal to" that event. This method compares the events' time, priority and ID.

Parameters:
event - That event.
o - That object which is compared with this object.
Returns:
True, if this object is the same as that object.

compareTo

public int compareTo(Event event,
                     Event e)
Compares that object with the specified object for order. Implementation of java.lang.Comparable interface. The events are compared in the order of the following conditions:
  1. Event with earlier time
  2. higher priority
  3. smaller ID first

Parameters:
event - That event.
e - The event to be compared.
Returns:
A negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

isInitialized

public boolean isInitialized()
Check, if this event has just been created.

Returns:
True, if event has just been created.

isPushed

public boolean isPushed()
Check, if this event has already been pushed to a calendar.

Returns:
True, if event has already been pushed.

isPopped

public boolean isPopped()
Check, if this event has already been popped and executed.

Returns:
True, if event has already popped.

getEventListeners

public java.util.Collection<EventListener> getEventListeners()
Get the unmodifiable collection of the event listeners for this event.

Returns:
The event listener collection.

addEventListener

public void addEventListener(EventListener listener)
Add a model for this event. Each model that shall be informed about handling this event, has to be added to the model list of this event.

Parameters:
listener - The model to handle the event.

removeEventListener

public void removeEventListener(EventListener listener)
Remove a model for this event.

Parameters:
listener - The model to handle the event.

setId

public void setId(Event event,
                  Id id)
Set the event's ID. Each simulation element obtains during its registration at the calendar (pushing) a unique, increasing number for identification. If ID is already set, it will not be changed.

Parameters:
event - That event.
id - The ID.

getId

public Id getId()
Retrieve the event's ID. Each simulation event obtains during its registration at the calendar (pushing) a unique, increasing number for identification.

Returns:
The ID.

setTime

public void setTime(Event event,
                    Time time)
Initialize the event's time. The event's priority must be set previous to its time.

Parameters:
event - That event.
time - The event's time.
Throws:
EventAlreadyInitializedException - Whenever already initialized.

getTime

public Time getTime()
Retrieve the event's time.

Returns:
The time of this event.

setPriority

public void setPriority(Event event,
                        int priority)
Initialize the event's priority. The event's priority must be set previous to its time.

Parameters:
event - That event.
priority - The event's priority.
Throws:
EventAlreadyInitializedException - Whenever already initialized.

getPriority

public int getPriority()
Retrieve the event's priority. A higher priority corresponds to a greater integer value.

Returns:
The priority of this event.