Package net.sf.freecol.common.model
Class LastSale
- java.lang.Object
-
- net.sf.freecol.common.model.FreeColObject
-
- net.sf.freecol.common.model.LastSale
-
- All Implemented Interfaces:
java.lang.Comparable<FreeColObject>
,ObjectWithId
public final class LastSale extends FreeColObject
This class contains the last sale a player has made, by Settlement and GoodsType.
-
-
Field Summary
Fields Modifier and Type Field Description private int
price
The price per unit returned from the sale.private static java.lang.String
PRICE_TAG
static java.lang.String
TAG
private Turn
when
When a sale was made.private static java.lang.String
WHEN_TAG
-
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE_TAG, DEFAULT_CLASS_INDEX, fcoComparator, ID_ATTRIBUTE_TAG, logger, PARTIAL_ATTRIBUTE_TAG, VALUE_TAG
-
-
Constructor Summary
Constructors Constructor Description LastSale()
Trivial constructor to allow creation with Game.newInstance.LastSale(java.lang.String id, Turn when, int price)
Make a new LastSale record.LastSale(FreeColXMLReader xr)
Create a new last sale by reading a stream.LastSale(Location where, GoodsType what, Turn when, int price)
Make a new LastSale record.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends FreeColObject>
booleancopyIn(T other)
Copy another FreeColObject into this one if it is compatible.int
getPrice()
Get the price from the sale.Turn
getWhen()
Get theTurn
when the sale was made.java.lang.String
getXMLTagName()
Get the serialization tag for 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
readAttributes(FreeColXMLReader xr)
Reads the attributes of this object from an XML stream.java.lang.String
toString()
protected void
writeAttributes(FreeColXMLWriter xw)
Write the attributes of this object to a stream.-
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addAbility, addFeatures, addModifier, addPropertyChangeListener, addPropertyChangeListener, apply, apply, applyModifiers, applyModifiers, arrayKey, compareIds, compareTo, containsAbilityKey, containsModifierKey, copy, copy, copy, copy, copyInCast, dumpObject, equals, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAbilities, getAbilities, getAbilities, getAbilities, getClassIndex, getDefenceModifiers, getDisplayObject, getFeatureContainer, getFreeColObjectClass, getFreeColObjectClassByName, getGame, getId, getIdNumber, getIdType, getIdTypeByName, getModifiers, getModifiers, getModifiers, getModifiers, getObjectClassIndex, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getSortedAbilities, getSortedModifiers, getSpecification, getSuffix, getSuffix, hasAbility, hasAbility, hasAbility, hashCode, hasListeners, hasModifier, hasModifier, hasModifier, idEquals, invokeMethod, logFreeColObjects, readChild, readChildren, readFromXML, readFromXMLPartial, removeAbilities, removeAbility, removeFeatures, removeModifier, removeModifiers, removePropertyChangeListener, removePropertyChangeListener, save, save, save, save, serialize, serialize, serialize, serialize, setGame, setId, setSpecification, toXML, toXML, toXMLPartial, toXMLPartial, writeChildren
-
-
-
-
Field Detail
-
TAG
public static final java.lang.String TAG
- See Also:
- Constant Field Values
-
when
private Turn when
When a sale was made.
-
price
private int price
The price per unit returned from the sale.
-
PRICE_TAG
private static final java.lang.String PRICE_TAG
- See Also:
- Constant Field Values
-
WHEN_TAG
private static final java.lang.String WHEN_TAG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LastSale
public LastSale()
Trivial constructor to allow creation with Game.newInstance.
-
LastSale
public LastSale(Location where, GoodsType what, Turn when, int price)
Make a new LastSale record.- Parameters:
where
- TheLocation
of the sale.what
- TheGoodsType
sold.when
- In whichTurn
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 object identifier.when
- In whichTurn
the sale occurred.price
- The per-unit price of the sale.
-
LastSale
public LastSale(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Create a new last sale by reading a stream.- Parameters:
xr
- TheFreeColXMLReader
to read from.- Throws:
javax.xml.stream.XMLStreamException
- if there is a problem reading the stream.
-
-
Method Detail
-
getWhen
public Turn getWhen()
Get theTurn
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
- TheLocation
of the sale.what
- TheGoodsType
sold.- Returns:
- A key string.
-
copyIn
public <T extends FreeColObject> boolean copyIn(T other)
Copy another FreeColObject into this one if it is compatible.- Overrides:
copyIn
in classFreeColObject
- Type Parameters:
T
- TheFreeColObject
subclass of the object to copy in.- Parameters:
other
- The other object.- Returns:
- True if the copy in is succesful.
-
writeAttributes
protected void writeAttributes(FreeColXMLWriter xw) throws javax.xml.stream.XMLStreamException
Write the attributes of this object to a stream. To be overridden if required by any object that has attributes and uses the toXML(FreeColXMLWriter, String) call.- Overrides:
writeAttributes
in classFreeColObject
- Parameters:
xw
- TheFreeColXMLWriter
to write to.- Throws:
javax.xml.stream.XMLStreamException
- if there are any problems writing to the stream.
-
readAttributes
public void readAttributes(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Reads the attributes of this object from an XML stream.- Overrides:
readAttributes
in classFreeColObject
- Parameters:
xr
- TheFreeColXMLReader
to read from.- Throws:
javax.xml.stream.XMLStreamException
- if there is a problem reading the stream.
-
getXMLTagName
public java.lang.String getXMLTagName()
Get the serialization tag for this object.- Specified by:
getXMLTagName
in classFreeColObject
- Returns:
- The tag.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classFreeColObject
-
-