net.sf.freecol.common.model
Class DiplomaticTrade

java.lang.Object
  extended by net.sf.freecol.common.model.FreeColObject
      extended by net.sf.freecol.common.model.DiplomaticTrade

public class DiplomaticTrade
extends FreeColObject

The class DiplomaticTrade represents an offer one player can make another.


Field Summary
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ID_ATTRIBUTE_TAG
 
Constructor Summary
DiplomaticTrade(Game game, org.w3c.dom.Element element)
          Creates a new DiplomaticTrade instance.
DiplomaticTrade(Game game, Player sender, Player recipient)
          Creates a new DiplomaticTrade instance.
DiplomaticTrade(Game game, Player sender, Player recipient, java.util.List<TradeItem> items)
          Creates a new DiplomaticTrade instance.
 
Method Summary
 void add(TradeItem newItem)
          Add a TradeItem to the DiplomaticTrade.
 java.util.List<Colony> getColoniesGivenBy(Player player)
          Returns a list of colonies given by Player
 Game getGame()
          Gets the game object this DiplomaticTrade belongs to.
 java.util.List<Goods> getGoodsGivenBy(Player player)
          Returns a list of goods given by Player
 Player getRecipient()
          Get the Recipient value.
 Player getSender()
          Get the Sender value.
 Player.Stance getStance()
          Returns the stance being offered, or null if none is being offered.
 java.util.List<TradeItem> getTradeItems()
          Returns all TradeItems.
static java.lang.String getXMLElementTagName()
          Gets the tag name of the root element representing this object.
 boolean isAccept()
          Get the Accept value.
 java.util.Iterator<TradeItem> iterator()
          Returns an iterator for all TradeItems.
 java.util.List<FreeColGameObject> makeTrade()
          Calls the makeTrade method of all TradeItems.
 void remove(int index)
          Remove a TradeItem from the DiplomaticTrade.
 void remove(TradeItem newItem)
          Remove a TradeItem from the DiplomaticTrade.
 void removeType(TradeItem someItem)
          Removes all trade items of the same class as the given argument.
 void setAccept(boolean newAccept)
          Set the Accept value.
 void setRecipient(Player newRecipient)
          Set the Recipient value.
 void setSender(Player newSender)
          Set the Sender 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, 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

DiplomaticTrade

public DiplomaticTrade(Game game,
                       Player sender,
                       Player recipient)
Creates a new DiplomaticTrade instance.

Parameters:
game - a Game value
sender - a Player value
recipient - a Player value

DiplomaticTrade

public DiplomaticTrade(Game game,
                       Player sender,
                       Player recipient,
                       java.util.List<TradeItem> items)
Creates a new DiplomaticTrade instance.

Parameters:
game - a Game value
sender - a Player value
recipient - a Player value

DiplomaticTrade

public DiplomaticTrade(Game game,
                       org.w3c.dom.Element element)
Creates a new DiplomaticTrade instance.

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

getGame

public Game getGame()
Gets the game object this DiplomaticTrade belongs to.

Returns:
The game.

isAccept

public final boolean isAccept()
Get the Accept value.

Returns:
a boolean value

setAccept

public final void setAccept(boolean newAccept)
Set the Accept value.

Parameters:
newAccept - The new Accept value.

getSender

public final Player getSender()
Get the Sender value.

Returns:
a Player value

setSender

public final void setSender(Player newSender)
Set the Sender value.

Parameters:
newSender - The new Sender value.

getRecipient

public final Player getRecipient()
Get the Recipient value.

Returns:
a Player value

setRecipient

public final void setRecipient(Player newRecipient)
Set the Recipient value.

Parameters:
newRecipient - The new Recipient value.

add

public void add(TradeItem newItem)
Add a TradeItem to the DiplomaticTrade.

Parameters:
newItem - a TradeItem value

remove

public void remove(TradeItem newItem)
Remove a TradeItem from the DiplomaticTrade.

Parameters:
newItem - a TradeItem value

remove

public void remove(int index)
Remove a TradeItem from the DiplomaticTrade.

Parameters:
index - the index of the TradeItem to remove

removeType

public void removeType(TradeItem someItem)
Removes all trade items of the same class as the given argument.

Parameters:
someItem - a TradeItem value

getStance

public Player.Stance getStance()
Returns the stance being offered, or null if none is being offered.

Returns:
an int value

getGoodsGivenBy

public java.util.List<Goods> getGoodsGivenBy(Player player)
Returns a list of goods given by Player

Returns:
a list of Goods offered by the player, empty if none given

getColoniesGivenBy

public java.util.List<Colony> getColoniesGivenBy(Player player)
Returns a list of colonies given by Player

Returns:
a list of Colony offered by the player, empty if none given

makeTrade

public java.util.List<FreeColGameObject> makeTrade()
Calls the makeTrade method of all TradeItems.

Returns:
A list of all objects traded.

getTradeItems

public java.util.List<TradeItem> getTradeItems()
Returns all TradeItems.

Returns:
a List of TradeItems

iterator

public java.util.Iterator<TradeItem> iterator()
Returns an iterator for all TradeItems.

Returns:
an iterator for all TradeItems.

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.

getXMLElementTagName

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

Returns:
"goods".