public class ReplyMessage extends Object
Creates a modifiable message that is a reply to a previous message. Components related to conversation control (protocol, conversation-id, reply-to, receivers) and content description (language and ontology) are then prepared automatically for the reply.
Reply messages can be instantiated via the message builder.
MessageBuilder
,
Serialized FormModifier and Type | Method and Description |
---|---|
void |
addReceiver(AgentIdentifier receiver)
Adds a receiver of the message.
|
void |
addReplyTo(AgentIdentifier replyTo)
Adds a reply-to of the message.
|
void |
addUserParameter(UserParameter parameter)
Adds a user-defined parameter without value of the message.
|
void |
addUserParameter(UserParameter parameter,
String value)
Adds a user-defined parameter of the message.
|
void |
clearReceivers()
Deletes all receivers of the message.
|
void |
clearReplyTos()
Deletes all reply-tos of the message.
|
void |
clearUserParameters()
Deletes all user-defined parameters of the message.
|
com.aimpulse.spectrum.mas.messaging.DefaultModifiableMessage |
clone()
Clones this modifiable message.
|
int |
compareTo(Message other) |
boolean |
equals(Object object) |
String |
getContent()
Returns the content of the message.
|
Serializable |
getContentObject()
Returns the content object of the message.
|
byte[] |
getContentObjectBytes()
Returns (a copy of) the content object of the message as an array of
bytes.
|
UniqueIdentifier |
getConversationID()
Returns the conversation-id of the message (part of the conversation
control).
|
EncodingIdentifier |
getEncoding()
Returns the encoding of the message (part of the content description).
|
UniqueIdentifier |
getInReplyTo()
Returns the in-reply-to of the message (part of the conversation
control).
|
LanguageIdentifier |
getLanguage()
Returns the language of the message (part of the content description).
|
OntologyIdentifier |
getOntology()
Returns the ontology of the message (part of the content description).
|
CommunicativeAct |
getPerformative()
Returns the type of communicative act.
|
ProtocolIdentifier |
getProtocol()
Returns the protocol of the message (part of the conversation control).
|
SortedSet<AgentIdentifier> |
getReceivers()
Returns the (unmodifiable) set of receivers of the message.
|
Timestamp |
getReplyBy()
Returns the reply-by of the message (part of the conversation control).
|
SortedSet<AgentIdentifier> |
getReplyTos()
Returns the (unmodifiable) set of reply-tos of the message.
|
UniqueIdentifier |
getReplyWith()
Returns the reply-with of the message (part of the conversation control).
|
AgentIdentifier |
getSender()
Returns the sender of the message.
|
String |
getUserParameter(UserParameter parameter)
Returns the value of the specified user-defined parameter of the message.
|
SortedMap<UserParameter,String> |
getUserParameters()
Returns the (unmodifiable) map of user-defined parameters of the message.
|
int |
hashCode() |
boolean |
hasUserParameter(UserParameter parameter)
Checks if a user-defined parameter is set for a message (including those
cases in which the parameter is set without a value).
|
static void |
prepareReplyConversationControl(Message message,
ModifiableMessage reply)
Prepares a message regarding its conversation control as a reply to an
original message.
|
boolean |
removeReceiver(AgentIdentifier receiver)
Removes a receiver of the message.
|
boolean |
removeReplyTo(AgentIdentifier replyTo)
Removes a reply-to of the message.
|
String |
removeUserParameter(UserParameter parameter)
Removes a user-defined parameter of the message based on its key.
|
void |
setContent(String content)
Sets the content of the message.
|
void |
setContentObject(Serializable contentObject)
Sets the content of the message to the serializable object provided.
|
void |
setContentObjectBytes(byte[] bytes)
Sets the content of the message to the byte-serializabled object
provided.
|
void |
setConversationID(UniqueIdentifier conversationID)
Sets the conversation-id of the message (part of the conversation
control).
|
void |
setEncoding(EncodingIdentifier encoding)
Sets the encoding of the message (part of the content description).
|
void |
setInReplyTo(UniqueIdentifier inReplyTo)
Sets the in-reply-to of the message (part of the conversation control).
|
void |
setLanguage(LanguageIdentifier language)
Sets the language of the message (part of the content description).
|
void |
setOntology(OntologyIdentifier ontology)
Sets the ontology of the message (part of the content description).
|
void |
setPerformative(CommunicativeAct performative)
Sets the type of communicative act.
|
void |
setProtocol(ProtocolIdentifier protocol)
Sets the protocol of the message (part of the conversation control).
|
void |
setReplyBy(Timestamp replyBy)
Sets the reply-by of the message (part of the conversation control).
|
void |
setReplyWith(UniqueIdentifier replyWith)
Sets the reply-with of the message (part of the conversation control).
|
String |
toString()
Returns the string representation of this message.
|
void |
unsetContent()
Unsets the content of the message.
|
void |
unsetContentObject()
Unsets the content object of the message.
|
void |
unsetConversationID()
Unsets the conversation-id of the message.
|
void |
unsetEncoding()
Unsets the encoding of the message.
|
void |
unsetInReplyTo()
Unsets the in-reply-to of the message.
|
void |
unsetLanguage()
Unsets the language of the message.
|
void |
unsetOntology()
Unsets the ontology of the message.
|
void |
unsetProtocol()
Unsets the protocol of the message.
|
void |
unsetReplyBy()
Unsets the reply-by of the message.
|
void |
unsetReplyWith()
Unsets the reply-with of the message.
|
public static void prepareReplyConversationControl(Message message, ModifiableMessage reply)
message
- the original messagereply
- the reply to be preparedpublic void setPerformative(CommunicativeAct performative)
ModifiableMessage
setPerformative
in interface ModifiableMessage
performative
- the type of communicative actpublic CommunicativeAct getPerformative()
Message
getPerformative
in interface Message
public AgentIdentifier getSender()
Message
public void addReceiver(AgentIdentifier receiver)
ModifiableMessage
addReceiver
in interface ModifiableMessage
receiver
- a receiver of the messagepublic boolean removeReceiver(AgentIdentifier receiver)
ModifiableMessage
removeReceiver
in interface ModifiableMessage
receiver
- a receiver of the messagetrue
if the receiver was on the set of receivers,
false
otherwisepublic void clearReceivers()
ModifiableMessage
clearReceivers
in interface ModifiableMessage
public SortedSet<AgentIdentifier> getReceivers()
Message
getReceivers
in interface Message
public void addReplyTo(AgentIdentifier replyTo)
ModifiableMessage
addReplyTo
in interface ModifiableMessage
replyTo
- a reply-to of the messagepublic boolean removeReplyTo(AgentIdentifier replyTo)
ModifiableMessage
removeReplyTo
in interface ModifiableMessage
replyTo
- a reply-to of the messagetrue
if the reply-to was on the set of reply-tos,
false
otherwisepublic void clearReplyTos()
ModifiableMessage
clearReplyTos
in interface ModifiableMessage
public SortedSet<AgentIdentifier> getReplyTos()
Message
getReplyTos
in interface Message
public void setContent(String content)
ModifiableMessage
setContent
in interface ModifiableMessage
content
- the content of the messagepublic void unsetContent()
ModifiableMessage
unsetContent
in interface ModifiableMessage
public String getContent()
Message
getContent
in interface Message
public void setContentObject(Serializable contentObject) throws IOException
ModifiableMessage
setContentObject
in interface ModifiableMessage
contentObject
- the content object of the messageIOException
- if the object cannot be serializedpublic void setContentObjectBytes(byte[] bytes) throws UnreadableException
ModifiableMessage
setContentObjectBytes
in interface ModifiableMessage
bytes
- the byte-serializabled content object of the messageUnreadableException
- if the object cannot be deserializedpublic void unsetContentObject()
ModifiableMessage
unsetContentObject
in interface ModifiableMessage
public Serializable getContentObject() throws UnreadableException
Message
getContentObject
in interface Message
UnreadableException
- if the content object cannot be readpublic byte[] getContentObjectBytes()
Message
getContentObjectBytes
in interface Message
public void setLanguage(LanguageIdentifier language)
ModifiableMessage
setLanguage
in interface ModifiableMessage
language
- the language of the messagepublic void unsetLanguage()
ModifiableMessage
unsetLanguage
in interface ModifiableMessage
public LanguageIdentifier getLanguage()
Message
getLanguage
in interface Message
public void setEncoding(EncodingIdentifier encoding)
ModifiableMessage
setEncoding
in interface ModifiableMessage
encoding
- the encoding of the messagepublic void unsetEncoding()
ModifiableMessage
unsetEncoding
in interface ModifiableMessage
public EncodingIdentifier getEncoding()
Message
getEncoding
in interface Message
public void setOntology(OntologyIdentifier ontology)
ModifiableMessage
setOntology
in interface ModifiableMessage
ontology
- the ontology of the messagepublic void unsetOntology()
ModifiableMessage
unsetOntology
in interface ModifiableMessage
public OntologyIdentifier getOntology()
Message
getOntology
in interface Message
public void setProtocol(ProtocolIdentifier protocol)
ModifiableMessage
setProtocol
in interface ModifiableMessage
protocol
- the protocol of the messagepublic void unsetProtocol()
ModifiableMessage
unsetProtocol
in interface ModifiableMessage
public ProtocolIdentifier getProtocol()
Message
getProtocol
in interface Message
public void setConversationID(UniqueIdentifier conversationID)
ModifiableMessage
setConversationID
in interface ModifiableMessage
conversationID
- the conversation-id of the messagepublic void unsetConversationID()
ModifiableMessage
unsetConversationID
in interface ModifiableMessage
public UniqueIdentifier getConversationID()
Message
getConversationID
in interface Message
public void setReplyWith(UniqueIdentifier replyWith)
ModifiableMessage
setReplyWith
in interface ModifiableMessage
replyWith
- the reply-with of the messagepublic void unsetReplyWith()
ModifiableMessage
unsetReplyWith
in interface ModifiableMessage
public UniqueIdentifier getReplyWith()
Message
getReplyWith
in interface Message
public void setInReplyTo(UniqueIdentifier inReplyTo)
ModifiableMessage
setInReplyTo
in interface ModifiableMessage
inReplyTo
- the in-reply-to of the messagepublic void unsetInReplyTo()
ModifiableMessage
unsetInReplyTo
in interface ModifiableMessage
public UniqueIdentifier getInReplyTo()
Message
getInReplyTo
in interface Message
public void setReplyBy(Timestamp replyBy)
ModifiableMessage
setReplyBy
in interface ModifiableMessage
replyBy
- the reply-by of the messagepublic void unsetReplyBy()
ModifiableMessage
unsetReplyBy
in interface ModifiableMessage
public Timestamp getReplyBy()
Message
Timestamp
object and never null. If no explicit reply-by date has
been set, the maximum possible timestamp should be returned.getReplyBy
in interface Message
public void addUserParameter(UserParameter parameter)
ModifiableMessage
addUserParameter
in interface ModifiableMessage
parameter
- the key of the user-defined parameter of the messagepublic void addUserParameter(UserParameter parameter, String value)
ModifiableMessage
addUserParameter
in interface ModifiableMessage
parameter
- the user-defined parameter of the messagevalue
- the value of the user-defined parameter of the messagepublic String removeUserParameter(UserParameter parameter)
ModifiableMessage
removeUserParameter
in interface ModifiableMessage
parameter
- the user-defined parameter to be removedpublic void clearUserParameters()
ModifiableMessage
clearUserParameters
in interface ModifiableMessage
public boolean hasUserParameter(UserParameter parameter)
Message
hasUserParameter
in interface Message
parameter
- the user-defined parametertrue
if the user-defined parameter is set,
false
otherwiseMessage.getUserParameter(UserParameter)
public String getUserParameter(UserParameter parameter) throws NoSuchElementException
Message
getUserParameter
in interface Message
parameter
- the user-defined parameterNoSuchElementException
- if the user-defined parameter is not setMessage.hasUserParameter(UserParameter)
public SortedMap<UserParameter,String> getUserParameters()
Message
getUserParameters
in interface Message
public com.aimpulse.spectrum.mas.messaging.DefaultModifiableMessage clone()
ModifiableMessage
public String toString()
Message
Returns the string representation of this message.
Note that messages are quite complex objects. Consequently, an implementation of this method might also be computationally demanding. Furthermore, caching the string representation might not be advisable because it can be quite memory-consuming. Therefore, this method should better not be used excessively.
public int compareTo(Message other)
compareTo
in interface Comparable<Message>
Copyright © Aimpulse Intelligent Systems GmbH
All rights reserved.