cz.zcu.fav.kiv.jsim
Class JSimCalendarEvent

java.lang.Object
  |
  +--cz.zcu.fav.kiv.jsim.JSimCalendarEvent
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable, java.io.Serializable

public class JSimCalendarEvent
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable, java.lang.Cloneable

A JSimCalendarEvent represents one wake-up event in a J-Sim calendar. It contains information about a process and a time point when the process should be activated. You should never need to create an instance of this class. Note: This class has a natural ordering that is inconsistent with equals().

Since:
J-Sim version 0.0.1
Version:
J-Sim version 0.3.0
Author:
Jarda KAČER
See Also:
Serialized Form

Field Summary
private  long creationTime
          The real (wallclock) time of the event's creation.
private  JSimProcess process
          The process to be activated (woken up).
private  long processNumber
          The process's number.
private  double time
          The simulation time point the process is scheduled for.
 
Constructor Summary
JSimCalendarEvent(double time, JSimProcess process)
          Creates a new calendar event with the specified time and process.
 
Method Summary
 java.lang.Object clone()
          Makes a shallow copy of the calendar event and returns it.
 int compareTo(java.lang.Object o)
          Compares this event with another one.
protected  long getCreationTime()
          Returns this event's creation time.
 JSimProcess getProcess()
          Returns the process referred to by the event.
 long getProcessNumber()
          Returns the number of the process referred to by the event.
 double getTime()
          Returns the absolute activation time of the event.
 java.lang.String toString()
          Returns a string representation of the calendar event.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

time

private double time
The simulation time point the process is scheduled for.


process

private transient JSimProcess process
The process to be activated (woken up). It is not serialized.


processNumber

private long processNumber
The process's number. This field is serialized instead of the process itself.


creationTime

private long creationTime
The real (wallclock) time of the event's creation. Used only for deterministic ordering of events in the calendar (later created, later interpreted).

Constructor Detail

JSimCalendarEvent

public JSimCalendarEvent(double time,
                         JSimProcess process)
                  throws java.lang.NullPointerException
Creates a new calendar event with the specified time and process.

Parameters:
process - The process to be activated.
Throws:
java.lang.NullPointerException - This exception is thrown out if the process to be activated is null.
Method Detail

getTime

public double getTime()
Returns the absolute activation time of the event.

Returns:
The activation time of the event.

getProcess

public JSimProcess getProcess()
Returns the process referred to by the event.

Returns:
The process referred to by the event.

getProcessNumber

public long getProcessNumber()
Returns the number of the process referred to by the event.

Returns:
The number of the process referred to by the event.

getCreationTime

protected long getCreationTime()
Returns this event's creation time. The creation time is measured in milliseconds and it is equal to the difference between the current time and midnight January 1 1970.

Returns:
The event's creation time.

compareTo

public int compareTo(java.lang.Object o)
Compares this event with another one. Returns a negative integer, zero, or a positive integer as this event is less than, equal to, or greater than the specified object. It is assumed that the argument is also a JSimCalendarEvent. Note: This class has a natural ordering that is inconsistent with equals().

Specified by:
compareTo in interface java.lang.Comparable
Returns:
Zero (0) if both the corresponding simulation time and the real time of creation are equal, (-1) if the simulation time (or the creation time when the simulation times are equal) of this event is less than the other event's simulation time, and (+1) if the simulation time of this event is greater than the other event's time.
Throws:
java.lang.ClassCastException - This exception is thrown out when the specified object cannot be typecasted to JSimCalendarEvent.

toString

public java.lang.String toString()
Returns a string representation of the calendar event. It consists of the corresponding process name, the simulation time when the process will be activated and the real time of the event's creation.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of the calendar event.

clone

public java.lang.Object clone()
Makes a shallow copy of the calendar event and returns it. Preserves the simulation time, the real time of creation (although it does not correspond with the reality after cloning), the process number and the process itself. The process is not cloned, just a reference is assigned.

Overrides:
clone in class java.lang.Object
Returns:
A copy of the calendar event.


Copyright © 2000-2004 University of West Bohemia, FAV-KIV. All Rights Reserved. Build date 20040510.