|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.freecol.common.model.FreeColObject
net.sf.freecol.common.model.FreeColGameObject
net.sf.freecol.common.model.GoodsContainer
public class GoodsContainer
Contains goods and can be used by a Location to make certain
tasks easier.
| Field Summary | |
|---|---|
static int |
CARGO_SIZE
|
private static java.util.logging.Logger |
logger
|
static java.lang.String |
OLD_STORED_GOODS_TAG
|
private java.util.Map<GoodsType,java.lang.Integer> |
oldStoredGoods
The previous list of Goods stored in this GoodsContainer. |
private Location |
parent
The owner of this GoodsContainer. |
static java.lang.String |
STORED_GOODS_TAG
|
private java.util.Map<GoodsType,java.lang.Integer> |
storedGoods
The list of Goods stored in this GoodsContainer. |
| Fields inherited from class net.sf.freecol.common.model.FreeColObject |
|---|
ARRAY_SIZE, ID_ATTRIBUTE, ID_ATTRIBUTE_TAG, PARTIAL_ATTRIBUTE |
| Constructor Summary | |
|---|---|
GoodsContainer(Game game,
Location parent)
Creates an empty GoodsContainer. |
|
GoodsContainer(Game game,
Location parent,
org.w3c.dom.Element e)
Initiates a new GoodsContainer from an Element. |
|
GoodsContainer(Game game,
Location parent,
javax.xml.stream.XMLStreamReader in)
Initiates a new GoodsContainer from an Element. |
|
| Method Summary | |
|---|---|
void |
addGoods(AbstractGoods g)
Adds a Goods to this containter. |
void |
addGoods(GoodsType type,
int amount)
Adds the given amount of the given type of goods. |
void |
cleanAndReport()
Removes goods exceeding limit and reports on goods exceeding levels. |
boolean |
contains(Goods g)
Checks if the specified Goods is in this container. |
java.util.List<Goods> |
getCompactGoods()
Gets an Iterator of every Goods in this
GoodsContainer. |
java.util.List<Goods> |
getFullGoods()
Gets an Iterator of every Goods in this
GoodsContainer. |
java.util.List<Goods> |
getGoods()
Returns an ArrayList containing all
Goods in this GoodsContainer. |
Goods |
getGoods(GoodsType goodsType)
|
int |
getGoodsCount()
Gets the number of goods-packages. |
int |
getGoodsCount(GoodsType type)
Returns the amount of one type of Goods in this container. |
java.util.Iterator<Goods> |
getGoodsIterator()
Gets an Iterator of every Goods in this
GoodsContainer. |
int |
getOldGoodsCount(GoodsType type)
Returns the amount of one type of Goods at the beginning of the turn. |
static java.lang.String |
getXMLElementTagName()
Gets the tag name of the root element representing this object. |
boolean |
hasReachedCapacity(int amount)
Checks if any storable type of goods has reached the given amount. |
protected void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
Initialize this object from an XML-representation of this object. |
void |
removeAbove(int newAmount)
Removes all goods above given amount, provided that the goods are storable and do not ignore warehouse limits. |
void |
removeAll()
Removes all goods. |
Goods |
removeGoods(AbstractGoods g)
Removes Goods from this containter. |
Goods |
removeGoods(GoodsType type)
|
Goods |
removeGoods(GoodsType type,
int amount)
Removes the given amount of the given type of goods. |
void |
saveState()
Prepares this GoodsContainer for a new turn. |
private void |
setAmount(GoodsType goodsType,
int newAmount)
|
java.lang.String |
toString()
Creates a String representation of this
GoodsContainer. |
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 |
|---|
addModelMessage, addModelMessage, addModelMessage, addToRemoveElement, dispose, equals, equals, getFreeColGameObject, getFreeColGameObject, getGame, getGameOptions, getIntegerID, hashCode, hasID, isDisposed, isUninitialized, readFromXML, readFromXMLPartialByClass, setFakeID, setGame, setId, toSavedXML, toXML, toXMLImpl, toXMLPartialByClass, updateFreeColGameObject, updateID |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final java.util.logging.Logger logger
public static final int CARGO_SIZE
public static final java.lang.String STORED_GOODS_TAG
public static final java.lang.String OLD_STORED_GOODS_TAG
private java.util.Map<GoodsType,java.lang.Integer> storedGoods
GoodsContainer.
private java.util.Map<GoodsType,java.lang.Integer> oldStoredGoods
GoodsContainer.
private final Location parent
GoodsContainer.
| Constructor Detail |
|---|
public GoodsContainer(Game game,
Location parent)
GoodsContainer.
game - The Game in which this GoodsContainer belong.parent - The Location this GoodsContainer will be containg goods for.
public GoodsContainer(Game game,
Location parent,
javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
GoodsContainer from an Element.
game - The Game in which this GoodsContainer
belong.parent - The object using this GoodsContainer
for storing it's goods.in - The input stream containing the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.
public GoodsContainer(Game game,
Location parent,
org.w3c.dom.Element e)
GoodsContainer from an Element.
game - The Game in which this GoodsContainer
belong.parent - The object using this GoodsContainer
for storing it's goods.e - An XML-element that will be used to initialize
this object.| Method Detail |
|---|
public void addGoods(AbstractGoods g)
Goods to this containter.
g - The Goods to add to this container.
public void addGoods(GoodsType type,
int amount)
type - The type of goods to add.amount - The type of amount to add.public Goods removeGoods(AbstractGoods g)
g - The Goods to remove from this container.public Goods removeGoods(GoodsType type)
public Goods removeGoods(GoodsType type,
int amount)
type - The type of goods to remove.amount - The type of amount to remove.
public void removeAbove(int newAmount)
newAmount - The treshold.
private void setAmount(GoodsType goodsType,
int newAmount)
public void removeAll()
public boolean hasReachedCapacity(int amount)
amount - The amount.
true if any type of goods,
except for Goods.FOOD, has reached
the given amount.public boolean contains(Goods g)
Goods is in this container.
g - The Goods to test the presence of.
public int getGoodsCount(GoodsType type)
type - The type of Goods being looked for in this container.
public int getOldGoodsCount(GoodsType type)
type - The type of Goods being looked for in this container.
public Goods getGoods(GoodsType goodsType)
public int getGoodsCount()
public java.util.Iterator<Goods> getGoodsIterator()
Iterator of every Goods in this
GoodsContainer. Each Goods have a maximum
amount of CARGO_SIZE.
Iterator.getCompactGoods()public java.util.List<Goods> getGoods()
ArrayList containing all
Goods in this GoodsContainer. Each
Goods has a maximum amount of CARGO_SIZE.
ArrayList.getGoodsIterator()public java.util.List<Goods> getCompactGoods()
Iterator of every Goods in this
GoodsContainer. There is only one Goods
for each type of goods.
Iterator.getGoodsIterator()public java.util.List<Goods> getFullGoods()
Iterator of every Goods in this
GoodsContainer. There is only one Goods
for each type of goods.
Iterator.getGoodsIterator()public void saveState()
GoodsContainer for a new turn.
public void cleanAndReport()
protected void toXMLImpl(javax.xml.stream.XMLStreamWriter out,
Player player,
boolean showAll,
boolean toSavedGame)
throws javax.xml.stream.XMLStreamException
Player will
be added to that representation if showAll is
set to false.
toXMLImpl in class FreeColGameObjectout - 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.
javax.xml.stream.XMLStreamException - if there are any problems writing
to the stream.
protected void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
readFromXMLImpl in class FreeColObjectin - The input stream with the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.public static java.lang.String getXMLElementTagName()
public java.lang.String toString()
String representation of this
GoodsContainer.
toString in class FreeColGameObjectString
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||