Public Member Functions | |
TagValTextParser (ByteBuffer buffer) throws IOException | |
String | getValue (String keyMsgType) throws TcProtocolException |
String | getValueWithDefault (String keyMsgType, String defaultVal) |
int | getValueAsInt (String keyIdField) throws TcProtocolException |
int | getValueAsIntWithDefault (String keyIdField, int defaultVal) throws TcProtocolException |
String | toString () |
Static Public Attributes | |
static final char | FIELD_TERMINATOR = '|' |
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.
com.thecoderscorner.menu.remote.protocol.TagValTextParser.TagValTextParser | ( | ByteBuffer | buffer | ) | throws IOException |
Creates an instance that contains all the tags and values in a map, that can then be used to extract the message.
buffer | a buffer containing a message. |
IOException | if the buffer is invalid |
String com.thecoderscorner.menu.remote.protocol.TagValTextParser.getValue | ( | String | keyMsgType | ) | throws TcProtocolException |
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
keyMsgType | the key to obtain |
int com.thecoderscorner.menu.remote.protocol.TagValTextParser.getValueAsInt | ( | String | keyIdField | ) | throws TcProtocolException |
Calls the getValue method first and the converts to an integer.
keyIdField | the key to obtain |
int com.thecoderscorner.menu.remote.protocol.TagValTextParser.getValueAsIntWithDefault | ( | String | keyIdField, |
int | defaultVal | ||
) | throws TcProtocolException |
Calls the getValue method first and the converts to an integer.
keyIdField | the key to obtain |
String com.thecoderscorner.menu.remote.protocol.TagValTextParser.getValueWithDefault | ( | String | keyMsgType, |
String | defaultVal | ||
) |
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.
keyMsgType | the key to obtain |