|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.freecol.common.model.FreeColObject
net.sf.freecol.common.model.FreeColGameObject
net.sf.freecol.common.model.TradeRoute
public class TradeRoute
A TradeRoute holds all information for a unit to follow along a trade route.
| Nested Class Summary | |
|---|---|
class |
TradeRoute.Stop
|
| Field Summary | |
|---|---|
private static java.lang.String |
CARGO_TAG
|
private int |
count
The number of carriers using this route. |
private static java.util.logging.Logger |
logger
|
private boolean |
modified
Whether the trade route has been modified. |
private java.lang.String |
name
The name of this trade route. |
private Player |
owner
The Player who owns this trade route. |
private java.util.List<TradeRoute.Stop> |
stops
A list of stops. |
| Fields inherited from class net.sf.freecol.common.model.FreeColGameObject |
|---|
UNITS_TAG_NAME |
| Fields inherited from class net.sf.freecol.common.model.FreeColObject |
|---|
ARRAY_SIZE, ID_ATTRIBUTE, ID_ATTRIBUTE_TAG, INFINITY, NO_ID, PARTIAL_ATTRIBUTE, UNDEFINED, VALUE_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. |
private Location |
findLocation(Game game,
java.lang.String id)
Nasty hack to find the stop location. |
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.List<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)
|
protected void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
Initialize this object from an XML-representation of this object. |
private void |
replaceStops(java.util.List<TradeRoute.Stop> otherStops)
Replace all the stops for this trade route with the stops passed from another trade route. |
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.List<TradeRoute.Stop> newStops)
Set the Stops value. |
java.lang.String |
toString()
Gets a string representation of the object. |
protected void |
toXMLImpl(javax.xml.stream.XMLStreamWriter out,
Player player,
boolean showAll,
boolean toSavedGame)
This method writes an XML-representation of this object to the given stream. |
void |
updateFrom(TradeRoute other)
Copy all fields from another trade route to this one. |
| Methods inherited from class net.sf.freecol.common.model.FreeColGameObject |
|---|
dispose, disposeList, equals, equals, fundamentalDispose, getFreeColGameObject, getFreeColGameObject, getGame, getIntegerID, getSpecification, hashCode, isDisposed, isUninitialized, newLocation, readFromXML, readFromXMLPartialByClass, setDefaultId, setGame, setId, toXML, toXMLImpl, toXMLPartialByClass, updateFreeColGameObject |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final java.util.logging.Logger logger
private static final java.lang.String CARGO_TAG
private java.lang.String name
private int count
private boolean modified
private Player owner
Player who owns this trade route. This is necessary to
ensure that malicious clients can not modify the trade routes of other
players.
private java.util.List<TradeRoute.Stop> stops
| Constructor Detail |
|---|
public TradeRoute(Game game,
java.lang.String name,
Player player)
TradeRoute instance.
game - a Game valuename - a String valueplayer - a Player value
public TradeRoute(Game game,
javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
TradeRoute instance.
game - a Game valuein - a XMLStreamReader value
javax.xml.stream.XMLStreamException - if an error occurs
public TradeRoute(Game game,
org.w3c.dom.Element e)
TradeRoute instance.
game - a Game valuee - an Element value| Method Detail |
|---|
public void updateFrom(TradeRoute other)
other - The route to copy from.public final boolean isModified()
Modified value.
boolean valuepublic final void setModified(boolean newModified)
Modified value.
newModified - The new Modified value.public final java.lang.String getName()
Name value.
String valuepublic final void setName(java.lang.String newName)
Name value.
newName - The new Name value.public int getCount()
Count value.
public void setCount(int newCount)
Count value.
newCount - The new Count value.public void addStop(TradeRoute.Stop stop)
Stop to this trade route.
stop - The Stop to add.public final Player getOwner()
Owner value.
getOwner in interface OwnablePlayer valuepublic final void setOwner(Player newOwner)
Owner value.
setOwner in interface OwnablenewOwner - The new Owner value.public java.util.List<Unit> getAssignedUnits()
public final java.util.List<TradeRoute.Stop> getStops()
Stops value.
ArrayList valuepublic final void setStops(java.util.List<TradeRoute.Stop> newStops)
Stops value.
newStops - The new Stops value.public TradeRoute clone()
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.
clone in class java.lang.Objectprivate void replaceStops(java.util.List<TradeRoute.Stop> otherStops)
otherStops - The new stops to use.clone()
public static boolean isStopValid(Unit unit,
TradeRoute.Stop stop)
public static boolean isStopValid(Player player,
TradeRoute.Stop stop)
public static java.lang.String getStopXMLElementTagName()
protected void toXMLImpl(javax.xml.stream.XMLStreamWriter out,
Player player,
boolean showAll,
boolean toSavedGame)
throws javax.xml.stream.XMLStreamException
FreeColGameObjectPlayer will
be added to that representation if showAll is
set to false.
toXMLImpl in class FreeColGameObjectout - The target stream.player - The Player this XML-representation
should be made for, or null if
showAll == true.showAll - Only attributes visible to player
will be added to the representation if showAll
is set to false.toSavedGame - If true then information that
is only needed when saving a game is added.
javax.xml.stream.XMLStreamException - if there are any problems writing
to the stream.
private Location findLocation(Game game,
java.lang.String id)
protected void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
readFromXMLImpl in class FreeColObjectin - The input stream with the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.public java.lang.String toString()
FreeColGameObject
toString in class FreeColGameObjectpublic static java.lang.String getXMLElementTagName()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||