Package net.sf.freecol.common.model
Class ColonyTradeItem
- java.lang.Object
-
- net.sf.freecol.common.model.FreeColObject
-
- net.sf.freecol.common.model.FreeColGameObject
-
- net.sf.freecol.common.model.TradeItem
-
- net.sf.freecol.common.model.ColonyTradeItem
-
- All Implemented Interfaces:
java.lang.Comparable<FreeColObject>
,ObjectWithId
public class ColonyTradeItem extends TradeItem
A trade item consisting of a colony.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
COLONY_NAME_TAG
private static java.lang.String
COLONY_TAG
private java.lang.String
colonyId
The identifier of the colony to change hands.private java.lang.String
colonyName
The colony name, which is useful when the colony is unknown to the offer recipient.static java.lang.String
TAG
-
Fields inherited from class net.sf.freecol.common.model.TradeItem
INVALID_TRADE_ITEM
-
Fields inherited from class net.sf.freecol.common.model.FreeColGameObject
initialized
-
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE_TAG, DEFAULT_CLASS_INDEX, fcoComparator, ID_ATTRIBUTE_TAG, PARTIAL_ATTRIBUTE_TAG, VALUE_TAG
-
-
Constructor Summary
Constructors Constructor Description ColonyTradeItem(Game game, FreeColXMLReader xr)
Creates a newColonyTradeItem
instance.ColonyTradeItem(Game game, Player source, Player destination, Colony colony)
Creates a newColonyTradeItem
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends FreeColObject>
booleancopyIn(T other)
Copy another FreeColObject into this one if it is compatible.boolean
equals(java.lang.Object o)
int
evaluateFor(Player player)
Evaluate this trade item for a given player.Colony
getColony(Game game)
Get the colony to trade.protected java.lang.String
getColonyId()
protected java.lang.String
getColonyName()
StringTemplate
getLabel()
Get a label for this item.java.lang.String
getXMLTagName()
Get the serialization tag for this object.int
hashCode()
boolean
isUnique()
Is this trade item unique? This is true for the StanceTradeItem and the GoldTradeItem, and false for all others.boolean
isValid()
Is this trade item valid? That is, is the request well formed.protected void
readAttributes(FreeColXMLReader xr)
Reads the attributes of this object from an XML stream.java.lang.String
toString()
protected void
writeAttributes(FreeColXMLWriter xw)
Write the attributes of this object to a stream.-
Methods inherited from class net.sf.freecol.common.model.TradeItem
getDestination, getGold, getGoods, getOther, getSource, getStance, getUnit, getVictim, isInternable, setDestination, setGold, setGoods, setSource, setStance, setUnit
-
Methods inherited from class net.sf.freecol.common.model.FreeColGameObject
checkIntegrity, dispose, disposeResources, fundamentalDispose, getClassIndex, getDisposables, getGame, getLinkTarget, getSpecification, intern, internId, isDisposed, isInitialized, readFromXML, setGame, setSpecification
-
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addAbility, addFeatures, addModifier, addPropertyChangeListener, addPropertyChangeListener, apply, apply, applyModifiers, applyModifiers, arrayKey, compareIds, compareTo, containsAbilityKey, containsModifierKey, copy, copy, copy, copy, copyInCast, dumpObject, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAbilities, getAbilities, getAbilities, getAbilities, getDefenceModifiers, getDisplayObject, getFeatureContainer, getFreeColObjectClass, getFreeColObjectClassByName, getId, getIdNumber, getIdType, getIdTypeByName, getModifiers, getModifiers, getModifiers, getModifiers, getObjectClassIndex, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getSortedAbilities, getSortedModifiers, getSuffix, getSuffix, hasAbility, hasAbility, hasAbility, hasListeners, hasModifier, hasModifier, hasModifier, idEquals, invokeMethod, logFreeColObjects, readChild, readChildren, readFromXMLPartial, removeAbilities, removeAbility, removeFeatures, removeModifier, removeModifiers, removePropertyChangeListener, removePropertyChangeListener, save, save, save, save, serialize, serialize, serialize, serialize, setId, toXML, toXML, toXMLPartial, toXMLPartial, writeChildren
-
-
-
-
Field Detail
-
TAG
public static final java.lang.String TAG
- See Also:
- Constant Field Values
-
colonyId
private java.lang.String colonyId
The identifier of the colony to change hands.
-
colonyName
private java.lang.String colonyName
The colony name, which is useful when the colony is unknown to the offer recipient.
-
COLONY_TAG
private static final java.lang.String COLONY_TAG
- See Also:
- Constant Field Values
-
COLONY_NAME_TAG
private static final java.lang.String COLONY_NAME_TAG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ColonyTradeItem
public ColonyTradeItem(Game game, Player source, Player destination, Colony colony)
Creates a newColonyTradeItem
instance.- Parameters:
game
- The enclosingGame
.source
- The sourcePlayer
.destination
- The destinationPlayer
.colony
- TheColony
to trade.
-
ColonyTradeItem
public ColonyTradeItem(Game game, FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Creates a newColonyTradeItem
instance.- Parameters:
game
- The enclosingGame
.xr
- TheFreeColXMLReader
to read from.- Throws:
javax.xml.stream.XMLStreamException
- if there is an error reading the stream.
-
-
Method Detail
-
getColonyId
protected java.lang.String getColonyId()
-
getColonyName
protected java.lang.String getColonyName()
-
isValid
public boolean isValid()
Is this trade item valid? That is, is the request well formed.
-
isUnique
public boolean isUnique()
Is this trade item unique? This is true for the StanceTradeItem and the GoldTradeItem, and false for all others.
-
getLabel
public StringTemplate getLabel()
Get a label for this item.
-
evaluateFor
public int evaluateFor(Player player)
Evaluate this trade item for a given player.- Specified by:
evaluateFor
in classTradeItem
- Parameters:
player
- ThePlayer
to evaluate for.- Returns:
- A value for the player, INVALID_TRADE_ITEM for invalid.
-
copyIn
public <T extends FreeColObject> boolean copyIn(T other)
Copy another FreeColObject into this one if it is compatible.
-
writeAttributes
protected void writeAttributes(FreeColXMLWriter xw) throws javax.xml.stream.XMLStreamException
Write the attributes of this object to a stream. To be overridden if required by any object that has attributes and uses the toXML(FreeColXMLWriter, String) call.- Overrides:
writeAttributes
in classTradeItem
- Parameters:
xw
- TheFreeColXMLWriter
to write to.- Throws:
javax.xml.stream.XMLStreamException
- if there are any problems writing to the stream.
-
readAttributes
protected void readAttributes(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Reads the attributes of this object from an XML stream.- Overrides:
readAttributes
in classTradeItem
- Parameters:
xr
- TheFreeColXMLReader
to read from.- Throws:
javax.xml.stream.XMLStreamException
- if there is a problem reading the stream.
-
getXMLTagName
public java.lang.String getXMLTagName()
Get the serialization tag for this object.- Specified by:
getXMLTagName
in classFreeColObject
- Returns:
- The tag.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classFreeColObject
-
-