Class Message

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable

    public class Message
    extends ParameterElement
    The message object.
    See Also:
    Serialized Form
    • Constructor Detail

      • Message

        public Message()
        For loading from file. Create a message with given parameters and sequence number.
        Parameters:
        arguments - The parameters of the message.
        sequence - The sequence number of the message.
      • Message

        public Message​(java.lang.Object event,
                       int sequence,
                       java.lang.String xid,
                       IComponentIdentifier sender,
                       IComponentIdentifier receiver,
                       java.lang.Object body)
        Create a message with given parameters and sequence number.
        Parameters:
        arguments - The parameters of the message.
        sequence - The sequence number of the message.
    • Method Detail

      • getDeclaredParameters

        public static final java.lang.String[] getDeclaredParameters()
        Get the user defined parameters. Does not return parameters for internal use.
        Returns:
        All defined parameters.
      • getSender

        public Component getSender()
        Returns:
        The sender.
      • getReceiver

        public Component getReceiver()
        Returns:
        The receiver.
      • getUniqueId

        public int getUniqueId()
        Returns:
        The unique id
      • setUniqueId

        public void setUniqueId​(int uniqueId)
        Set the unique id.
        Parameters:
        uniqueid - The unique id.
      • isMulticast

        public boolean isMulticast()
        Returns:
        True if the message is part of a multicast.
      • getEndpoints

        public edu.uci.ics.jung.graph.util.Pair getEndpoints()
        Helper method for checking the visibility of the message including the state of sender , receiver and dummy agent Returns a pair of Agents if the message should be displayed or null if not.
        Returns:
        The pair of Agents (either redirected or not) or null if the message shouldnt be displayed
      • applyFilter

        protected boolean applyFilter​(MessageFilter[] filter)
        Applies a filter on the message and returns if the visibility has changed.
        Parameters:
        filter - The filter to be applied on the message.
        Returns:
        True if the visibility has changed
      • setSender

        public void setSender​(Component agent)
        Parameters:
        agent - The sender to set.
      • setReceiver

        public void setReceiver​(Component agent)
        Parameters:
        agent - The receiver to set.
      • setDuration

        public void setDuration​(long duration)
        Parameters:
        duration - The duration to set.
      • getId

        public java.lang.String getId()
        Specified by:
        getId in class ParameterElement
        Returns:
        The id of the element.
      • getParameter

        public java.lang.Object getParameter​(java.lang.String name)
        Returns a parameter value.
        Overrides:
        getParameter in class ParameterElement
        Parameters:
        name - The name of the parameter.
        Returns:
        The value.
      • getParameters

        public java.util.Map getParameters()
        Returns the parameter map.
        Overrides:
        getParameters in class ParameterElement
        Returns:
        The parameter map.
      • hasParameter

        public boolean hasParameter​(java.lang.String name)
        Checks if a given parameter is contained by the parameter map.
        Overrides:
        hasParameter in class ParameterElement
        Parameters:
        name - The name of the parameter.
        Returns:
        true if the parameter is contained.
      • compareTo

        public int compareTo​(java.lang.Object o)
        Messages are compared by their unique_id. That implies that messsages are sorted by their sequence number.
        Specified by:
        compareTo in interface java.lang.Comparable
        Overrides:
        compareTo in class ParameterElement
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        The hashcode.
      • equals

        public boolean equals​(java.lang.Object obj)
        Only messages with the same unique id are equal.
        Overrides:
        equals in class ParameterElement
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class ParameterElement
        Returns:
        The string representation for the message.