Interface Message

  • All Superinterfaces:
    java.lang.Cloneable, java.lang.Comparable<java.lang.Object>, Identifiable, Unique
    All Known Implementing Classes:
    MagellanMessageImpl

    public interface Message
    extends Identifiable
    A class for representing a message.

    The new format of messages in Eressea CR versions >= 41 made it necessary to reconsider this class. Mainly, messages can now have an id and attributes.

    Two special attributes are available directly via the corresping get/set methods.

    First, this is the type attribte (tag ;type in the cr) denoting the type of the message. It is transformed into a MessageType object.

    Second, there is the text attribute (tag ;rendered in the cr). By design this attribute should actually be created by rendering the message according to the message type's pattern and the other attributes. This class does contain a render() method, still, it is too primitive to yield acceptable results, so it is preferrable to take the rendered message text directly from the cr.

    Note, that for historic reasons, a Message object might have no type or attributes and an invalid id of -1.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static IntegerID ambiguousID
      An placeholder ID for messages without valid ID.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)
      Indicates whether this Message object is equal to another object.
      java.util.Map<java.lang.String,​java.lang.String> getAttributes()
      The attributes of this message.
      IntegerID getID()
      Returns an ID for this message.
      MessageType getMessageType()
      Returns the MessageType of this message.
      java.lang.String getText()
      Gets the rendered message text.
      int hashCode()
      As we want to use the hashCode/equals contract we need to force the implementation of hashCode.
      boolean isAcknowledged()  
      void render​(GameData data)
      Renders the message and updates the message text.
      void setAcknowledged​(boolean ack)
      Sets the new acknowledged status.
      void setAttributes​(java.util.Map<java.lang.String,​java.lang.String> attributes)
      The attributes of this message.
      void setText​(java.lang.String text)
      Sets the text of this message to text.
      void setType​(MessageType type)
      Sets the MessageType of this message.
      java.lang.String toString()
      DOCUMENT-ME
    • Field Detail

      • ambiguousID

        static final IntegerID ambiguousID
        An placeholder ID for messages without valid ID.
    • Method Detail

      • getAttributes

        java.util.Map<java.lang.String,​java.lang.String> getAttributes()
        The attributes of this message. The keys are the keys of the attribute, the values object pairs of the attributes' keys and values.
      • setAttributes

        void setAttributes​(java.util.Map<java.lang.String,​java.lang.String> attributes)
        The attributes of this message. The keys are the keys of the attribute, the values object pairs of the attributes' keys and values.
      • getText

        java.lang.String getText()
        Gets the rendered message text.
        Returns:
        The message text
      • setText

        void setText​(java.lang.String text)
        Sets the text of this message to text.
        Parameters:
        text - The new text
      • getMessageType

        MessageType getMessageType()
        Returns the MessageType of this message.
        Returns:
        The message type
      • setType

        void setType​(MessageType type)
        Sets the MessageType of this message.
        Parameters:
        type - The new message type
      • render

        void render​(GameData data)
        Renders the message and updates the message text.
        Parameters:
        data - The GameData for replacing unit IDs and region coordinates
      • hashCode

        int hashCode()
        Description copied from interface: Identifiable
        As we want to use the hashCode/equals contract we need to force the implementation of hashCode.
        Specified by:
        hashCode in interface Identifiable
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        A hash code for this message
      • equals

        boolean equals​(java.lang.Object o)
        Indicates whether this Message object is equal to another object. Returns true only if o is not null and an instance of class Message and o's id is equal to the id of this Message object. 2002.02.21 pavkovic: Also the message text has to be the same for Messages with ambiguous IntegerID(-1)
        Specified by:
        equals in interface Identifiable
        Overrides:
        equals in class java.lang.Object
      • toString

        java.lang.String toString()
        DOCUMENT-ME
        Overrides:
        toString in class java.lang.Object
      • isAcknowledged

        boolean isAcknowledged()
        Returns:
        true if the message has been acknowledged (by the user)
      • setAcknowledged

        void setAcknowledged​(boolean ack)
        Sets the new acknowledged status.