core
Class VSTask

java.lang.Object
  extended by core.VSTask
All Implemented Interfaces:
java.lang.Comparable, VSSerializable

public class VSTask
extends java.lang.Object
implements java.lang.Comparable, VSSerializable

The class VSTask, an object of this class represents a task to do or done. All tasks are managed by the task manager. There are local and global timed tasks. Local timed tasks are being fullfilled if the process' local time is reached. Global timed tasks are being fullfilled if the simulator's time is reached.

Author:
Paul C. Buetow

Field Summary
static boolean GLOBAL
          The Constant GLOBAL.
static boolean LOCAL
          The Constant LOCAL.
 
Constructor Summary
VSTask(long taskTime, VSInternalProcess process, VSAbstractEvent event, boolean isLocal)
          Instantiates a new task.
VSTask(VSSerialize serialize, java.io.ObjectInputStream objectInputStream)
          Instantiates a new task during a deserialization.
VSTask(VSTask task)
          Instantiates a new task, it's a copy constructor.
 
Method Summary
 int compareTo(java.lang.Object object)
           
 void deserialize(VSSerialize serialize, java.io.ObjectInputStream objectInputStream)
          Deserializes
 boolean equals(VSTask task)
          Checks if the task equals to another task.
 VSAbstractEvent getEvent()
          Gets the event.
 VSInternalProcess getProcess()
          Gets the process.
 int getTaskNum()
          Gets the task num.
 long getTaskTime()
          Gets the task time.
 boolean hasInternalEvent()
          Checks if the task is using an "internal event".
 boolean hasMessageReceiveEvent()
          Checks if the task is a message receive event.
 boolean hasNotSerializableEvent()
          Checks if the task should not get serialized.
 boolean hasProcessRecoverEvent()
          Checks if the task is a process recover event.
 boolean isGlobalTimed()
          Checks if the task is global timed.
 boolean isProcess(VSInternalProcess process)
          Checks if the task belongs to the specified process.
 boolean isProgrammed()
          Checks if the task is programmed.
 void isProgrammed(boolean isProgrammed)
          Sets if the task is programmed.
 boolean isProtocol(VSAbstractProtocol protocol)
          Checks if the task belongs to the specified protocol object.
 void run()
          Runs the task.
 void serialize(VSSerialize serialize, java.io.ObjectOutputStream objectOutputStream)
          Serializes
 void setProcess(VSInternalProcess process)
          Sets the process.
 void setTaskTime(long taskTime)
          Sets the task time.
 boolean timeOver()
          Checks if the task's time is over.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOCAL

public static final boolean LOCAL
The Constant LOCAL. Used for the constructor if it's a local timed task.

See Also:
Constant Field Values

GLOBAL

public static final boolean GLOBAL
The Constant GLOBAL. Used for the constructor if it's a global timed task.

See Also:
Constant Field Values
Constructor Detail

VSTask

public VSTask(long taskTime,
              VSInternalProcess process,
              VSAbstractEvent event,
              boolean isLocal)
Instantiates a new task.

Parameters:
taskTime - the task time
process - the process
event - the event
isLocal - the taks is local timed

VSTask

public VSTask(VSTask task)
Instantiates a new task, it's a copy constructor.

Parameters:
task - the task to copy

VSTask

public VSTask(VSSerialize serialize,
              java.io.ObjectInputStream objectInputStream)
       throws java.io.IOException,
              java.lang.ClassNotFoundException
Instantiates a new task during a deserialization.

Parameters:
serialize - the serialize object
objectInputStream - The input stream
Throws:
java.io.IOException
java.lang.ClassNotFoundException
Method Detail

getTaskNum

public int getTaskNum()
Gets the task num.

Returns:
the task num

isProgrammed

public void isProgrammed(boolean isProgrammed)
Sets if the task is programmed.

Parameters:
isProgrammed - true, if the task is programmed

isProgrammed

public boolean isProgrammed()
Checks if the task is programmed.

Returns:
true, if the task is programmed

hasInternalEvent

public boolean hasInternalEvent()
Checks if the task is using an "internal event".

Returns:
true, if the task is using an internal event

hasNotSerializableEvent

public boolean hasNotSerializableEvent()
Checks if the task should not get serialized.

Returns:
true, if the task should not get serialized

hasMessageReceiveEvent

public boolean hasMessageReceiveEvent()
Checks if the task is a message receive event.

Returns:
true, if it is a message receive event

hasProcessRecoverEvent

public boolean hasProcessRecoverEvent()
Checks if the task is a process recover event.

Returns:
true, if it is a process recover event

isProtocol

public boolean isProtocol(VSAbstractProtocol protocol)
Checks if the task belongs to the specified protocol object.

Parameters:
protocol - the protocol object to check against.
Returns:
true, if it's a task using the protocol object.

timeOver

public boolean timeOver()
Checks if the task's time is over.

Returns:
true, if it's over

equals

public boolean equals(VSTask task)
Checks if the task equals to another task.

Parameters:
task - the task to compare to
Returns:
true, if equal (the task nums equal)

isProcess

public boolean isProcess(VSInternalProcess process)
Checks if the task belongs to the specified process.

Parameters:
process - the process to check against
Returns:
true, if the task is using the process

isGlobalTimed

public boolean isGlobalTimed()
Checks if the task is global timed.

Returns:
true, if the taks is global timed

getProcess

public VSInternalProcess getProcess()
Gets the process.

Returns:
the process of the event

run

public void run()
Runs the task.


getTaskTime

public long getTaskTime()
Gets the task time.

Returns:
the task time

setTaskTime

public void setTaskTime(long taskTime)
Sets the task time.

Parameters:
taskTime - the task time

setProcess

public void setProcess(VSInternalProcess process)
Sets the process.

Parameters:
process - the process

getEvent

public VSAbstractEvent getEvent()
Gets the event.

Returns:
the event

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

compareTo

public int compareTo(java.lang.Object object)
Specified by:
compareTo in interface java.lang.Comparable

serialize

public void serialize(VSSerialize serialize,
                      java.io.ObjectOutputStream objectOutputStream)
               throws java.io.IOException
Description copied from interface: VSSerializable
Serializes

Specified by:
serialize in interface VSSerializable
Parameters:
serialize - The serialize object
objectOutputStream - The object output stream
Throws:
java.io.IOException

deserialize

public void deserialize(VSSerialize serialize,
                        java.io.ObjectInputStream objectInputStream)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Description copied from interface: VSSerializable
Deserializes

Specified by:
deserialize in interface VSSerializable
Parameters:
serialize - The serialize object
objectInputStream - The object input stream
Throws:
java.io.IOException
java.lang.ClassNotFoundException