Class Message
java.lang.Object
madkit.kernel.Message
- All Implemented Interfaces:
Serializable
,Cloneable
- Direct Known Subclasses:
ObjectMessage
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Message
clone()
Returns a shallow copy of the message.Returns the conversation ID for this message.Returns the agent address corresponding to the agent that receives this message.Returns the agent address corresponding to the agent that sends this message.Returns the role of the agent that sent this message.toString()
Returns a string representation of the message.
-
Constructor Details
-
Message
public Message()
-
-
Method Details
-
getReceiver
Returns the agent address corresponding to the agent that receives this message.- Returns:
- the receiver
-
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
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
-
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 byAgent.broadcast(Message, java.util.List)
and the like to set different receivers for each cloned message. -
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 usingAgent.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.
-