Exemplo n.º 1
0
 /**
  * create a new ACLMessage that is a reply to this message. In particular, it sets the following
  * parameters of the new message: receiver, language, ontology, protocol, conversation-id,
  * in-reply-to, reply-with. The programmer needs to set the communicative-act and the content. Of
  * course, if he wishes to do that, he can reset any of the fields.
  *
  * @return the ACLMessage to send as a reply
  */
 public ACLMessage createReply() {
   ACLMessage m = new ACLMessage(getPerformative());
   Iterator it = getAllReplyTo();
   while (it.hasNext()) m.addReceiver((AID) it.next());
   if ((reply_to == null) || reply_to.isEmpty()) m.addReceiver(getSender());
   m.setLanguage(getLanguage());
   m.setOntology(getOntology());
   m.setProtocol(getProtocol());
   m.setInReplyTo(getReplyWith());
   if (source != null) m.setReplyWith(source.getName() + java.lang.System.currentTimeMillis());
   else m.setReplyWith("X" + java.lang.System.currentTimeMillis());
   m.setConversationId(getConversationId());
   // Copy only well defined user-def-params
   String trace = getUserDefinedParameter(TRACE);
   if (trace != null) {
     m.addUserDefinedParameter(TRACE, trace);
   }
   // #CUSTOM_EXCLUDE_BEGIN
   // Set the Aclrepresentation of the reply message to the aclrepresentation of the sent message
   if (messageEnvelope != null) {
     m.setDefaultEnvelope();
     String aclCodec = messageEnvelope.getAclRepresentation();
     if (aclCodec != null) m.getEnvelope().setAclRepresentation(aclCodec);
   } else m.setEnvelope(null);
   // #CUSTOM_EXCLUDE_END
   return m;
 }