Class WrapperMessage

  • Direct Known Subclasses:
    QuestionMessage, ReplyMessage

    public abstract class WrapperMessage
    extends AttributeMessage
    A wrapper message. That is a message with just a reply identifier attribute to be matched, and the underlying real message.
    • Field Detail

      • message

        private Message message
        The encapsulated message.
    • Constructor Detail

      • WrapperMessage

        protected WrapperMessage​(java.lang.String tag,
                                 int replyId,
                                 Message message)
        Create a new WrapperMessage of a given type.
        Parameters:
        tag - The actual message tag.
        replyId - The reply id.
        message - The Message to encapsulate.
      • WrapperMessage

        protected WrapperMessage​(java.lang.String tag,
                                 Game game,
                                 FreeColXMLReader xr)
                          throws javax.xml.stream.XMLStreamException,
                                 FreeColException
        Create a new WrapperMessage from a stream.
        Parameters:
        tag - The actual message tag.
        game - The Game to read within.
        xr - The FreeColXMLReader to read from.
        Throws:
        javax.xml.stream.XMLStreamException - if the stream is corrupt.
        FreeColException - if the internal message can not be read.
    • Method Detail

      • isEmpty

        public boolean isEmpty()
        Is this message vacuous?
        Overrides:
        isEmpty in class Message
        Returns:
        True if there are no attributes or children present.
      • clientHandler

        public void clientHandler​(FreeColClient freeColClient)
                           throws FreeColException
        Client-side handler for this message. Client handlers always return null.
        Overrides:
        clientHandler in class TrivialMessage
        Parameters:
        freeColClient - The FreeColClient to handle this message.
        Throws:
        FreeColException - if there is a problem building the message.
      • serverHandler

        public ChangeSet serverHandler​(FreeColServer freeColServer,
                                       ServerPlayer serverPlayer)
        Server-side handler for this message.
        Overrides:
        serverHandler in class TrivialMessage
        Parameters:
        freeColServer - The FreeColServer handling the request.
        serverPlayer - The ServerPlayer that sent the request.
        Returns:
        A ChangeSet defining the response.
      • writeChildren

        public void writeChildren​(FreeColXMLWriter xw)
                           throws javax.xml.stream.XMLStreamException
        Write any children of this message.
        Overrides:
        writeChildren in class Message
        Parameters:
        xw - The FreeColXMLWriter to write to.
        Throws:
        javax.xml.stream.XMLStreamException - if there is a problem writing the stream.
      • getMessage

        public Message getMessage()
        Get the wrapped message.
        Returns:
        The Message.
      • getSubType

        public java.lang.String getSubType()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class Message