net.sf.freecol.common.model
Class LastSale

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

public final class LastSale
extends FreeColObject

This class contains the last sale a player has made, by Settlement and GoodsType.


Field Summary
private  int price
           
private  Turn when
           
 
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
LastSale()
          Empty constructor for Player.
LastSale(Location where, GoodsType what, Turn when, int price)
          Make a new LastSale record.
LastSale(java.lang.String id, Turn when, int price)
          Make a new LastSale record.
 
Method Summary
 int getPrice()
          Get the price from the sale.
 Turn getWhen()
          Get the Turn when the sale was made.
static java.lang.String getXMLElementTagName()
          Returns the tag name of the root element representing this object.
static java.lang.String makeKey(Location where, GoodsType what)
          Make a String to be used as a key for looking up sales.
 void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
          Initialize this object from an XML-representation of this object.
 java.lang.String toString()
          Debug helper.
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 children 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, 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, writeChildren
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

when

private Turn when

price

private int price
Constructor Detail

LastSale

public LastSale()
Empty constructor for Player.


LastSale

public LastSale(Location where,
                GoodsType what,
                Turn when,
                int price)
Make a new LastSale record.

Parameters:
where - The Location of the sale.
what - The GoodsType sold.
when - In which Turn the sale occurred.
price - The per-unit price of the sale.

LastSale

public LastSale(java.lang.String id,
                Turn when,
                int price)
Make a new LastSale record.

Parameters:
id - The identifier (encoding Settlement and GoodsType).
when - In which Turn the sale occurred.
price - The per-unit price of the sale.
Method Detail

getWhen

public Turn getWhen()
Get the Turn when the sale was made.

Returns:
The Turn when the sale was made.

getPrice

public int getPrice()
Get the price from the sale.

Returns:
The price from the sale.

makeKey

public static java.lang.String makeKey(Location where,
                                       GoodsType what)
Make a String to be used as a key for looking up sales.

Parameters:
where - The Location of the sale.
what - The GoodsType sold.
Returns:
A key string.

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 with the stream.

writeAttributes

protected void writeAttributes(javax.xml.stream.XMLStreamWriter out)
                        throws javax.xml.stream.XMLStreamException
Write the children 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

public 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 there are any problems with the stream.

toString

public java.lang.String toString()
Debug helper.

Overrides:
toString in class java.lang.Object

getXMLElementTagName

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

Returns:
"lastSale"