jadex.base.service.message.transport.MessageEnvelope Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-platform-base Show documentation
Show all versions of jadex-platform-base Show documentation
The Jadex platform base package contains
functionality useful for constructing platforms.
The newest version!
package jadex.base.service.message.transport;
import jadex.bridge.IComponentIdentifier;
import jadex.commons.SReflect;
import jadex.commons.SUtil;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
/**
* The message envelope holding the native message,
* the receivers and the message type.
*/
public class MessageEnvelope
{
//-------- attributes --------
/** The message. */
protected Map message;
/** The receivers. */
protected Collection receivers;
/** The message type. */
protected String message_type;
//-------- constructors --------
/**
* Create a new message envelope.
* (bean constructor)
*/
public MessageEnvelope()
{
}
/**
* Create a new message envelope.
*/
public MessageEnvelope(Map message, Collection receivers, String message_type)
{
this.message = message;
this.receivers = receivers;
this.message_type = message_type;
}
//-------- methods --------
/**
* Get native message.
* @return The native message.
*/
public Map getMessage()
{
return message;
}
/**
* Set native message.
* @param message The native message.
*/
public void setMessage(Map message)
{
this.message = message;
}
/**
* Get the receivers.
*/
public IComponentIdentifier[] getReceivers()
{
return receivers==null? new IComponentIdentifier[0]: receivers.toArray(new IComponentIdentifier[receivers.size()]);
}
/**
* Get the receivers.
*/
public void setReceivers(IComponentIdentifier[] receivers)
{
this.receivers = new ArrayList();
if(receivers!=null)
{
for(int i=0; i();
receivers.add(receiver);
}
/**
* Set the type (e.g. "fipa").
* @param messagetypename
*/
public void setTypeName(String messagetypename)
{
message_type = messagetypename;
}
/**
* Get the type (e.g. "fipa").
*/
public String getTypeName()
{
return message_type;
}
/**
* Get the string representation.
* @return The string representation.
*/
public String toString()
{
StringBuffer sb = new StringBuffer();
sb.append(SReflect.getInnerClassName(this.getClass())+"(");
//sb.append("sender: "+getSender()+", ");
sb.append("receivers: "+SUtil.arrayToString(getReceivers())+", ");
sb.append("message type: "+message_type);
sb.append("raw values: "+message);
// sb.append(super.toString());
sb.append(")");
return sb.toString();
}
}