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
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ID_ATTRIBUTE_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
 Player getDestination()
          Get the Destination value.
 Game getGame()
          Get the Game value.
 Player getSource()
          Get the Source value.
abstract  boolean isUnique()
          Returns whether this TradeItem must be unique.
abstract  boolean isValid()
          Returns whether this TradeItem is valid.
abstract  java.util.List<FreeColGameObject> makeTrade()
          Concludes the trade.
 void setDestination(Player newDestination)
          Set the Destination value.
 void setGame(Game newGame)
          Set the Game value.
 void setSource(Player newSource)
          Set the Source value.
 void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
          This method writes an XML-representation of this object to the given stream.
 
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, getXMLElementTagName, hasAbility, hasAttribute, hasListeners, readFromXML, readFromXMLElement, removePropertyChangeListener, removePropertyChangeListener, toXML, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, writeAttribute, writeFreeColGameObject
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

getGame

public final Game getGame()
Get the Game value.

Returns:
a Game value

setGame

public final void setGame(Game newGame)
Set the Game value.

Parameters:
newGame - The new Game value.

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

makeTrade

public abstract java.util.List<FreeColGameObject> makeTrade()
Concludes the trade.

Returns:
An item to be updated, or null if none required.

toXMLImpl

public void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
               throws javax.xml.stream.XMLStreamException
This method writes an XML-representation of this object to the given stream.

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