net.sf.freecol.common.networking
Class ChatMessage

java.lang.Object
  extended by net.sf.freecol.common.networking.DOMMessage
      extended by net.sf.freecol.common.networking.ChatMessage

public class ChatMessage
extends DOMMessage

The message that contains a chat string.


Field Summary
private  java.lang.String message
          The text of the message.
private  Player player
          The sending player.
private  boolean privateChat
          Whether this is a private message or not.
private  java.lang.String sender
          The ID of the sender player.
 
Fields inherited from class net.sf.freecol.common.networking.DOMMessage
document, logger
 
Constructor Summary
ChatMessage(Game game, org.w3c.dom.Element element)
          Create a new ChatMessage from a supplied element.
ChatMessage(Player player, java.lang.String message, boolean privateChat)
          Create a new ChatMessage with the supplied message.
 
Method Summary
 java.lang.String getMessage()
          What is the text of this ChatMessage?
 Player getPlayer()
          Who sent this ChatMessage?
static java.lang.String getXMLElementTagName()
          The tag name of the root element representing this object.
 org.w3c.dom.Element handle(FreeColServer server, Connection connection)
          Handle a "chat"-message.
 boolean isPrivate()
          Is this ChatMessage private?
 org.w3c.dom.Element toXMLElement()
          Convert this ChatMessage to XML.
 
Methods inherited from class net.sf.freecol.common.networking.DOMMessage
clientError, createError, createError, createNewDocument, createNewRootElement, getAttribute, getChildElement, getDocument, getFreeColProtocolVersion, getType, hasAttribute, insertAsRoot, isType, setAttribute, setAttribute, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

player

private Player player
The sending player.


sender

private java.lang.String sender
The ID of the sender player.


message

private java.lang.String message
The text of the message.


privateChat

private boolean privateChat
Whether this is a private message or not.

Constructor Detail

ChatMessage

public ChatMessage(Player player,
                   java.lang.String message,
                   boolean privateChat)
Create a new ChatMessage with the supplied message.

Parameters:
player - The player that is sending the message.
message - The text of the message to send.
privateChat - Whether this message is private.

ChatMessage

public ChatMessage(Game game,
                   org.w3c.dom.Element element)
Create a new ChatMessage from a supplied element.

Parameters:
game - The Game this message belongs to.
element - The Element to use to create the message.
Throws:
java.lang.IllegalStateException - if there is problem with the senderID.
Method Detail

getPlayer

public Player getPlayer()
Who sent this ChatMessage?

Returns:
The name of the player that sent this ChatMessage.

getMessage

public java.lang.String getMessage()
What is the text of this ChatMessage?

Returns:
The text of this ChatMessage.

isPrivate

public boolean isPrivate()
Is this ChatMessage private?

Returns:
True if this ChatMessage is private.

handle

public org.w3c.dom.Element handle(FreeColServer server,
                                  Connection connection)
Handle a "chat"-message.

Parameters:
server - The FreeColServer that handles the message.
connection - The Connection message was received on.
Returns:
Null.

toXMLElement

public org.w3c.dom.Element toXMLElement()
Convert this ChatMessage to XML.

Overrides:
toXMLElement in class DOMMessage
Returns:
The XML representation of this message.

getXMLElementTagName

public static java.lang.String getXMLElementTagName()
The tag name of the root element representing this object.

Returns:
"chat".