Class TagValMenuCommandProtocol

  • All Implemented Interfaces:
    MenuCommandProtocol

    public class TagValMenuCommandProtocol
    extends java.lang.Object
    implements MenuCommandProtocol
    A protocol implementation that uses tag value pair notation with a few special text items in order to create messages that can be transmitted. It is currently the default protocol. Example of this format: "0=123|1=234~" where key 0 is 123 and key 1 is 234, tilde indicates the end of the message.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      MenuCommand fromChannel​(java.nio.ByteBuffer buffer)
      Retrieves a message from the channel, or throws an exception if the message is not fully formed.
      byte getKeyIdentifier()
      returns the identifier for this protocol, when used in messages
      void toChannel​(java.nio.ByteBuffer buffer, MenuCommand cmd)
      Puts the command specified into the byte buffer, it is assumed that the callee will flip the channel once complete.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TagValMenuCommandProtocol

        public TagValMenuCommandProtocol()
    • Method Detail

      • fromChannel

        public MenuCommand fromChannel​(java.nio.ByteBuffer buffer)
                                throws java.io.IOException
        Description copied from interface: MenuCommandProtocol
        Retrieves a message from the channel, or throws an exception if the message is not fully formed. It is assumed that the buffer has been suitably flipped ready for reading
        Specified by:
        fromChannel in interface MenuCommandProtocol
        Throws:
        java.io.IOException
      • toChannel

        public void toChannel​(java.nio.ByteBuffer buffer,
                              MenuCommand cmd)
        Description copied from interface: MenuCommandProtocol
        Puts the command specified into the byte buffer, it is assumed that the callee will flip the channel once complete.
        Specified by:
        toChannel in interface MenuCommandProtocol
        Parameters:
        buffer - to write the data to
        cmd - the command to write
      • getKeyIdentifier

        public byte getKeyIdentifier()
        Description copied from interface: MenuCommandProtocol
        returns the identifier for this protocol, when used in messages
        Specified by:
        getKeyIdentifier in interface MenuCommandProtocol
        Returns:
        the ID for this protocol