server.framework.network.parser
Class StringParser

java.lang.Object
  extended by server.framework.network.parser.StringParser
All Implemented Interfaces:
MessageParser<java.lang.String>

public class StringParser
extends java.lang.Object
implements MessageParser<java.lang.String>

An implementation of the MessageParser interface, that creates and parses String messages. The format of these messages is ":"["@"][{","}{";"{","}}]"|" (in EBNF-notation).

Author:
Eivind Sorteberg, Martin Jarrett

Field Summary
static int MAXIMUM_MESSAGE_SIZE
           
 
Constructor Summary
StringParser()
           
 
Method Summary
 java.lang.String createMessage(Action action, java.lang.Object[][] values, AbstractPlayer sender)
          Creates a string message in the specified format from the given action identifier and values.
 ActionPair parseMessage(java.lang.String message)
          Parses a given string message into an ActionPair wrapper.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAXIMUM_MESSAGE_SIZE

public static final int MAXIMUM_MESSAGE_SIZE
See Also:
Constant Field Values
Constructor Detail

StringParser

public StringParser()
Method Detail

createMessage

public java.lang.String createMessage(Action action,
                                      java.lang.Object[][] values,
                                      AbstractPlayer sender)
Creates a string message in the specified format from the given action identifier and values.

Specified by:
createMessage in interface MessageParser<java.lang.String>
Parameters:
action - The action identifier.
values - An array containing the message's values.
sender - The sender of the action message.
Returns:
A string message to send to the server.

parseMessage

public ActionPair parseMessage(java.lang.String message)
Parses a given string message into an ActionPair wrapper.

Specified by:
parseMessage in interface MessageParser<java.lang.String>
Parameters:
message - The string message to parse.
Returns:
An ActionTriplet containing the message's contents.