server.framework.network.parser
Interface MessageParser<T>

All Known Implementing Classes:
StringParser

public interface MessageParser<T>

An interface that is used to parse messages of different formats into ActionPair 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
 T createMessage(Action action, java.lang.Object[][] values, AbstractPlayer sender)
          Creates a message in the specified format from an Action identifier, an array of values, and a sender.
 ActionPair parseMessage(T message)
          Takes a message in the specified format as input parameter, and creates an ActionPair object based on the contents of the message.
 

Method Detail

parseMessage

ActionPair parseMessage(T message)
Takes a message in the specified format as input parameter, and creates an ActionPair object based on the contents of the message.

Parameters:
message - The message to parse.
Returns:
An ActionPair object wrapping the message's contents.

createMessage

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

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