Class Message

java.lang.Object
  extended by Message
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Message>

public class Message
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable<Message>

This class represents the messages sent and received by LPs.

Version:
2.0 (10/2006)
Author:
Yin Xiong
See Also:
Serialized Form

Nested Class Summary
static class Message.MsgType
          Constants representing categories of messages that can be sent.
 
Field Summary
(package private)  java.lang.Object content
          Message content
(package private)  Message.MsgType msgType
          Type of the message, matching one of the constants defined in this class.
(package private)  java.lang.String receiverAPPid
          Receiver's APPid, if receiver is a LogicalProcess, or identifier, if receiver is a monitoring/steering application.
(package private)  int receiverLP
          Receiver's LP number
(package private)  java.lang.String receiverMN
          Receiver's machine name
(package private)  int receiverPE
          Receiver's PE number
(package private)  java.lang.String senderAPPid
          Sender's APPid, if sender is a LogicalProcess, or identifier, if sender is a monitoring/steering application.
(package private)  int senderLP
          Sender's LP number
(package private)  int senderPE
          Sender's PE number
(package private)  int tag
          Tag that indicate whether this message has already been acknowledged by the receiver
(package private)  int timeStamp
          (Simulation) time this message should occur.
 
Constructor Summary
Message(int time, Message.MsgType typ, java.lang.Object cont)
          Preferred constructor; constructs a Message object of undefined origin and destination.
Message(int time, Message.MsgType typ, java.lang.Object cont, java.lang.String sender, java.lang.String receiver)
          Constructs a Message object with preliminary (not complete) addressing.
 
Method Summary
 int compareTo(Message O)
          Compares two Messages' time stamps.
 java.lang.Object getContent()
          Returns the content of the message.
 Message.MsgType getMsgType()
          Returns the type of the message.
 java.lang.String getReceiverAPPid()
          Returns the receiver name.
 int getReceiverLP()
          gets the receiver LP.
 java.lang.String getReceiverMN()
          Returns the machine name of the receive of this message.
 int getReceiverPE()
          Returns the PE id of the receiver of the message.
 java.lang.String getSenderAPPid()
          Returns the sender name.
 int getSenderLP()
          gets the sender LP.
 double getTimeStamp()
          Returns the time stamp of the message.
(package private)  Message makeAntiMsg()
          Returns a copy of the passed-in message with a negative sign.
(package private)  void setMsgType(Message.MsgType typ)
          Sets the message type;
(package private)  void setReceiverAPPid(java.lang.String raid)
          Sets the receiver APPid.
(package private)  void setReceiverLP(int rLP)
          Sets the receiver's LP number.
(package private)  void setReceiverMN(java.lang.String mn)
          Sets the machine name of the receiver of this message.
(package private)  void setReceiverPE(int rPE)
          Sets the receiver's PE number.
(package private)  void setSenderAPPid(java.lang.String said)
          Sets the sender APPid.
(package private)  void setSenderLP(int sLP)
          Sets the sender's LP number.
(package private)  void setSenderPE(int sPE)
          Sets the sender's PE number.
 java.lang.String toString()
          Returns a string representation of the Message object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tag

int tag
Tag that indicate whether this message has already been acknowledged by the receiver


msgType

Message.MsgType msgType
Type of the message, matching one of the constants defined in this class.


timeStamp

int timeStamp
(Simulation) time this message should occur.


content

java.lang.Object content
Message content


senderAPPid

java.lang.String senderAPPid
Sender's APPid, if sender is a LogicalProcess, or identifier, if sender is a monitoring/steering application.


senderLP

int senderLP
Sender's LP number


senderPE

int senderPE
Sender's PE number


receiverAPPid

java.lang.String receiverAPPid
Receiver's APPid, if receiver is a LogicalProcess, or identifier, if receiver is a monitoring/steering application.


receiverLP

int receiverLP
Receiver's LP number


receiverPE

int receiverPE
Receiver's PE number


receiverMN

java.lang.String receiverMN
Receiver's machine name

Constructor Detail

Message

public Message(int time,
               Message.MsgType typ,
               java.lang.Object cont)
Preferred constructor; constructs a Message object of undefined origin and destination. The sender and receiver info must be set later.

Parameters:
time - The local sim time this message occurs.
typ - MsgType of this Message.
cont - Object the content of the message.

Message

public Message(int time,
               Message.MsgType typ,
               java.lang.Object cont,
               java.lang.String sender,
               java.lang.String receiver)
Constructs a Message object with preliminary (not complete) addressing. senderLP, senderPE, receiverLP, and receiverPE must be specified later!

Parameters:
time - The local sim time this message occurs.
typ - MsgType of this Message.
cont - Object the content of the message.
sender - String the APPid of the sender LP.
receiver - String the APPid of the receiver LP.
Method Detail

setReceiverMN

void setReceiverMN(java.lang.String mn)
Sets the machine name of the receiver of this message.

Parameters:
mn - a String object representing the machine name.

getReceiverMN

public java.lang.String getReceiverMN()
Returns the machine name of the receive of this message.


setMsgType

void setMsgType(Message.MsgType typ)
Sets the message type;

Parameters:
typ - MsgType

makeAntiMsg

Message makeAntiMsg()
Returns a copy of the passed-in message with a negative sign.


getReceiverPE

public int getReceiverPE()
Returns the PE id of the receiver of the message.


setSenderPE

void setSenderPE(int sPE)
Sets the sender's PE number.

Parameters:
sPE - int the PE where the sender resides.

setSenderLP

void setSenderLP(int sLP)
Sets the sender's LP number.

Parameters:
sLP - int the LP id of the sender.

setReceiverPE

void setReceiverPE(int rPE)
Sets the receiver's PE number.

Parameters:
rPE - int the PE where the receiver resides.

setReceiverLP

void setReceiverLP(int rLP)
Sets the receiver's LP number.

Parameters:
rLP - int the id of the receiver LP.

setSenderAPPid

void setSenderAPPid(java.lang.String said)
Sets the sender APPid.


setReceiverAPPid

void setReceiverAPPid(java.lang.String raid)
Sets the receiver APPid.


getReceiverLP

public int getReceiverLP()
gets the receiver LP.


getSenderLP

public int getSenderLP()
gets the sender LP.


getSenderAPPid

public java.lang.String getSenderAPPid()
Returns the sender name.


getReceiverAPPid

public java.lang.String getReceiverAPPid()
Returns the receiver name.


getMsgType

public Message.MsgType getMsgType()
Returns the type of the message.


getTimeStamp

public double getTimeStamp()
Returns the time stamp of the message.


getContent

public java.lang.Object getContent()
Returns the content of the message.


toString

public java.lang.String toString()
Returns a string representation of the Message object.

Overrides:
toString in class java.lang.Object

compareTo

public int compareTo(Message O)
Compares two Messages' time stamps. If this Message has an earlier time stamp than the other, it is "less than" it, and a negative number is returned. If this message has a later time stamp, it is "greater" and a positive number is returned. If they have the same time stamp, zero is returned (marking them as "equal"). As such, note: this class has a natural ordering that is inconsistent with equals.

Specified by:
compareTo in interface java.lang.Comparable<Message>