cz.zcu.fav.kiv.jsim
Class JSimCalendarEvent

java.lang.Object
  extended by cz.zcu.fav.kiv.jsim.JSimCalendarEvent
All Implemented Interfaces:
java.lang.Comparable<JSimCalendarEvent>

public class JSimCalendarEvent
extends java.lang.Object
implements java.lang.Comparable<JSimCalendarEvent>

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.6.0
Author:
Jarda KAČER

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
 int compareTo(JSimCalendarEvent ce)
          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
clone, 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 JSimProcess process
The process to be activated (woken up).


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:
time - The absolute simulation time (not a delta) of activation.
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(JSimCalendarEvent ce)
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<JSimCalendarEvent>
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.


Copyright © 2000-2006 University of West Bohemia. Licensed under the Academic Free License v. 2.1. Build date 20060812.