net.sf.freecol.common.networking
Class ChangeStateMessage

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

public class ChangeStateMessage
extends DOMMessage

The message sent when changing a unit state.


Field Summary
private  java.lang.String stateString
          The state as a string.
private  java.lang.String unitId
          The id of the unit to change.
 
Fields inherited from class net.sf.freecol.common.networking.DOMMessage
document, logger
 
Constructor Summary
ChangeStateMessage(Game game, org.w3c.dom.Element element)
          Create a new ChangeStateMessage from a supplied element.
ChangeStateMessage(Unit unit, Unit.UnitState state)
          Create a new ChangeStateMessage with the supplied unit and state.
 
Method Summary
static java.lang.String getXMLElementTagName()
          The tag name of the root element representing this object.
 org.w3c.dom.Element handle(FreeColServer server, Player player, Connection connection)
          Handle a "changeState"-message.
 org.w3c.dom.Element toXMLElement()
          Convert this ChangeStateMessage to XML.
 
Methods inherited from class net.sf.freecol.common.networking.DOMMessage
clientError, collapseElements, createError, createError, createNewDocument, createNewRootElement, elementToString, 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

unitId

private java.lang.String unitId
The id of the unit to change.


stateString

private java.lang.String stateString
The state as a string.

Constructor Detail

ChangeStateMessage

public ChangeStateMessage(Unit unit,
                          Unit.UnitState state)
Create a new ChangeStateMessage with the supplied unit and state.

Parameters:
unit - The Unit to change the state of.
state - The new state.

ChangeStateMessage

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

Parameters:
game - The Game this message belongs to.
element - The Element to use to create the message.
Method Detail

handle

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

Parameters:
server - The FreeColServer handling the message.
player - The Player the message applies to.
connection - The Connection message was received on.
Returns:
An update containing the changeStated unit, or an error Element on failure.

toXMLElement

public org.w3c.dom.Element toXMLElement()
Convert this ChangeStateMessage 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:
"changeState".