Class TagValMenuCommandProtocol
- java.lang.Object
-
- com.thecoderscorner.menu.remote.protocol.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.
-
-
Field Summary
Fields Modifier and Type Field Description static byteEND_OF_MSGstatic byteFIELD_TERMINATORstatic bytePROTOCOL_TAG_VALstatic byteSTART_OF_MSG
-
Constructor Summary
Constructors Constructor Description TagValMenuCommandProtocol()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MenuCommandfromChannel(java.nio.ByteBuffer buffer)Retrieves a message from the channel, or throws an exception if the message is not fully formed.bytegetKeyIdentifier()returns the identifier for this protocol, when used in messagesvoidtoChannel(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.
-
-
-
Field Detail
-
PROTOCOL_TAG_VAL
public static final byte PROTOCOL_TAG_VAL
- See Also:
- Constant Field Values
-
START_OF_MSG
public static final byte START_OF_MSG
- See Also:
- Constant Field Values
-
END_OF_MSG
public static final byte END_OF_MSG
- See Also:
- Constant Field Values
-
FIELD_TERMINATOR
public static final byte FIELD_TERMINATOR
- See Also:
- Constant Field Values
-
-
Method Detail
-
fromChannel
public MenuCommand fromChannel(java.nio.ByteBuffer buffer) throws java.io.IOException
Description copied from interface:MenuCommandProtocolRetrieves 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:
fromChannelin interfaceMenuCommandProtocol- Throws:
java.io.IOException
-
toChannel
public void toChannel(java.nio.ByteBuffer buffer, MenuCommand cmd)Description copied from interface:MenuCommandProtocolPuts the command specified into the byte buffer, it is assumed that the callee will flip the channel once complete.- Specified by:
toChannelin interfaceMenuCommandProtocol- Parameters:
buffer- to write the data tocmd- the command to write
-
getKeyIdentifier
public byte getKeyIdentifier()
Description copied from interface:MenuCommandProtocolreturns the identifier for this protocol, when used in messages- Specified by:
getKeyIdentifierin interfaceMenuCommandProtocol- Returns:
- the ID for this protocol
-
-