Class TagValTextParser
java.lang.Object
com.thecoderscorner.menu.remote.protocol.TagValTextParser
This 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
ConstructorsConstructorDescriptionTagValTextParser(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
Modifier and TypeMethodDescriptionGets the value associated with the key from the message.intgetValueAsInt(String keyIdField)Calls the getValue method first and the converts to an integer.intgetValueAsIntWithDefault(String keyIdField, int defaultVal)Calls the getValue method first and the converts to an integer.getValueWithDefault(String keyMsgType, String defaultVal)Gets the value associated with the key from the message if it exists in the underlying map.toString()
-
Constructor Details
-
TagValTextParser
Creates 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:
IOException- if the buffer is invalid
-
-
Method Details
-
getValue
Gets 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:
IOException
-
getValueWithDefault
Gets the value associated with the key from the message if it exists in the underlying map. This version returns the default value if it does not exist.- Parameters:
keyMsgType- the key to obtain- Returns:
- the associated value or the default
-
getValueAsInt
Calls the getValue method first and the converts to an integer.- Parameters:
keyIdField- the key to obtain- Returns:
- the integer value associated
- Throws:
IOException
-
getValueAsIntWithDefault
Calls the getValue method first and the converts to an integer.- Parameters:
keyIdField- the key to obtain- Returns:
- the integer value associated
- Throws:
IOException
-
toString
-