net.sf.freecol.common.model
Class TradeRoute

java.lang.Object
  extended by net.sf.freecol.common.model.FreeColObject
      extended by net.sf.freecol.common.model.FreeColGameObject
          extended by net.sf.freecol.common.model.TradeRoute
All Implemented Interfaces:
java.lang.Cloneable, Ownable

public class TradeRoute
extends FreeColGameObject
implements java.lang.Cloneable, Ownable

A TradeRoute holds all information for a unit to follow along a trade route.


Nested Class Summary
 class TradeRoute.Stop
           
 
Field Summary
static TradeRoute NO_TRADE_ROUTE
           
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ID_ATTRIBUTE_TAG
 
Constructor Summary
TradeRoute(Game game, org.w3c.dom.Element e)
          Creates a new TradeRoute instance.
TradeRoute(Game game, java.lang.String name, Player player)
          Creates a new TradeRoute instance.
TradeRoute(Game game, javax.xml.stream.XMLStreamReader in)
          Creates a new TradeRoute instance.
 
Method Summary
 void addStop(TradeRoute.Stop stop)
          Add a new Stop to this trade route.
 TradeRoute clone()
          Clone the trade route and return a deep copy.
 java.util.List<Unit> getAssignedUnits()
           
 int getCount()
          Get the Count value.
 java.lang.String getName()
          Get the Name value.
 Player getOwner()
          Get the Owner value.
 java.util.ArrayList<TradeRoute.Stop> getStops()
          Get the Stops value.
static java.lang.String getStopXMLElementTagName()
          Returns the tag name of the root element representing this object.
static java.lang.String getXMLElementTagName()
          Returns the tag name of the root element representing this object.
 boolean isModified()
          Get the Modified value.
static boolean isStopValid(Player player, TradeRoute.Stop stop)
           
static boolean isStopValid(Unit unit, TradeRoute.Stop stop)
           
 void newTurn()
          A traderoute does not do anything on a new turn.
 void setCount(int newCount)
          Set the Count value.
 void setModified(boolean newModified)
          Set the Modified value.
 void setName(java.lang.String newName)
          Set the Name value.
 void setOwner(Player newOwner)
          Set the Owner value.
 void setStops(java.util.ArrayList<TradeRoute.Stop> newStops)
          Set the Stops value.
 java.lang.String toString()
          Returns a string representation of the object.
 void updateFrom(TradeRoute other)
          Copy all fields from another trade route to this one.
 
Methods inherited from class net.sf.freecol.common.model.FreeColGameObject
addToRemoveElement, dispose, equals, equals, getFreeColGameObject, getFreeColGameObject, getGame, getGameOptions, getIntegerID, hashCode, hasID, isDisposed, isUninitialized, readFromXML, setGame, setId, toSavedXML, toXML, updateFreeColGameObject, updateID
 
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAttribute, getAttribute, getAttribute, getAttribute, getId, getPropertyChangeListeners, getPropertyChangeListeners, hasAbility, hasAttribute, hasListeners, readFromXMLElement, removePropertyChangeListener, removePropertyChangeListener, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, writeAttribute, writeFreeColGameObject
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_TRADE_ROUTE

public static final TradeRoute NO_TRADE_ROUTE
Constructor Detail

TradeRoute

public TradeRoute(Game game,
                  java.lang.String name,
                  Player player)
Creates a new TradeRoute instance.

Parameters:
game - a Game value
name - a String value
player - a Player value

TradeRoute

public TradeRoute(Game game,
                  javax.xml.stream.XMLStreamReader in)
           throws javax.xml.stream.XMLStreamException
Creates a new TradeRoute instance.

Parameters:
game - a Game value
in - a XMLStreamReader value
Throws:
javax.xml.stream.XMLStreamException - if an error occurs

TradeRoute

public TradeRoute(Game game,
                  org.w3c.dom.Element e)
Creates a new TradeRoute instance.

Parameters:
game - a Game value
e - an Element value
Method Detail

updateFrom

public void updateFrom(TradeRoute other)
Copy all fields from another trade route to this one. This is useful when an updated route is received on the server side from the client.

Parameters:
other - The route to copy from.

isModified

public final boolean isModified()
Get the Modified value.

Returns:
a boolean value

setModified

public final void setModified(boolean newModified)
Set the Modified value.

Parameters:
newModified - The new Modified value.

getName

public final java.lang.String getName()
Get the Name value.

Returns:
a String value

setName

public final void setName(java.lang.String newName)
Set the Name value.

Parameters:
newName - The new Name value.

getCount

public int getCount()
Get the Count value.

Returns:
The count of trade route users.

setCount

public void setCount(int newCount)
Set the Count value.

Parameters:
newCount - The new Count value.

addStop

public void addStop(TradeRoute.Stop stop)
Add a new Stop to this trade route.

Parameters:
stop - The Stop to add.

getOwner

public final Player getOwner()
Get the Owner value.

Specified by:
getOwner in interface Ownable
Returns:
a Player value

setOwner

public final void setOwner(Player newOwner)
Set the Owner value.

Specified by:
setOwner in interface Ownable
Parameters:
newOwner - The new Owner value.

toString

public java.lang.String toString()
Description copied from class: FreeColGameObject
Returns a string representation of the object.

Overrides:
toString in class FreeColGameObject
Returns:
The String

getAssignedUnits

public java.util.List<Unit> getAssignedUnits()

getStops

public final java.util.ArrayList<TradeRoute.Stop> getStops()
Get the Stops value.

Returns:
an ArrayList value

setStops

public final void setStops(java.util.ArrayList<TradeRoute.Stop> newStops)
Set the Stops value.

Parameters:
newStops - The new Stops value.

newTurn

public void newTurn()
A traderoute does not do anything on a new turn.


clone

public TradeRoute clone()
Clone the trade route and return a deep copy.

The copied trade route has no reference back to the original and can safely be used as a temporary copy. It is NOT registered with the game, but will have the same unique id as the original.

Overrides:
clone in class java.lang.Object
Returns:
deep copy of trade route.

isStopValid

public static boolean isStopValid(Unit unit,
                                  TradeRoute.Stop stop)

isStopValid

public static boolean isStopValid(Player player,
                                  TradeRoute.Stop stop)

getXMLElementTagName

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

Returns:
"tradeRoute".

getStopXMLElementTagName

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

Returns:
"tradeRouteStop".