madkit.kernel

## Class Message

- java.lang.Object
- - madkit.kernel.Message

- All Implemented Interfaces:
    Serializable, Cloneable
  Direct Known Subclasses:
    ActMessage, ObjectMessage, XMLMessage

      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).
  Version:
    5
  Author:
    Fabien Michel, Olivier Gutknecht
  See Also:
    `AgentAddress`, `AbstractAgent.sendMessage(AgentAddress, Message)`, `AbstractAgent.sendMessage(String, String, String, Message)`, Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Message()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected Message` | `clone()` Returns a shadow copy of the message.
    `ConversationID` | `getConversationID()` returns the conversation ID for this message.
    `AgentAddress` | `getReceiver()` Returns the agent address corresponding to the agent that receive this message.
    `AgentAddress` | `getSender()` Returns the agent address corresponding to the agent that sends this message.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Message

          public Message()

  - ### Method Detail

    - #### getReceiver

          public AgentAddress getReceiver()

      Returns the agent address corresponding to the agent that receive 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:
        `AbstractAgent.sendMessage(AgentAddress, Message)`, `AbstractAgent.sendMessage(String, String, String, Message)`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### clone

          protected Message clone()

      Returns a shadow copy of the message. Message subclasses requiring deep copies of their object fields should override this method. Especially, message cloning is used by `AbstractAgent.broadcastMessage(String, String, String, Message)` and the like to set different receivers for each cloned message.
      Overrides:
        `clone` in class `Object`
      Returns:
        a shadow 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 `AbstractAgent.sendReply(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.

Fabien Michel, Olivier Gutknecht, Jacques Ferber - February 12 2016