com.ls.lars.communication
Class SingleMessage

java.lang.Object
  |
  +--com.ls.lars.communication.Message
        |
        +--com.ls.lars.communication.SingleMessage
All Implemented Interfaces:
Cloneable, Comparable, Serializable

public class SingleMessage
extends Message

Message object for the communication between the agents.

Note, that the Message object is not synchronized!

Standard for naming message services:

This standard is needed for automatic registration of "interpret"-methods in agents.

Version:
$Revision: 1.6 $
Author:
Last modified by $Author: ODrugan $
See Also:
Serialized Form

Field Summary
static String TAG_RECEIVER
          string that represent the "receiver"
 
Fields inherited from class com.ls.lars.communication.Message
ADDRESS_CONFIG, ADDRESS_LARS_INTERNAL, EXPIRE_HOPS_DEFAULT, MESSAGE_TYPE_GROUP, MESSAGE_TYPE_MULTICAST, MESSAGE_TYPE_SERVICE_BROADCAST, MESSAGE_TYPE_SERVICE_SINGLE, MESSAGE_TYPE_SINGLE, PRIORITY_HIGH, PRIORITY_LOW, PRIORITY_NORMAL, PRIORITY_SYSTEM, PRIORITY_TEXT_HIGH, PRIORITY_TEXT_LOW, PRIORITY_TEXT_NORMAL, SERVICE_UNKNOWN, TAG_CONTENT, TAG_CURRENT_HOPS, TAG_EXPIRE_HOPS, TAG_FORWARDED_BY, TAG_IN_REPLY_TO, TAG_MESSAGE, TAG_PRIORITY, TAG_QUALITY_OF_SERVICE, TAG_REPLY_COUNTER, TAG_REPLY_WITH, TAG_SENDER, TAG_SENT_TIME, TAG_SERVICE, TAG_TYPE
 
Constructor Summary
SingleMessage(String service, String receiver, Object content)
          sets all fields of a message including the content object
 
Method Summary
 String getReceiver()
          returns the name of the receiver agent
 boolean hasInvalidReceiver()
          calls SingleMessage.hasInvalidReceiver(this.receiver)
static boolean hasInvalidReceiver(String receiver)
          Rudimentary checks this message, if it contains an invalid receiver address.
protected  Map inheritorToMap()
          returns a map containing the SingleMessage specific fields (type and receiver)
protected  String inheritorToString()
          returns a well formatted string containing the SingleMessage specific fields (type and receiver)
 
Methods inherited from class com.ls.lars.communication.Message
clone, compareTo, createMessage, createReply, getContent, getCurrentHops, getExpireHops, getForwardedBy, getInReplyTo, getPriority, getQualityOfService, getReplyWith, getSender, getSentTime, getService, hasInvalidSender, hop, increasePriority, isExpired, isSent, setExpireHops, setInReplyTo, setPriority, setPriority, setQualityOfService, setQualityOfService, setReplyWith, setSystemPriority, toMap, toString, toStringWithContent
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TAG_RECEIVER

public static final String TAG_RECEIVER
string that represent the "receiver"
Constructor Detail

SingleMessage

public SingleMessage(String service,
                     String receiver,
                     Object content)
              throws InvalidArgumentException
sets all fields of a message including the content object
Parameters:
service - service of the message
receiver - name of the receiver agent
content - content of the message as a hash
Throws:
InvalidArgumentException - If given service or receiver is null or empty or contains only whitespace characters or if given content is null
Method Detail

getReceiver

public final String getReceiver()
returns the name of the receiver agent
Returns:
name of this receiver agent

hasInvalidReceiver

public final boolean hasInvalidReceiver()
calls SingleMessage.hasInvalidReceiver(this.receiver)
Returns:
hasInvalidReceiver(this.receiver)

hasInvalidReceiver

public static boolean hasInvalidReceiver(String receiver)
Rudimentary checks this message, if it contains an invalid receiver address. A receiver address is assumed to be invalid, if any of the following cases is true: receiver ...
Parameters:
receiver - the name of the receiver to be veryfied
Returns:
true, if one of the cases above evaluates to true; false else

inheritorToMap

protected Map inheritorToMap()
returns a map containing the SingleMessage specific fields (type and receiver)
Overrides:
inheritorToMap in class Message
Returns:
SingleMessage specific fields as a Map

inheritorToString

protected String inheritorToString()
returns a well formatted string containing the SingleMessage specific fields (type and receiver)
Overrides:
inheritorToString in class Message
Returns:
SingleMessage specific fields as a well-formatted string