net.sf.freecol.common.networking
Class DiplomacyMessage

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

public class DiplomacyMessage
extends DOMMessage

The message sent when executing a diplomatic trade.


Field Summary
private  DiplomaticTrade agreement
          The trade to make.
private  Settlement settlement
          The settlement to negotiate with.
private  Unit unit
          The unit doing the trading.
 
Fields inherited from class net.sf.freecol.common.networking.DOMMessage
document, logger
 
Constructor Summary
DiplomacyMessage(Game game, org.w3c.dom.Element element)
          Create a new DiplomacyMessage from a supplied element.
DiplomacyMessage(Unit unit, Settlement settlement, DiplomaticTrade agreement)
          Create a new DiplomacyMessage.
 
Method Summary
 DiplomaticTrade getAgreement()
          Get the agreement (a DiplomaticTrade) in this message.
 Settlement getSettlement()
          Get the Settlement at which a diplomatic exchange happens.
 Unit getUnit()
          Get the Unit which began this diplomatic exchange.
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 "diplomacy"-message.
 void setAgreement(DiplomaticTrade agreement)
          Set the agreement (a DiplomaticTrade) in this message.
 org.w3c.dom.Element toXMLElement()
          Convert this DiplomacyMessage 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

unit

private Unit unit
The unit doing the trading. Can not use just an id as the unit might be invisible to the settlement due to being aboard a carrier.


settlement

private Settlement settlement
The settlement to negotiate with.


agreement

private DiplomaticTrade agreement
The trade to make.

Constructor Detail

DiplomacyMessage

public DiplomacyMessage(Unit unit,
                        Settlement settlement,
                        DiplomaticTrade agreement)
Create a new DiplomacyMessage.

Parameters:
unit - The Unit that is negotiating.
settlement - The Settlement to negotiate with.
agreement - The DiplomaticTrade to make.

DiplomacyMessage

public DiplomacyMessage(Game game,
                        org.w3c.dom.Element element)
Create a new DiplomacyMessage from a supplied element. The unit is supplied in case it was hidden in some way, such as aboard a ship.

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

getUnit

public Unit getUnit()
Get the Unit which began this diplomatic exchange.

Returns:
The unit, or null if none.

getSettlement

public Settlement getSettlement()
Get the Settlement at which a diplomatic exchange happens.

Returns:
The settlement, or null if none.

getAgreement

public DiplomaticTrade getAgreement()
Get the agreement (a DiplomaticTrade) in this message.

Returns:
The agreement in this message.

setAgreement

public void setAgreement(DiplomaticTrade agreement)
Set the agreement (a DiplomaticTrade) in this message.

Parameters:
agreement - The DiplomaticTrade to set.

handle

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

Parameters:
server - The FreeColServer that handles the message.
connection - The Connection the message is from.
Returns:
An Element describing the trade with either "accept" or "reject" status, null on trade failure, or an error Element on outright error.

toXMLElement

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