aigames.soccer.application
Class Message

java.lang.Object
  extended byaigames.soccer.application.Message

public class Message
extends java.lang.Object

This class describes message passed from communication module. It should be compatible with AI Soccer protocol.

Version:
$Id: Message.java,v 1.9 2004/05/08 21:55:27 mwerla Exp $

Field Summary
static int CONFIRMATION
          CONFIRMATION message type
static int GAME_OVER
          GAME_OVER message type
static int HELLO
          HELLO message type
static int LOG
          LOG message type
static int MOVE
          MOVE message type
static int PARAMS
          PARAMS message type
static int UNKNOWN
          UNKNOWN message type
 
Constructor Summary
Message(UserId userId, org.dom4j.Document message)
          Message constructor.
 
Method Summary
 java.lang.String getLastValidationReason()
          Returns validation result - can be used after calling validate(Validator) method.
 org.dom4j.Document getMessage()
          Returns Document with message body.
 int getMessageId()
          Returns unique message id.
 java.lang.String getMessageIdAsString()
          Returns string representation of user id.
 int getMessageType()
          Return message type.
 Move getMove()
          Returns move.
 java.util.Date getSendDate()
          Returns date when the message was sent.
 UserId getUserId()
          Returns user id of a user which send the message.
 void incResendCounter()
          Increases counter which shows how many times message was resend.
 void setSendDate(java.util.Date sendDate)
          Sets message send date.
 boolean validate(Validator validator)
          Validates message with given validator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HELLO

public static final int HELLO
HELLO message type

See Also:
Constant Field Values

MOVE

public static final int MOVE
MOVE message type

See Also:
Constant Field Values

PARAMS

public static final int PARAMS
PARAMS message type

See Also:
Constant Field Values

LOG

public static final int LOG
LOG message type

See Also:
Constant Field Values

GAME_OVER

public static final int GAME_OVER
GAME_OVER message type

See Also:
Constant Field Values

CONFIRMATION

public static final int CONFIRMATION
CONFIRMATION message type

See Also:
Constant Field Values

UNKNOWN

public static final int UNKNOWN
UNKNOWN message type

See Also:
Constant Field Values
Constructor Detail

Message

public Message(UserId userId,
               org.dom4j.Document message)
Message constructor.

Parameters:
userId - Id of user which sent the message.
message - Sent message.
Method Detail

getLastValidationReason

public java.lang.String getLastValidationReason()
Returns validation result - can be used after calling validate(Validator) method.

Returns:
Validation result.

getMessageId

public int getMessageId()
Returns unique message id.

Returns:
Unique message id.

getMessageType

public int getMessageType()
Return message type.

Returns:
Message type.

getMessage

public org.dom4j.Document getMessage()
Returns Document with message body.

Returns:
Document with message body.

validate

public boolean validate(Validator validator)
Validates message with given validator.

Parameters:
validator - Validator that should be used to validate message.
Returns:
True if message is valid, otherwise false.

getUserId

public UserId getUserId()
Returns user id of a user which send the message.

Returns:
User id.

getMessageIdAsString

public java.lang.String getMessageIdAsString()
Returns string representation of user id.

Returns:
String representation of user id

getSendDate

public java.util.Date getSendDate()
Returns date when the message was sent.

Returns:
Date when the message was sent.

setSendDate

public void setSendDate(java.util.Date sendDate)
Sets message send date.

Parameters:
sendDate - The send date to set.

incResendCounter

public void incResendCounter()
Increases counter which shows how many times message was resend.


getMove

public Move getMove()
Returns move. It should be used only if message type is MOVE.

Returns:
Returns the move.


Copyright © 2001-2004 MoMaT & MWe Team. All Rights Reserved.