de.hagenah.diplomacy.game
Class MessageFilter

java.lang.Object
  extended by de.hagenah.diplomacy.game.MessageFilter
All Implemented Interfaces:
java.io.Serializable

public class MessageFilter
extends java.lang.Object
implements java.io.Serializable

A filter for messages.

See Also:
Serialized Form

Constructor Summary
MessageFilter(boolean broadcastmessages, boolean pressmessages, boolean diarymessages, java.lang.String text, java.util.Collection persons)
          Creates a message filter
 
Method Summary
 boolean areAllMatching()
          Do all messages match to this filter?
 boolean areBroadcastMessagesIncluded()
          Are broadcast messages included?
 boolean areDiaryMessagesIncluded()
          Are diary messages included?
 boolean arePressMessagesIncluded()
          Are press messages included?
 boolean equals(java.lang.Object obj)
          Indicates whether obj is "equal to" this one.
 java.util.SortedSet getPersons()
          Returns the persons who must know the message.
 java.lang.String getText()
          Returns the text that must be contained in the message.
 int hashCode()
          Returns a hashcode for this message filter.
 boolean isMatching(DiaryEntry entry)
          Tests whether the diary entry matches.
 boolean isMatching(Message msg, MapData map)
          Tests whether the msg matches.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageFilter

public MessageFilter(boolean broadcastmessages,
                     boolean pressmessages,
                     boolean diarymessages,
                     java.lang.String text,
                     java.util.Collection persons)
Creates a message filter

Parameters:
broadcastmessages - Are broadcast messages included?
pressmessages - Are press messages included?
diarymessages - Are diary messages included?
text - This text that must be contained in the message
persons - The persons who must know the message
Method Detail

areBroadcastMessagesIncluded

public boolean areBroadcastMessagesIncluded()
Are broadcast messages included?

Returns:
true if broadcast messages are included

arePressMessagesIncluded

public boolean arePressMessagesIncluded()
Are press messages included?

Returns:
true if press messages are included

areDiaryMessagesIncluded

public boolean areDiaryMessagesIncluded()
Are diary messages included?

Returns:
true if diary messages are included

getText

public java.lang.String getText()
Returns the text that must be contained in the message.

Returns:
The text

getPersons

public java.util.SortedSet getPersons()
Returns the persons who must know the message.

Returns:
The persons

isMatching

public boolean isMatching(Message msg,
                          MapData map)
Tests whether the msg matches.

Parameters:
msg - The message to test
map - The map of the game
Returns:
true if the message matches

isMatching

public boolean isMatching(DiaryEntry entry)
Tests whether the diary entry matches.

Parameters:
entry - The diary entry to test
Returns:
true if the diary entry matches

areAllMatching

public boolean areAllMatching()
Do all messages match to this filter?

Returns:
true if all messages match (none are filtered)

equals

public boolean equals(java.lang.Object obj)
Indicates whether obj is "equal to" this one.

Overrides:
equals in class java.lang.Object
Parameters:
obj - The other obj
Returns:
true if obj is a MessageFilter and does the same filtering

hashCode

public int hashCode()
Returns a hashcode for this message filter.

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code.