client.framework.network.parser
Class StringParser
java.lang.Object
client.framework.network.parser.StringParser
- All Implemented Interfaces:
- MessageParser
public class StringParser
- extends java.lang.Object
- implements MessageParser
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
Method Summary |
java.lang.Object |
createMessage(Action action,
java.lang.Object[][] values)
Creates a string message in the specified format
from the given action identifier and values. |
ActionTriplet |
parseMessage(java.lang.Object message)
Parses a given string message into an ActionTriplet
wrapper. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
StringParser
public StringParser()
parseMessage
public ActionTriplet parseMessage(java.lang.Object message)
throws java.io.IOException
- Parses a given string message into an
ActionTriplet
wrapper. If the message is not a String
object, an
IOException
is thrown.
- Specified by:
parseMessage
in interface MessageParser
- Parameters:
message
- The string message to parse.
- Returns:
- An
ActionTriplet
containing the message's contents.
- Throws:
java.io.IOException
- If the given message is not a String
instance.
createMessage
public java.lang.Object createMessage(Action action,
java.lang.Object[][] values)
- Creates a string message in the specified format
from the given action identifier and values. The
string message is wrapped as an
Object
to meet the interface's specification.
- Specified by:
createMessage
in interface MessageParser
- Parameters:
action
- The action identifier.values
- An array containing the message's values.
- Returns:
- A string message to send to the server.