net.sf.freecol.common.networking
Class SetTradeRoutesMessage

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

public class SetTradeRoutesMessage
extends DOMMessage

The message sent when setting the trade routes.


Field Summary
private static java.lang.String idPrefix
           
private  java.util.List<TradeRoute> tradeRoutes
          The trade routes to set.
 
Fields inherited from class net.sf.freecol.common.networking.DOMMessage
document, logger
 
Constructor Summary
SetTradeRoutesMessage(Game game, org.w3c.dom.Element element)
          Create a new SetTradeRoutesMessage from a supplied element.
SetTradeRoutesMessage(java.util.List<TradeRoute> tradeRoutes)
          Create a new SetTradeRoutesMessage with the supplied routes.
 
Method Summary
static java.lang.String getPrefix(TradeRoute route)
           
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 "setTradeRoutes"-message.
static boolean hasPrefix(TradeRoute route)
           
static java.lang.String removePrefix(TradeRoute route)
           
 org.w3c.dom.Element toXMLElement()
          Convert this SetTradeRoutesMessage to XML.
static TradeRoute tradeRouteFromElement(Game game, org.w3c.dom.Element element)
          Creates a trade route from an element.
 
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

idPrefix

private static final java.lang.String idPrefix
See Also:
Constant Field Values

tradeRoutes

private java.util.List<TradeRoute> tradeRoutes
The trade routes to set.

Constructor Detail

SetTradeRoutesMessage

public SetTradeRoutesMessage(java.util.List<TradeRoute> tradeRoutes)
Create a new SetTradeRoutesMessage with the supplied routes.

Parameters:
tradeRoutes - A list of TradeRoutes to set.

SetTradeRoutesMessage

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

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

tradeRouteFromElement

public static TradeRoute tradeRouteFromElement(Game game,
                                               org.w3c.dom.Element element)
Creates a trade route from an element. Be careful not to allow real IDs to surface or the trade route constructor will replace the existing game trade route with the one in the element before we have finished checking it. Public routine as updateTradeRoute has the same problem.

Parameters:
game - The Game to create in.
element - An Element to read from.
Returns:
A TradeRoute on success, null on error.

getPrefix

public static java.lang.String getPrefix(TradeRoute route)

removePrefix

public static java.lang.String removePrefix(TradeRoute route)

hasPrefix

public static boolean hasPrefix(TradeRoute route)

handle

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

Parameters:
server - The FreeColServer handling the message.
connection - The Connection message was received on.
Returns:
Null, or an error Element on failure.

toXMLElement

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