client.framework.network.parser
Interface MessageParser

All Known Implementing Classes:
StringParser

public interface MessageParser

An interface that is used to parse messages of different formats into ActionTriplet objects, and vice versa. The format of the messages should be well defined before this interface is implemented, to simplify the process of implementing the methods.

Author:
Eivind Sorteberg, Martin Jarrett

Method Summary
 java.lang.Object createMessage(Action action, java.lang.Object[][] values)
          Creates a message in the specified format from an Action identifier and an array of values.
 ActionTriplet parseMessage(java.lang.Object message)
          Takes a message in the specified format as input parameter, and creates an ActionTriplet object based on the contents of the message.
 

Method Detail

parseMessage

ActionTriplet parseMessage(java.lang.Object message)
                           throws java.io.IOException
Takes a message in the specified format as input parameter, and creates an ActionTriplet object based on the contents of the message. If the format of the message is not as expected, an IOException should be thrown.

Parameters:
message - The message to parse.
Returns:
An ActionTriplet object wrapping the message's contents.
Throws:
java.io.IOException - If the provided message is not in the expected format, or of the correct type.

createMessage

java.lang.Object createMessage(Action action,
                               java.lang.Object[][] values)
Creates a message in the specified format from an Action identifier and an array of values.

Parameters:
action - The action identifier of the message.
values - The values to contain in the message.
Returns:
A message following the specified format.