public class ACLMessage extends Object implements Cloneable, Serializable
private final String
.
All values can be set by using the methods set and can be read by using
the methods get.
Warning: since JADE 3.1 an exception might be thrown during the serialization of the ACLMessage parameters (with exception of the content of the ACLMessage) because of a limitation to 65535 in the total number of bytes needed to represent all the characters of a String (see also java.io.DataOutput#writeUTF(String)).
The methods setByteSequenceContent()
and
getByteSequenceContent()
allow to send arbitrary
sequence of bytes
over the content of an ACLMessage.
The couple of methods
setContentObject()
and
getContentObject()
allow to send
serialized Java objects over the content of an ACLMessage.
These method are not strictly
FIPA compliant so their usage is not encouraged.
Modifier and Type | Field and Description |
---|---|
static int |
ACCEPT_PROPOSAL
constant identifying the FIPA performative
|
static int |
AGREE
constant identifying the FIPA performative
|
static String |
AMS_FAILURE_AGENT_NOT_FOUND
AMS failure reasons
|
static String |
AMS_FAILURE_AGENT_UNREACHABLE |
static String |
AMS_FAILURE_FOREIGN_AGENT_NO_ADDRESS |
static String |
AMS_FAILURE_FOREIGN_AGENT_UNREACHABLE |
static String |
AMS_FAILURE_SERVICE_ERROR |
static String |
AMS_FAILURE_UNAUTHORIZED |
static String |
AMS_FAILURE_UNEXPECTED_ERROR |
private byte[] |
byteSequenceContent |
static int |
CANCEL
constant identifying the FIPA performative
|
static int |
CFP
constant identifying the FIPA performative
|
static int |
CONFIRM
constant identifying the FIPA performative
|
private StringBuffer |
content |
private String |
conversation_id |
private ArrayList |
dests |
static int |
DISCONFIRM
constant identifying the FIPA performative
|
private String |
encoding |
static int |
FAILURE
constant identifying the FIPA performative
|
static String |
IGNORE_FAILURE
User defined parameter key specifying, when set to "true", that if the delivery of a
message fails, no FAILURE notification has to be sent back to the sender.
|
private String |
in_reply_to |
static int |
INFORM
constant identifying the FIPA performative
|
static int |
INFORM_IF
constant identifying the FIPA performative
|
static int |
INFORM_REF
constant identifying the FIPA performative
|
private String |
language |
private Envelope |
messageEnvelope |
static String |
NO_CLONE
User defined parameter key specifying that this message does not need to be cloned by the message delivery service.
|
static int |
NOT_UNDERSTOOD
constant identifying the FIPA performative
|
private String |
ontology |
private int |
performative |
private static String[] |
performatives
This array of Strings keeps the names of the performatives
|
private Long |
persistentID |
static String |
POST_TIME_STAMP
User defined parameter key specifying that the corresponding value must be replaced by the JADE runtime
by an ISO8601 encoded time-stamp at posting time.
|
static int |
PROPAGATE
constant identifying the FIPA performative
|
static int |
PROPOSE
constant identifying the FIPA performative
|
private String |
protocol |
static int |
PROXY
constant identifying the FIPA performative
|
static int |
QUERY_IF
constant identifying the FIPA performative
|
static int |
QUERY_REF
constant identifying the FIPA performative
|
private static int |
RECEIVERS_EXPECTED_SIZE
These constants represent the expected size of the 2 array lists
used by this class
|
static int |
REFUSE
constant identifying the FIPA performative
|
static int |
REJECT_PROPOSAL
constant identifying the FIPA performative
|
private long |
reply_byInMillisec |
private ArrayList |
reply_to |
private String |
reply_with |
private static int |
REPLYTO_EXPECTED_SIZE |
static int |
REQUEST
constant identifying the FIPA performative
|
static int |
REQUEST_WHEN
constant identifying the FIPA performative
|
static int |
REQUEST_WHENEVER
constant identifying the FIPA performative
|
private static long |
serialVersionUID |
private AID |
source |
static int |
SUBSCRIBE
constant identifying the FIPA performative
|
static String |
SYNCH_DELIVERY
User defined parameter key specifying that this message must be delivered synchronously.
|
static String |
TRACE
User defined parameter key specifying that the JADE tracing mechanism should be activated for this message.
|
static int |
UNKNOWN
constant identifying an unknown performative
|
private Properties |
userDefProps |
Constructor and Description |
---|
ACLMessage()
Deprecated.
Since every ACL Message must have a message type, you
should use the new constructor which gets a message type as a
parameter. To avoid problems, now this constructor silently sets
the message type to
not-understood . |
ACLMessage(int perf)
This constructor creates an ACL message object with the specified
performative.
|
Modifier and Type | Method and Description |
---|---|
void |
addReceiver(AID r)
Adds a value to
:receiver slot. |
void |
addReplyTo(AID dest)
Adds a value to
:reply-to slot. |
void |
addUserDefinedParameter(String key,
String value)
Add a new user defined parameter to this ACLMessage.
|
void |
clearAllReceiver()
Removes all values from
:receiver
slot. |
void |
clearAllReplyTo()
Removes all values from
:reply_to
slot. |
Object |
clearUserDefinedParameter(String key)
Removes the key and its corresponding value from the list of user
defined parameters in this ACLMessage.
|
Object |
clone()
Clone an
ACLMessage object. |
ACLMessage |
createReply()
create a new ACLMessage that is a reply to this message.
|
Iterator |
getAllIntendedReceiver()
retrieve the whole list of intended receivers for this message.
|
static String[] |
getAllPerformativeNames()
Returns the list of the communicative acts as an array of
String . |
Iterator |
getAllReceiver()
Reads
:receiver slot. |
Iterator |
getAllReplyTo()
Reads
:reply_to slot. |
Properties |
getAllUserDefinedParameters()
Return all user defined parameters of this ACLMessage in form of a Properties object
|
byte[] |
getByteSequenceContent()
Reads
:content slot. |
String |
getContent()
Reads
:content slot. |
Serializable |
getContentObject()
This method returns the content of this ACLMessage when they have
been written via the method
setContentObject . |
String |
getConversationId()
Reads
:conversation-id slot. |
String |
getEncoding()
Reads
:encoding slot. |
Envelope |
getEnvelope()
Reads the envelope attached to this message, if any.
|
String |
getInReplyTo()
Reads
:reply-to slot. |
static int |
getInteger(String perf)
Returns the integer corresponding to the performative
|
String |
getLanguage()
Reads
:language slot. |
String |
getOntology()
Reads
:ontology slot. |
int |
getPerformative()
return the integer representing the performative of this object
|
static String |
getPerformative(int perf)
Returns the string corresponding to the integer for the performative
|
private Long |
getPersistentID() |
String |
getProtocol()
Reads
:protocol slot. |
private ArrayList |
getReceivers() |
String |
getReplyBy()
Deprecated.
Since the value of this slot is a Date by definition, then
the
getReplyByDate should be used that returns a Date |
Date |
getReplyByDate()
Reads
:reply-by slot. |
private ArrayList |
getReplyTo() |
String |
getReplyWith()
Reads
:reply-with slot. |
AID |
getSender()
Reads
:sender slot. |
String |
getUserDefinedParameter(String key)
Searches for the user defined parameter with the specified key.
|
private Serializable |
getUserDefinedProperties() |
boolean |
hasByteSequenceContent()
This method allows to check if the content of this ACLMessage
is a byteSequence or a String
|
boolean |
removeReceiver(AID r)
Removes a value from
:receiver
slot. |
boolean |
removeReplyTo(AID dest)
Removes a value from
:reply_to
slot. |
boolean |
removeUserDefinedParameter(String key)
Removes the key and its corresponding value from the list of user
defined parameters in this ACLMessage.
|
void |
reset()
Resets all the message slots.
|
void |
setAllUserDefinedParameters(Properties userDefProps)
Replace all user defined parameters of this ACLMessage with the specified Properties object.
|
void |
setByteSequenceContent(byte[] byteSequenceContent)
Writes the
:content slot. |
void |
setContent(String content)
Writes the
:content slot. |
void |
setContentObject(Serializable s)
This method sets the content of this ACLMessage to a Java object.
|
void |
setConversationId(String str)
Writes the
:conversation-id slot. |
void |
setDefaultEnvelope()
Writes the message envelope for this message, using the
:sender and :receiver message slots to
fill in the envelope. |
void |
setEncoding(String str)
Writes the
:encoding slot. |
void |
setEnvelope(Envelope e)
Attaches an envelope to this message.
|
void |
setInReplyTo(String reply)
Writes the
:in-reply-to slot. |
void |
setLanguage(String str)
Writes the
:language slot. |
void |
setOntology(String str)
Writes the
:ontology slot. |
void |
setPerformative(int perf)
set the performative of this ACL message object to the passed constant.
|
private void |
setPersistentID(Long l) |
void |
setProtocol(String str)
Writes the
:protocol slot. |
private void |
setReceivers(ArrayList al) |
void |
setReplyByDate(Date date)
Writes the
:reply-by slot. |
private void |
setReplyTo(ArrayList al) |
void |
setReplyWith(String reply)
Writes the
:reply-with slot. |
void |
setSender(AID s)
Writes the
:sender slot. |
private void |
setUserDefinedProperties(Serializable p) |
String |
toString()
Convert an ACL message to its string representation.
|
private static final long serialVersionUID
public static final int ACCEPT_PROPOSAL
public static final int AGREE
public static final int CANCEL
public static final int CFP
public static final int CONFIRM
public static final int DISCONFIRM
public static final int FAILURE
public static final int INFORM
public static final int INFORM_IF
public static final int INFORM_REF
public static final int NOT_UNDERSTOOD
public static final int PROPOSE
public static final int QUERY_IF
public static final int QUERY_REF
public static final int REFUSE
public static final int REJECT_PROPOSAL
public static final int REQUEST
public static final int REQUEST_WHEN
public static final int REQUEST_WHENEVER
public static final int SUBSCRIBE
public static final int PROXY
public static final int PROPAGATE
public static final int UNKNOWN
private int performative
private static final String[] performatives
public static final String IGNORE_FAILURE
public static final String POST_TIME_STAMP
public static final String TRACE
public static final String NO_CLONE
public static final String SYNCH_DELIVERY
public static final String AMS_FAILURE_AGENT_NOT_FOUND
public static final String AMS_FAILURE_AGENT_UNREACHABLE
public static final String AMS_FAILURE_SERVICE_ERROR
public static final String AMS_FAILURE_UNAUTHORIZED
public static final String AMS_FAILURE_FOREIGN_AGENT_UNREACHABLE
public static final String AMS_FAILURE_FOREIGN_AGENT_NO_ADDRESS
public static final String AMS_FAILURE_UNEXPECTED_ERROR
private AID source
private static final int RECEIVERS_EXPECTED_SIZE
private static final int REPLYTO_EXPECTED_SIZE
private ArrayList dests
private ArrayList reply_to
private StringBuffer content
private byte[] byteSequenceContent
private String reply_with
private String in_reply_to
private String encoding
private String language
private String ontology
private long reply_byInMillisec
private String protocol
private String conversation_id
private Properties userDefProps
private Envelope messageEnvelope
private Long persistentID
public ACLMessage()
not-understood
.ACLMessage(int)
public ACLMessage(int perf)
not-understood
.public static String[] getAllPerformativeNames()
String
.public void setSender(AID s)
:sender
slot. Warning: no
checks are made to validate the slot value.source
- The new value for the slot.getSender()
public void addReceiver(AID r)
:receiver
slot. Warning:
no checks are made to validate the slot value.r
- The value to add to the slot value set.public boolean removeReceiver(AID r)
:receiver
slot. Warning: no checks are made to validate the slot
value.r
- The value to remove from the slot value set.public void clearAllReceiver()
:receiver
slot. Warning: no checks are made to validate the slot
value.public void addReplyTo(AID dest)
:reply-to
slot. Warning:
no checks are made to validate the slot value.dest
- The value to add to the slot value set.public boolean removeReplyTo(AID dest)
:reply_to
slot. Warning: no checks are made to validate the slot
value.dest
- The value to remove from the slot value set.public void clearAllReplyTo()
:reply_to
slot. Warning: no checks are made to validate the slot
value.public void setPerformative(int perf)
INFORM, REQUEST, ...
)
defined in this classpublic void setContent(String content)
:content
slot. Warning: no
checks are made to validate the slot value.
Notice that, in general, setting a String content and getting
back a byte sequence content - or viceversa - does not return
the same value, i.e. the following relation does not hold
getByteSequenceContent(setByteSequenceContent(getContent().getBytes()))
is equal to getByteSequenceContent()
content
- The new value for the slot.getContent()
,
setByteSequenceContent(byte[])
,
setContentObject(Serializable s)
public void setByteSequenceContent(byte[] byteSequenceContent)
:content
slot. Warning: no
checks are made to validate the slot value.
Notice that, in general, setting a String content and getting
back a byte sequence content - or viceversa - does not return
the same value, i.e. the following relation does not hold
getByteSequenceContent(setByteSequenceContent(getContent().getBytes()))
is equal to getByteSequenceContent()
byteSequenceContent
- The new value for the slot.setContent(String s)
,
getByteSequenceContent()
,
setContentObject(Serializable s)
public void setContentObject(Serializable s) throws IOException
ACLMessage msg = new ACLMessage(ACLMessage.INFORM); Date d = new Date(); try{ msg.setContentObject(d); }catch(IOException e){}
s
- the object that will be used to set the content of the ACLMessage.IOException
- if an I/O error occurs.public Serializable getContentObject() throws UnreadableException
setContentObject
.
It is not FIPA compliant so its usage is not encouraged.
For example to read Java objects from the content
ACLMessage msg = blockingReceive(); try{ Date d = (Date)msg.getContentObject(); }catch(UnreadableException e){}
UnreadableException
- when an error occurs during the decoding.public void setReplyWith(String reply)
:reply-with
slot. Warning: no
checks are made to validate the slot value.reply
- The new value for the slot.getReplyWith()
public void setInReplyTo(String reply)
:in-reply-to
slot. Warning: no
checks are made to validate the slot value.reply
- The new value for the slot.getInReplyTo()
public void setEncoding(String str)
:encoding
slot. Warning: no
checks are made to validate the slot value.str
- The new value for the slot.getEncoding()
public void setLanguage(String str)
:language
slot. Warning: no
checks are made to validate the slot value.str
- The new value for the slot.getLanguage()
public void setOntology(String str)
:ontology
slot. Warning: no
checks are made to validate the slot value.str
- The new value for the slot.getOntology()
public void setReplyByDate(Date date)
:reply-by
slot. Warning: no
checks are made to validate the slot value.date
- The new value for the slot.getReplyByDate()
public void setProtocol(String str)
:protocol
slot. Warning: no
checks are made to validate the slot value.str
- The new value for the slot.getProtocol()
public void setConversationId(String str)
:conversation-id
slot. Warning: no
checks are made to validate the slot value.str
- The new value for the slot.getConversationId()
public Iterator getAllReceiver()
:receiver
slot.Iterator
containing the Agent IDs of the
receiver agents for this message.public Iterator getAllReplyTo()
:reply_to
slot.Iterator
containing the Agent IDs of the
reply_to agents for this message.public AID getSender()
:sender
slot.:sender
slot.setSender(AID).
public static String getPerformative(int perf)
public static int getInteger(String perf)
public int getPerformative()
public boolean hasByteSequenceContent()
public String getContent()
:content
slot.
Notice that, in general, setting a String content and getting
back a byte sequence content - or viceversa - does not return
the same value, i.e. the following relation does not hold
getByteSequenceContent(setByteSequenceContent(getContent().getBytes()))
is equal to getByteSequenceContent()
:content
slot.setContent(String)
,
getByteSequenceContent()
,
getContentObject()
public byte[] getByteSequenceContent()
:content
slot.
Notice that, in general, setting a String content and getting
back a byte sequence content - or viceversa - does not return
the same value, i.e. the following relation does not hold
getByteSequenceContent(setByteSequenceContent(getContent().getBytes()))
is equal to getByteSequenceContent()
:content
slot.getContent()
,
setByteSequenceContent(byte[])
,
getContentObject()
public String getReplyWith()
:reply-with
slot.:reply-with
slot.setReplyWith(String).
public String getInReplyTo()
:reply-to
slot.:reply-to
slot.setInReplyTo(String).
public String getEncoding()
:encoding
slot.:encoding
slot.setEncoding(String).
public String getLanguage()
:language
slot.:language
slot.setLanguage(String).
public String getOntology()
:ontology
slot.:ontology
slot.setOntology(String).
public String getReplyBy()
getReplyByDate
should be used that returns a Date:reply-by
slot.:reply-by
slot, as a string.getReplyByDate().
public Date getReplyByDate()
:reply-by
slot.:reply-by
slot, as a
Date
object.setReplyByDate(Date).
public String getProtocol()
:protocol
slot.:protocol
slot.setProtocol(String).
public String getConversationId()
:conversation-id
slot.:conversation-id
slot.setConversationId(String).
public void addUserDefinedParameter(String key, String value)
key
- the property key.value
- the property valuepublic String getUserDefinedParameter(String key)
null
if the parameter is not found.key
- the parameter key.public Properties getAllUserDefinedParameters()
public void setAllUserDefinedParameters(Properties userDefProps)
public boolean removeUserDefinedParameter(String key)
key
- the key that needs to be removedpublic Object clearUserDefinedParameter(String key)
key
- the key that needs to be removedpublic void setEnvelope(Envelope e)
e
- The Envelope
object to attach to this
message.jade.lang.acl
,
jade.lang.acl
public void setDefaultEnvelope()
:sender
and :receiver
message slots to
fill in the envelope.jade.lang.acl
,
jade.lang.acl
public Envelope getEnvelope()
jade.lang.acl
,
jade.lang.acl
public String toString()
ACLMessage
into a
character string.
If the content is a bytesequence, then it is automatically converted
into Base64 encoding.public Object clone()
ACLMessage
object.public void reset()
public ACLMessage createReply()
public Iterator getAllIntendedReceiver()
private Long getPersistentID()
private void setPersistentID(Long l)
private void setReceivers(ArrayList al)
private ArrayList getReceivers()
private void setReplyTo(ArrayList al)
private ArrayList getReplyTo()
private void setUserDefinedProperties(Serializable p)
private Serializable getUserDefinedProperties()