net.sf.freecol.common.model
Class TradeItem

java.lang.Object
  extended by net.sf.freecol.common.model.FreeColObject
      extended by net.sf.freecol.common.model.TradeItem
Direct Known Subclasses:
ColonyTradeItem, GoldTradeItem, GoodsTradeItem, StanceTradeItem, UnitTradeItem

public abstract class TradeItem
extends FreeColObject

One of the items a DiplomaticTrade consists of.


Field Summary
private  Player destination
          The player who is to receive this item.
protected  Game game
          The game this TradeItem belongs to.
private  Player source
          The player who is to provide this item.
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE, ID_ATTRIBUTE, ID_ATTRIBUTE_TAG, INFINITY, logger, NO_ID, PARTIAL_ATTRIBUTE, UNDEFINED, VALUE_TAG
 
Constructor Summary
TradeItem(Game game, java.lang.String id, Player source, Player destination)
          Creates a new TradeItem instance.
TradeItem(Game game, javax.xml.stream.XMLStreamReader in)
          Creates a new TradeItem instance.
 
Method Summary
 Colony getColony()
          Get the colony to trade.
 Player getDestination()
          Get the Destination value.
 int getGold()
          Get the gold to trade.
 Goods getGoods()
          Get the goods to trade.
 Player getSource()
          Get the Source value.
 Player.Stance getStance()
          Get the stance to trade.
 Unit getUnit()
          Get the unit to trade.
abstract  boolean isUnique()
          Returns whether this TradeItem must be unique.
abstract  boolean isValid()
          Returns whether this TradeItem is valid.
protected  void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
          Initialize this object from an XML-representation of this object.
 void setColony(Colony colony)
          Set the colony to trade.
 void setDestination(Player newDestination)
          Set the Destination value.
 void setGold(int gold)
          Set the gold to trade.
 void setGoods(Goods goods)
          Set the goods to trade.
 void setSource(Player newSource)
          Set the Source value.
 void setStance(Player.Stance stance)
          Set the stance to trade.
 void setUnit(Unit unit)
          Set the unit to trade.
protected  void writeAttributes(javax.xml.stream.XMLStreamWriter out)
          Write the attributes of this object to a stream.
 
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addPropertyChangeListener, addPropertyChangeListener, dumpObject, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getId, getPropertyChangeListeners, getPropertyChangeListeners, getSpecification, getXMLElementTagName, hasAbility, hasAttribute, hasListeners, readAttributes, readAttributes, readChild, readChild, readChildren, readChildren, readFromArrayElement, readFromArrayElement, readFromListElement, readFromXML, readFromXMLElement, readFromXMLImpl, readFromXMLPartialImpl, removePropertyChangeListener, removePropertyChangeListener, save, save, setId, setSpecification, toXML, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, toXMLImpl, toXMLPartialImpl, writeAttribute, writeChildren
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

game

protected Game game
The game this TradeItem belongs to.


source

private Player source
The player who is to provide this item.


destination

private Player destination
The player who is to receive this item.

Constructor Detail

TradeItem

public TradeItem(Game game,
                 java.lang.String id,
                 Player source,
                 Player destination)
Creates a new TradeItem instance.

Parameters:
game - a Game value
id - a String value
source - a Player value
destination - a Player value

TradeItem

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

Parameters:
game - a Game value
in - a XMLStreamReader value
Throws:
javax.xml.stream.XMLStreamException
Method Detail

getSource

public final Player getSource()
Get the Source value.

Returns:
a Player value

setSource

public final void setSource(Player newSource)
Set the Source value.

Parameters:
newSource - The new Source value.

getDestination

public final Player getDestination()
Get the Destination value.

Returns:
a Player value

setDestination

public final void setDestination(Player newDestination)
Set the Destination value.

Parameters:
newDestination - The new Destination value.

isValid

public abstract boolean isValid()
Returns whether this TradeItem is valid.

Returns:
a boolean value

isUnique

public abstract boolean isUnique()
Returns whether this TradeItem must be unique. This is true for the StanceTradeItem and the GoldTradeItem, and false for all others.

Returns:
a boolean value

getColony

public Colony getColony()
Get the colony to trade.

Returns:
The colony to trade.

setColony

public void setColony(Colony colony)
Set the colony to trade.

Parameters:
colony - The new Colony to trade.

getGoods

public Goods getGoods()
Get the goods to trade.

Returns:
The goods to trade.

setGoods

public void setGoods(Goods goods)
Set the goods to trade.

Parameters:
goods - The new Goods to trade.

getGold

public int getGold()
Get the gold to trade.

Returns:
The gold to trade.

setGold

public void setGold(int gold)
Set the gold to trade.

Parameters:
gold - The new gold value.

getStance

public Player.Stance getStance()
Get the stance to trade.

Returns:
The stance to trade.

setStance

public void setStance(Player.Stance stance)
Set the stance to trade.

Parameters:
stance - The new Stance to trade.

getUnit

public Unit getUnit()
Get the unit to trade.

Returns:
The unit to trade.

setUnit

public void setUnit(Unit unit)
Set the unit to trade.

Parameters:
unit - The new Unit to trade.

writeAttributes

protected void writeAttributes(javax.xml.stream.XMLStreamWriter out)
                        throws javax.xml.stream.XMLStreamException
Write the attributes of this object to a stream.

Overrides:
writeAttributes in class FreeColObject
Parameters:
out - The target stream.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

readFromXMLImpl

protected void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
                        throws javax.xml.stream.XMLStreamException
Initialize this object from an XML-representation of this object.

Overrides:
readFromXMLImpl in class FreeColObject
Parameters:
in - The input stream with the XML.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.