net.sf.freecol.common.model
Class GoodsTradeItem

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

public class GoodsTradeItem
extends TradeItem


Field Summary
private  Goods goods
          The goods to change hands.
private  Settlement settlement
          The settlement where the trade is to take place.
 
Fields inherited from class net.sf.freecol.common.model.TradeItem
game
 
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
GoodsTradeItem(Game game, Player source, Player destination, Goods goods, Settlement settlement)
          Creates a new GoodsTradeItem instance.
GoodsTradeItem(Game game, javax.xml.stream.XMLStreamReader in)
          Creates a new GoodsTradeItem instance.
 
Method Summary
 Goods getGoods()
          Get the goods to trade.
 Settlement getSettlement()
          Get the Settlement value.
static java.lang.String getXMLElementTagName()
          Gets the tag name of the root element representing this object.
 boolean isUnique()
          Returns whether this TradeItem must be unique.
 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 setGoods(Goods goods)
          Set the goods to trade.
 void setSettlement(Settlement newSettlement)
          Set the Settlement value.
protected  void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
          This method writes an XML-representation of this object to the given stream.
protected  void writeAttributes(javax.xml.stream.XMLStreamWriter out)
          Write the attributes of this object to a stream.
protected  void writeChildren(javax.xml.stream.XMLStreamWriter out)
          Write the children of this object to a stream.
 
Methods inherited from class net.sf.freecol.common.model.TradeItem
getColony, getDestination, getGold, getSource, getStance, getUnit, setColony, setDestination, setGold, setSource, setStance, setUnit
 
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, 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, toXMLPartialImpl, writeAttribute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

goods

private Goods goods
The goods to change hands.


settlement

private Settlement settlement
The settlement where the trade is to take place.

Constructor Detail

GoodsTradeItem

public GoodsTradeItem(Game game,
                      Player source,
                      Player destination,
                      Goods goods,
                      Settlement settlement)
Creates a new GoodsTradeItem instance.

Parameters:
game - a Game value
source - a Player value
destination - a Player value
goods - a Goods value
settlement - a Settlement value

GoodsTradeItem

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

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

getSettlement

public final Settlement getSettlement()
Get the Settlement value.

Returns:
a Settlement value

setSettlement

public final void setSettlement(Settlement newSettlement)
Set the Settlement value.

Parameters:
newSettlement - The new Settlement value.

isValid

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

Specified by:
isValid in class TradeItem
Returns:
a boolean value

isUnique

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

Specified by:
isUnique in class TradeItem
Returns:
a boolean value

getGoods

public Goods getGoods()
Get the goods to trade.

Overrides:
getGoods in class TradeItem
Returns:
The goods to trade.

setGoods

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

Overrides:
setGoods in class TradeItem
Parameters:
goods - The new Goods to trade.

toXMLImpl

protected 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.

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

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 TradeItem
Parameters:
out - The target stream.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

writeChildren

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

Overrides:
writeChildren 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 TradeItem
Parameters:
in - The input stream with the XML.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.

getXMLElementTagName

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

Returns:
"goodsTradeItem".