Class AttributeMessage

    • Field Detail

      • attributes

        protected final java.util.Map<java.lang.String,​java.lang.String> attributes
        The key,value attribute pairs.
      • mergeable

        private boolean mergeable
        Whether this message is trivially mergeable.
    • Constructor Detail

      • AttributeMessage

        public AttributeMessage​(java.lang.String type)
        Create a new AttributeMessage of a given type.
        Parameters:
        type - The message type.
      • AttributeMessage

        public AttributeMessage​(java.lang.String type,
                                java.lang.String... attributes)
        Create a new AttributeMessage of a given type and attributes.
        Parameters:
        type - The message type.
        attributes - The key,value pairs.
      • AttributeMessage

        protected AttributeMessage​(java.lang.String type,
                                   java.util.Map<java.lang.String,​java.lang.String> attributeMap)
        Create a new AttributeMessage of a given type and attributes.
        Parameters:
        type - The message type.
        attributeMap - A map of key,value pairs.
      • AttributeMessage

        protected AttributeMessage​(java.lang.String type,
                                   FreeColXMLReader xr,
                                   java.lang.String... attributes)
                            throws javax.xml.stream.XMLStreamException
        Create a new AttributeMessage from a stream. Should only be called by direct subclasses of AttributeMessage as the entire message is consumed.
        Parameters:
        type - The message type.
        xr - The FreeColXMLReader to read from.
        attributes - The attributes to read.
        Throws:
        javax.xml.stream.XMLStreamException - if the stream is corrupt.
    • Method Detail

      • hasAttribute

        protected boolean hasAttribute​(java.lang.String key)
        Checks if an attribute is present in this message.
        Overrides:
        hasAttribute in class TrivialMessage
        Parameters:
        key - The attribute to look for.
        Returns:
        True if the attribute is present.
      • getStringAttribute

        protected java.lang.String getStringAttribute​(java.lang.String key)
        Get a string attribute value.
        Overrides:
        getStringAttribute in class TrivialMessage
        Parameters:
        key - The attribute to look for.
        Returns:
        The string value found, or null if the attribute was absent.
      • setStringAttribute

        protected void setStringAttribute​(java.lang.String key,
                                          java.lang.String value)
        Sets an attribute in this message.
        Overrides:
        setStringAttribute in class TrivialMessage
        Parameters:
        key - The attribute to set.
        value - The new value of the attribute.
      • getStringAttributeMap

        protected java.util.Map<java.lang.String,​java.lang.String> getStringAttributeMap()
        Get a map of all the attributes in this message.
        Overrides:
        getStringAttributeMap in class TrivialMessage
        Returns:
        A Map of the attributes.
      • canMerge

        public boolean canMerge()
        Does this message consist only of mergeable attributes?
        Overrides:
        canMerge in class Message
        Returns:
        True if this message is trivially mergeable.
      • setMergeable

        public AttributeMessage setMergeable​(boolean mergeable)
        Set the mergeable state of this message.
        Parameters:
        mergeable - The new mergeable state.
        Returns:
        This message.