unsw.cse.mica.agent
Class Message

java.lang.Object
  extended by unsw.cse.mica.agent.Message
Direct Known Subclasses:
BlackboardMessage

public class Message
extends java.lang.Object

A representation of the messages that the blackboard sends. This is useful as a way of internally passing these messages around or storing them.

Author:
jhw

Field Summary
static java.lang.String TYPE_DELETEDMOB
          A constant string to indicate that the message is a handleDeletedMob message
static java.lang.String TYPE_NEWMOB
          A constant string to indicate that the message is a handleNewMob message
static java.lang.String TYPE_REPLACEDMOB
           
static java.lang.String TYPE_TYPEMANAGERCHANGED
          A constant string to indicate that the message is a handleTypeManagerchanged message
 
Constructor Summary
Message(java.lang.String type)
          Create a new Message object with the given type.
Message(java.lang.String type, Mob mob)
          Create a new Message object with the given type and mob.
Message(java.lang.String type, Mob mob1, Mob mob2)
          Create a new Message object with the given type and mobs.
 
Method Summary
 Mob getMob1()
          Get the mob associated with this message
 Mob getMob2()
           
 java.lang.String getType()
          Get the type of this message
 boolean isDeletedMob()
          See if this message is a TYPE_DELETEDMOB message
 boolean isNewMob()
          See if this message is a TYPE_NEWMOB message
 boolean isReplacedMob()
          See if this message is a TYPE_REPLACEDMOB message
 boolean isTypeManagerChanged()
          See if this message is a TYPE_TYPEMANAGERCHANGED message
 java.lang.String toString()
          Get a string representation of this message
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_NEWMOB

public static final java.lang.String TYPE_NEWMOB
A constant string to indicate that the message is a handleNewMob message

See Also:
Constant Field Values

TYPE_DELETEDMOB

public static final java.lang.String TYPE_DELETEDMOB
A constant string to indicate that the message is a handleDeletedMob message

See Also:
Constant Field Values

TYPE_REPLACEDMOB

public static final java.lang.String TYPE_REPLACEDMOB
See Also:
Constant Field Values

TYPE_TYPEMANAGERCHANGED

public static final java.lang.String TYPE_TYPEMANAGERCHANGED
A constant string to indicate that the message is a handleTypeManagerchanged message

See Also:
Constant Field Values
Constructor Detail

Message

public Message(java.lang.String type)
Create a new Message object with the given type. This constructor should only be used for TYPE_TYPEMANAGERCHANGED messages.

Parameters:
type - The type for this message. Should be TYPE_TYPEMANAGERCHANGED

Message

public Message(java.lang.String type,
               Mob mob)
Create a new Message object with the given type and mob. This constructor should be used for TYPE_NEWMOB and TYPE_DELETEDMOB messages.

Parameters:
type - The type for this message
mob - The mob that caused this message

Message

public Message(java.lang.String type,
               Mob mob1,
               Mob mob2)
Create a new Message object with the given type and mobs. This constructor should be used for TYPE_REPLACEDMOB messages.

Parameters:
type - The type for this message
mob1 - the mob that caused this message
mob2 - another mob that this message relates to
Method Detail

getType

public java.lang.String getType()
Get the type of this message

Returns:
the type of this message

isNewMob

public boolean isNewMob()
See if this message is a TYPE_NEWMOB message

Returns:
true if this is a TYPE_NEWMOB message, false otherwise

isDeletedMob

public boolean isDeletedMob()
See if this message is a TYPE_DELETEDMOB message

Returns:
true if this is a TYPE_DELETEDMOB message, false otherwise

isReplacedMob

public boolean isReplacedMob()
See if this message is a TYPE_REPLACEDMOB message

Returns:
true if this is a TYPE_REPLACEDMOB message, false otherwise

isTypeManagerChanged

public boolean isTypeManagerChanged()
See if this message is a TYPE_TYPEMANAGERCHANGED message

Returns:
true if this is a TYPE_TYPEMANAGERCHANGED message, false otherwise

getMob1

public Mob getMob1()
Get the mob associated with this message

Returns:
the mob associated with the message, or null if the mnessage does not have a mob associated with it.

getMob2

public Mob getMob2()

toString

public java.lang.String toString()
Get a string representation of this message

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this message.