edu.ksu.cis.cooprobot.simulator.communication
Class Message

java.lang.Object
  extended byedu.ksu.cis.cooprobot.simulator.communication.Message
All Implemented Interfaces:
Serializable

public class Message
extends Object
implements Serializable

This class represents format of message which passes back and forth between robots in the system. The content in a message is composed of

- Sender
- Receiver
- The time that message was sent.
- The expected time that message will be delivered to the receiver.
- The real content of a message

The sent time will be automatically filled in with the current time step By the time message is created the received time will be blank until the message is passed to the process of sending message. The received time will be filled out based on system delay and robot delay.

In order to passing an object across TCP/IP connection, this object must implement Serializable.

Author:
Acharaporn Pattaravanichanon
See Also:
Serialized Form

Field Summary
private  Object content
          The actual content of a message which can be any object.
static Message NULL_MESSAGE
           
private  long receivedTime
          The expected time which message will be delivered to the recipients.
private  String receiver
          Message receiver.
private  String sender
          Message sender
private  long sentTime
          The time which message was sent.
 
Constructor Summary
Message()
          Constructor of Message class
Message(String sender, String receiver, Object content)
          Contructor of Message class
 
Method Summary
 Object getContent()
          Get content of a message
 long getReceivedTime()
          Get expected time which receiver will get this message
 String getReceiver()
          Get receiver name
 String getSender()
          Get sender name
 long getSentTime()
          Get message sent time
 boolean isBroadcastMessage()
          Check if this message is broadcast message.
 boolean isNullMessage()
           
 boolean isP2PMessage()
          Check if this message is point-to-point message.
 void setContent(Object content)
          Set message content
 void setReceivedTime(long time)
          Set expected received time
 void setReceiver(String name)
          Set receiver name
 void setSender(String name)
          Set sender name
 void setSentTime(long time)
          Set message sent time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL_MESSAGE

public static final Message NULL_MESSAGE

sender

private String sender
Message sender


receiver

private String receiver
Message receiver. It can be either robot name or "BROADCAST". "BROADCAST" represents a broadcast message which will be delivered to all robots.


sentTime

private long sentTime
The time which message was sent.


receivedTime

private long receivedTime
The expected time which message will be delivered to the recipients.


content

private Object content
The actual content of a message which can be any object.

Constructor Detail

Message

public Message()
Constructor of Message class


Message

public Message(String sender,
               String receiver,
               Object content)
Contructor of Message class

Parameters:
sender - - message sender
receiver - - message receiver
content - - actual content of message
Method Detail

getSender

public String getSender()
Get sender name

Returns:
sender name

getReceiver

public String getReceiver()
Get receiver name

Returns:
receiver name

getSentTime

public long getSentTime()
Get message sent time

Returns:
time which message was sent

getReceivedTime

public long getReceivedTime()
Get expected time which receiver will get this message

Returns:
expected received time

getContent

public Object getContent()
Get content of a message

Returns:
content

setSender

public void setSender(String name)
Set sender name

Parameters:
name - - sender name

setReceiver

public void setReceiver(String name)
Set receiver name

Parameters:
name - - receiver name

setSentTime

public void setSentTime(long time)
Set message sent time. It is supposed to be current time step.

Parameters:
time - - message sent time

setReceivedTime

public void setReceivedTime(long time)
Set expected received time

Parameters:
time - - expected received time

setContent

public void setContent(Object content)
Set message content

Parameters:
content - - message content

isBroadcastMessage

public boolean isBroadcastMessage()
Check if this message is broadcast message.

Returns:
true if receiver is broadcast, false otherwise

isP2PMessage

public boolean isP2PMessage()
Check if this message is point-to-point message.

Returns:
true if receiver is not broadcast, false otherxise

isNullMessage

public boolean isNullMessage()