public class UnmodifiableMessage extends Object
This class represents those messages an agent receives from other agents.
Unmodifiable messages are unmodifiable in the sense that they can be modified neither by the sender nor by the receiver. All components cloned so that the sender cannot modify them later (e.g., by means of an existing reference to the inner message). Furthermore, all components are either unmodifiable or returned as unmodifiable (collections) so that also the sender cannot change the message.
Constructor and Description |
---|
UnmodifiableMessage(AgentIdentifier sender,
Message message)
Instantiates an unmodifiable message from a sender and a message.
|
UnmodifiableMessage(Message message)
Instantiates an unmodifiable message from a message.
|
Modifier and Type | Method and Description |
---|---|
UnmodifiableMessage |
clone()
Clones this 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).
|
String |
toString()
Returns the string representation of this message.
|
public UnmodifiableMessage(Message message)
message
- the original messageNullPointerException
- if the message is null
public UnmodifiableMessage(AgentIdentifier sender, Message message)
sender
- the sender of the unmodifiable messagemessage
- the original messageNullPointerException
- if the sender is null
NullPointerException
- if the message is null
public CommunicativeAct getPerformative()
Message
getPerformative
in interface Message
public AgentIdentifier getSender()
Message
public SortedSet<AgentIdentifier> getReceivers()
Message
getReceivers
in interface Message
public SortedSet<AgentIdentifier> getReplyTos()
Message
getReplyTos
in interface Message
public SortedMap<UserParameter,String> getUserParameters()
Message
getUserParameters
in interface Message
public UnmodifiableMessage clone()
Message
public String getContent()
Message
getContent
in interface Message
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 LanguageIdentifier getLanguage()
Message
getLanguage
in interface Message
public EncodingIdentifier getEncoding()
Message
getEncoding
in interface Message
public OntologyIdentifier getOntology()
Message
getOntology
in interface Message
public ProtocolIdentifier getProtocol()
Message
getProtocol
in interface Message
public UniqueIdentifier getConversationID()
Message
getConversationID
in interface Message
public UniqueIdentifier getReplyWith()
Message
getReplyWith
in interface Message
public UniqueIdentifier getInReplyTo()
Message
getInReplyTo
in interface Message
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 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 int compareTo(Message other)
compareTo
in interface Comparable<Message>
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.
Copyright © Aimpulse Intelligent Systems GmbH
All rights reserved.