visidia.simulation.process.messages
Class Message

java.lang.Object
  extended by visidia.simulation.process.messages.Message
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
BooleanMessage, IntegerMessage, NeighborMessage, StringMessage, VectorMessage

public abstract class Message
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

This is the abstract base class representing the messages exchanged between the network nodes. To avoid cross-references (different nodes owning a reference to the same Message), messages must be cloned before being added to the receiver queue.

See Also:
Serialized Form

Constructor Summary
Message()
           
 
Method Summary
abstract  java.lang.Object clone()
          Gives a copy (a clone) of this object.
abstract  java.lang.Object getData()
          Each message has a data which can be accessed by the getData() method.
 int getMsgClock()
          This method allows the user to get the time at which the message has been sent.
 MessageType getType()
          gets the message type.
 boolean getVisualization()
          Checks if the message is to be visualized.
 void setMsgClock(int value)
          This method allows the user to set the time at which the message is sent.
 void setType(MessageType type)
          This method sets the type of a message.
 void setVisualization(boolean s)
          Sets if the message is to be visualized.
abstract  java.lang.String toString()
          Returns a string representation of the message.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Message

public Message()
Method Detail

setMsgClock

public void setMsgClock(int value)
This method allows the user to set the time at which the message is sent.

Parameters:
value - the value

getMsgClock

public int getMsgClock()
This method allows the user to get the time at which the message has been sent.

Returns:
the msg clock

setType

public void setType(MessageType type)
This method sets the type of a message. This is only for the purpose of visualization. Nevertheless, the user can create new message types and use them in his algorithms. The default message type is DefaultMessageType (red, to be visualized, name = default).

Parameters:
type - the type

getType

public MessageType getType()
gets the message type. If the user has set a message type T then the method returns this Type T. Otherwise if no Type has been set, then the default message type is DefaultMessageType.

Returns:
the type

getData

public abstract java.lang.Object getData()
Each message has a data which can be accessed by the getData() method.

Returns:
the data

toString

public abstract java.lang.String toString()
Returns a string representation of the message. This is used for the visualization. For the visualization, it is important to provide a nice implementation for the this.toString() method.

Overrides:
toString in class java.lang.Object
Returns:
the string

getVisualization

public boolean getVisualization()
Checks if the message is to be visualized.

Returns:
true, if the message is to be visualized; false otherwise.

setVisualization

public void setVisualization(boolean s)
Sets if the message is to be visualized.

Parameters:
s - true if the message is to be visualized; false otherwise

clone

public abstract java.lang.Object clone()
Gives a copy (a clone) of this object.

Overrides:
clone in class java.lang.Object
Returns:
the object