net.sf.freecol.common.model
Class MarketData

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

public class MarketData
extends FreeColGameObject

Objects of this class hold the market data for a particular type of good.


Field Summary
private  int amountInMarket
          Amount of this goods in the market.
private  int arrears
          Arrears owed to the crown.
private  int costToBuy
          Purchase price.
private  GoodsType goodsType
          What type of goods is this.
private  int incomeAfterTaxes
          Total income after taxes.
private  int incomeBeforeTaxes
          Total income before taxes.
private  int initialPrice
          The initial price.
private static java.util.logging.Logger logger
           
static int MAXIMUM_PRICE
           
static int MINIMUM_PRICE
          Bounds on price movements.
private  int oldPrice
          Place to save to old price so as to be able to tell when a price change message should be generated.
private  int paidForSale
          Sale price.
private  int sales
          Total sales.
private  boolean traded
          Has this good been traded?
 
Fields inherited from class net.sf.freecol.common.model.FreeColGameObject
UNITS_TAG_NAME
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE, ID_ATTRIBUTE, ID_ATTRIBUTE_TAG, INFINITY, NO_ID, PARTIAL_ATTRIBUTE, UNDEFINED, VALUE_TAG
 
Constructor Summary
MarketData(Game game, GoodsType goodsType)
          Creates a new MarketData instance.
MarketData(Game game, java.lang.String id)
          Instantiates a new MarketData with the given ID.
MarketData(Game game, javax.xml.stream.XMLStreamReader in)
          Instantiate a new MarketData from an XML representation.
 
Method Summary
 int getAmountInMarket()
          Get the AmountInMarket value.
 int getArrears()
          Get the Arrears value.
 int getCostToBuy()
          Get the CostToBuy value.
 GoodsType getGoodsType()
          Get the type of goods of this MarketData.
 int getIncomeAfterTaxes()
          Get the IncomeAfterTaxes value.
 int getIncomeBeforeTaxes()
          Get the IncomeBeforeTaxes value.
 int getInitialPrice()
          Get the InitialPrice value.
 int getOldPrice()
          Get the old price in this MarketData.
 int getPaidForSale()
          Get the PaidForSale value.
 int getSales()
          Get the Sales value.
 boolean getTraded()
          Has there been trading in this MarketData?
static java.lang.String getXMLElementTagName()
          Returns the tag name of the root element representing this object.
 void price()
          Adjust the prices.
protected  void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
          Initialize this object from an XML-representation of this object.
 void setAmountInMarket(int newAmountInMarket)
          Set the AmountInMarket value.
 void setArrears(int newArrears)
          Set the Arrears value.
 void setCostToBuy(int newCostToBuy)
          Set the CostToBuy value.
 void setIncomeAfterTaxes(int newIncomeAfterTaxes)
          Set the IncomeAfterTaxes value.
 void setIncomeBeforeTaxes(int newIncomeBeforeTaxes)
          Set the IncomeBeforeTaxes value.
 void setInitialPrice(int newInitialPrice)
          Set the InitialPrice value.
 void setOldPrice(int oldPrice)
          Set the old price in this MarketData.
 void setPaidForSale(int newPaidForSale)
          Set the PaidForSale value.
 void setSales(int newSales)
          Set the Sales value.
 void setTraded(boolean traded)
          Set the trade status of this MarketData.
protected  void toXMLImpl(javax.xml.stream.XMLStreamWriter out, Player player, boolean showAll, boolean toSavedGame)
          This method writes an XML-representation of this object to the given stream.
 
Methods inherited from class net.sf.freecol.common.model.FreeColGameObject
dispose, disposeList, equals, equals, fundamentalDispose, getFreeColGameObject, getFreeColGameObject, getGame, getIntegerID, getSpecification, hashCode, isDisposed, isUninitialized, newLocation, readFromXML, readFromXMLPartialByClass, setDefaultId, setGame, setId, toString, toXML, toXMLImpl, toXMLPartialByClass, updateFreeColGameObject
 
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, hasAbility, hasAttribute, hasListeners, readAttributes, readAttributes, readChild, readChild, readChildren, readChildren, readFromArrayElement, readFromArrayElement, readFromListElement, readFromXMLElement, readFromXMLImpl, readFromXMLPartialImpl, removePropertyChangeListener, removePropertyChangeListener, save, save, setSpecification, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, toXMLPartialImpl, writeAttribute, writeAttributes, writeChildren
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

private static final java.util.logging.Logger logger

MINIMUM_PRICE

public static final int MINIMUM_PRICE
Bounds on price movements.

See Also:
Constant Field Values

MAXIMUM_PRICE

public static final int MAXIMUM_PRICE
See Also:
Constant Field Values

goodsType

private GoodsType goodsType
What type of goods is this.


costToBuy

private int costToBuy
Purchase price.


paidForSale

private int paidForSale
Sale price.


amountInMarket

private int amountInMarket
Amount of this goods in the market.


initialPrice

private int initialPrice
The initial price.


arrears

private int arrears
Arrears owed to the crown.


sales

private int sales
Total sales.


incomeBeforeTaxes

private int incomeBeforeTaxes
Total income before taxes.


incomeAfterTaxes

private int incomeAfterTaxes
Total income after taxes.


oldPrice

private int oldPrice
Place to save to old price so as to be able to tell when a price change message should be generated. Not necessary to serialize.


traded

private boolean traded
Has this good been traded?

Constructor Detail

MarketData

public MarketData(Game game,
                  GoodsType goodsType)
Creates a new MarketData instance.

Parameters:
goodsType - a GoodsType value

MarketData

public MarketData(Game game,
                  javax.xml.stream.XMLStreamReader in)
           throws javax.xml.stream.XMLStreamException
Instantiate a new MarketData from an XML representation.

Parameters:
game - The Game this object belongs to.
in - The input stream containing the XML.
Throws:
javax.xml.stream.XMLStreamException - if an error occured during parsing.

MarketData

public MarketData(Game game,
                  java.lang.String id)
Instantiates a new MarketData with the given ID. The object should later be initialized by calling either FreeColGameObject.readFromXML(XMLStreamReader) or FreeColObject.readFromXMLElement(Element).

Parameters:
game - The Game in which this object belong.
id - The unique identifier for this object.
Method Detail

price

public void price()
Adjust the prices. Sets the costToBuy and paidForSale fields from the amount in the market, initial price and goods-type specific information.


getGoodsType

public final GoodsType getGoodsType()
Get the type of goods of this MarketData.

Returns:
The goods type for this data.

getCostToBuy

public final int getCostToBuy()
Get the CostToBuy value.

Returns:
an int value

setCostToBuy

public final void setCostToBuy(int newCostToBuy)
Set the CostToBuy value.

Parameters:
newCostToBuy - The new CostToBuy value.

getPaidForSale

public final int getPaidForSale()
Get the PaidForSale value.

Returns:
an int value

setPaidForSale

public final void setPaidForSale(int newPaidForSale)
Set the PaidForSale value.

Parameters:
newPaidForSale - The new PaidForSale value.

getAmountInMarket

public final int getAmountInMarket()
Get the AmountInMarket value.

Returns:
an int value

setAmountInMarket

public final void setAmountInMarket(int newAmountInMarket)
Set the AmountInMarket value.

Parameters:
newAmountInMarket - The new AmountInMarket value.

getInitialPrice

public final int getInitialPrice()
Get the InitialPrice value.

Returns:
an int value

setInitialPrice

public final void setInitialPrice(int newInitialPrice)
Set the InitialPrice value.

Parameters:
newInitialPrice - The new InitialPrice value.

getArrears

public final int getArrears()
Get the Arrears value.

Returns:
an int value

setArrears

public final void setArrears(int newArrears)
Set the Arrears value.

Parameters:
newArrears - The new Arrears value.

getSales

public final int getSales()
Get the Sales value.

Returns:
an int value

setSales

public final void setSales(int newSales)
Set the Sales value.

Parameters:
newSales - The new Sales value.

getIncomeBeforeTaxes

public final int getIncomeBeforeTaxes()
Get the IncomeBeforeTaxes value.

Returns:
an int value

setIncomeBeforeTaxes

public final void setIncomeBeforeTaxes(int newIncomeBeforeTaxes)
Set the IncomeBeforeTaxes value.

Parameters:
newIncomeBeforeTaxes - The new IncomeBeforeTaxes value.

getIncomeAfterTaxes

public final int getIncomeAfterTaxes()
Get the IncomeAfterTaxes value.

Returns:
an int value

setIncomeAfterTaxes

public final void setIncomeAfterTaxes(int newIncomeAfterTaxes)
Set the IncomeAfterTaxes value.

Parameters:
newIncomeAfterTaxes - The new IncomeAfterTaxes value.

getOldPrice

public final int getOldPrice()
Get the old price in this MarketData.

Returns:
The old price.

setOldPrice

public void setOldPrice(int oldPrice)
Set the old price in this MarketData.

Parameters:
oldPrice - A `new' old price.

getTraded

public final boolean getTraded()
Has there been trading in this MarketData?

Returns:
Whether trading has occurred.

setTraded

public void setTraded(boolean traded)
Set the trade status of this MarketData.

Parameters:
traded - The trade status to set.

toXMLImpl

protected void toXMLImpl(javax.xml.stream.XMLStreamWriter out,
                         Player player,
                         boolean showAll,
                         boolean toSavedGame)
                  throws javax.xml.stream.XMLStreamException
This method writes an XML-representation of this object to the given stream. Only attributes visible to the given Player will be added to that representation if showAll is set to false.

Specified by:
toXMLImpl in class FreeColGameObject
Parameters:
out - The target stream.
player - The Player this XML-representation should be made for, or null if showAll == true.
showAll - Only attributes visible to player will be added to the representation if showAll is set to false.
toSavedGame - If true then information that is only needed when saving a game is added.
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.

getXMLElementTagName

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

Returns:
"marketData"