Class TagValTextParser
- java.lang.Object
-
- com.thecoderscorner.menu.remote.protocol.TagValTextParser
-
public class TagValTextParser extends java.lang.ObjectThis is the parser implementation that understands tag value format and can convert the tags back into a series of tags and values suitable for the protocol to decode messages.
-
-
Constructor Summary
Constructors Constructor Description TagValTextParser(java.nio.ByteBuffer buffer)Creates an instance that contains all the tags and values in a map, that can then be used to extract the message.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetValue(java.lang.String keyMsgType)Gets the value associated with the key from the message.intgetValueAsInt(java.lang.String keyIdField)Calls the getValue method first and the converts to an integer.java.lang.StringtoString()
-
-
-
Constructor Detail
-
TagValTextParser
public TagValTextParser(java.nio.ByteBuffer buffer) throws java.io.IOExceptionCreates an instance that contains all the tags and values in a map, that can then be used to extract the message.- Parameters:
buffer- a buffer containing a message.- Throws:
java.io.IOException- if the buffer is invalid
-
-
Method Detail
-
getValue
public java.lang.String getValue(java.lang.String keyMsgType) throws java.io.IOExceptionGets the value associated with the key from the message. This version throws an exception if the key is not available and should be used for mandatory fields- Parameters:
keyMsgType- the key to obtain- Returns:
- the associated value
- Throws:
java.io.IOException
-
getValueAsInt
public int getValueAsInt(java.lang.String keyIdField) throws java.io.IOExceptionCalls the getValue method first and the converts to an integer.- Parameters:
keyIdField- the key to obtain- Returns:
- the integer value associated
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-