Class Message

java.lang.Object
madkit.kernel.Message
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
ObjectMessage

public class Message extends Object implements Cloneable, Serializable
The generic MaDKit message class. Create Subclasses to adapt it to your needs. This class is quite lightweight, it just defines sender and receivers (expressed with AgentAddress class).
See Also:
  • Constructor Details

    • Message

      public Message()
  • Method Details

    • getReceiver

      public AgentAddress getReceiver()
      Returns the agent address corresponding to the agent that receives this message.
      Returns:
      the receiver
    • getSender

      public AgentAddress getSender()
      Returns the agent address corresponding to the agent that sends this message.
      Returns:
      the message's sender or null if the message has not been sent by an agent, but by any other kind of object.
      See Also:
    • getSenderRole

      public String getSenderRole()
      Returns the role of the agent that sent this message.
      Returns:
      the sender's role or null if the message has not been sent by an agent, but by any other kind of object.
      See Also:
    • toString

      public String toString()
      Returns a string representation of the message.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the message
    • clone

      protected Message clone()
      Returns a shallow copy of the message. Message subclasses requiring deep copies of their object fields should override this method. Especially, message cloning is used by Agent.broadcast(Message, java.util.List) and the like to set different receivers for each cloned message.
      Overrides:
      clone in class Object
      Returns:
      a shallow copy of the message.
    • getConversationID

      public ConversationID getConversationID()
      Returns the conversation ID for this message. When a message is created, it is given an ID that will be used to tag all the messages that will be created for answering this message using Agent.reply(Message, Message) like methods. Especially, if the answer is again used for replying, the ID will be used again to tag this new answer, and so on.
      Returns:
      the ID of the conversation to which this message belongs to.