p2p.simulator.message
Class Message

java.lang.Object
  extended by p2p.simulator.message.Message
All Implemented Interfaces:
java.io.Serializable

public class Message
extends java.lang.Object
implements java.io.Serializable

The class Message creates and manages the messages that are being delivered among peers.

See Also:
Serialized Form

Field Summary
 int method
           
 
Constructor Summary
Message(long src, long dest, MessageBody data)
          Creates a new message.
 
Method Summary
 MessageBody getData()
          Returns the message's data.
 long getDestinationId()
          Returns the peer id of the receiver.
 int getHops()
          Returns the number of times this message has been forwarded.
 int getMethod()
          Returns the transmittion method of the message.
 long getMsgId()
          Returns the unique message's identifier.
 long getSourceId()
          Returns the peer id of the transmitter.
 int getType()
          Returns the message's data type.
 void incHops()
          Increases the number of hops by one.
 void setData(MessageBody data)
          Sets the message data.
 void setDestinationId(long id)
          Sets the peer id of the receiver.
 void setMethod(int meth)
          Sets the message's transmittion method.
 void setSourceId(long id)
          Sets the peer id of the transmitter.
 java.lang.String toString()
          Creates a string with the following message's fields: transmitter's id, receiver's id, type of message, number of hops and their respective values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

method

public int method
Constructor Detail

Message

public Message(long src,
               long dest,
               MessageBody data)
Creates a new message.

Parameters:
src - The peer's id that sends the message.
dest - The peer's id of the message's destination.
data - The message's data.
Method Detail

getSourceId

public long getSourceId()
Returns the peer id of the transmitter.

Returns:
The peer's id.

setSourceId

public void setSourceId(long id)
Sets the peer id of the transmitter.

Parameters:
id - The peer's id.

setDestinationId

public void setDestinationId(long id)
Sets the peer id of the receiver.

Parameters:
id -

getDestinationId

public long getDestinationId()
Returns the peer id of the receiver.

Returns:
The peer id.

getType

public int getType()
Returns the message's data type. The data types declared at MessageT class.

Returns:
The message's data type.

getMsgId

public long getMsgId()
Returns the unique message's identifier.

Returns:
The message's id.

getHops

public int getHops()
Returns the number of times this message has been forwarded.

Returns:
The number of hops.

incHops

public void incHops()
Increases the number of hops by one. This method is used exclusively by the simulator and should not be invoced by the user.


setMethod

public void setMethod(int meth)
Sets the message's transmittion method. The supported methods are point to point, multicast and broadcast.

Parameters:
meth - The transmittion method.

getMethod

public int getMethod()
Returns the transmittion method of the message.

Returns:
The transmittion method.

getData

public MessageBody getData()
Returns the message's data. The data object implements the MessageBody interface.

Returns:
The message's data.

setData

public void setData(MessageBody data)
Sets the message data. The data object implements the MessageBody interface.

Parameters:
data - The messages data.

toString

public java.lang.String toString()
Creates a string with the following message's fields: transmitter's id, receiver's id, type of message, number of hops and their respective values.

Overrides:
toString in class java.lang.Object
Returns:
The message's string represantation.