talx.model.filters
Class CommandFilter
java.lang.Object
talx.model.filters.ReceiverFilterAdapter
talx.model.filters.CommandFilter
- All Implemented Interfaces:
- ControllerConstants, java.util.EventListener, ReceiverFilter, ReceiverFilterListener, TALFeature
- public class CommandFilter
- extends ReceiverFilterAdapter
- implements ControllerConstants
Searches incoming messages for test commands and game moves.
|
Method Summary |
protected boolean |
filterMessage(javax.mail.internet.MimeMessage msg)
Filters messages containing CPIS commands and game moves. |
javax.mail.internet.MimeMessage |
getTestResults(java.util.Date timestamp)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
LOG_DATE_FORMAT
public static final java.text.SimpleDateFormat LOG_DATE_FORMAT
CommandFilter
public CommandFilter(GameManager gm,
Settings s,
java.lang.String param)
- Parameters:
param - A set of key=value pairs that describe the handling of commands.
This are:
- tech - the address that system messages should look like they come from.
- date - a valid data format string for use with Java's SimpleDateFormat class.
- Throws:
java.lang.NullPointerException - if the required keys are not present in param.
filterMessage
protected boolean filterMessage(javax.mail.internet.MimeMessage msg)
- Filters messages containing CPIS commands and game moves.
Test Commands
Any message containing a test message header will be
filtered. Another message, appearing to come from tech
is placed in the pipe, saying that the test succeeded.
Game Moves
Any messages that contain game moves are moved to the filtered
pipe. This filter determines game moves by looking for a header
matching the GameManager.MOVE_MESSAGE_HEADER. If that header
is found, the message is interpreted as a move and this filter
tries to interpret the body as a serialized GameMemento. This
process will fail if the message is a multipart message or if
the single part was not created as a ObjectOutputStream and
had a single GameMemento written to it. If the process fails,
the reason is logged and the move is dropped. The sender is
not notified.
Important Note: Once the filter sees the proper header,
the message is filtered, whether or not a GameState can
successfully be extracted.
- Specified by:
filterMessage in class ReceiverFilterAdapter
- Parameters:
msg - The message to be filtered by this method.
- Returns:
- true if the message should be passed along, false if the message should
be dropped.
- See Also:
- CPIS Command Syntax
getTestResults
public javax.mail.internet.MimeMessage getTestResults(java.util.Date timestamp)
throws javax.mail.MessagingException
- Throws:
javax.mail.MessagingException
© 2001-2005 University of Oregon.
Eugene OR 97403, U.S.A. All Rights Reserved.