/** {@inheritDoc} */ protected void readChild(XMLStreamReader in) throws XMLStreamException { if (GoodsContainer.getXMLElementTagName().equals(in.getLocalName())) { goodsContainer = getGame() .getFreeColGameObject(in.getAttributeValue(null, ID_ATTRIBUTE), GoodsContainer.class); if (goodsContainer == null) { goodsContainer = new GoodsContainer(getGame(), this, in); } else { goodsContainer.readFromXML(in); } } else { super.readChild(in); } }
/** * Checks if this <code>Location</code> contains the specified <code>Locatable</code>. * * @param locatable The <code>Locatable</code> to test the presence of. * @return * <ul> * <li><i>true</i> if the specified <code>Locatable</code> is on this <code>Location</code> * and * <li><i>false</i> otherwise. * </ul> */ public boolean contains(Locatable locatable) { if (locatable instanceof Goods) { return goodsContainer.contains((Goods) locatable); } else { return super.contains(locatable); } }
/** {@inheritDoc} */ protected void writeChildren( XMLStreamWriter out, Player player, boolean showAll, boolean toSavedGame) throws XMLStreamException { super.writeChildren(out, player, showAll, toSavedGame); if (goodsContainer != null) { goodsContainer.toXML(out, player, showAll, toSavedGame); } }
/** * Removes all references to this object. * * @return A list of disposed objects. */ public List<FreeColGameObject> disposeList() { List<FreeColGameObject> objects = new ArrayList<FreeColGameObject>(); if (goodsContainer != null) { objects.addAll(goodsContainer.disposeList()); goodsContainer = null; } objects.addAll(super.disposeList()); return objects; }
/** * Gets the amount of one type of Goods at this Settlement. * * @param type The type of goods to look for. * @return The amount of this type of Goods at this Location. */ public int getGoodsCount(GoodsType type) { return goodsContainer.getGoodsCount(type); }
/** * Describe <code>addGoods</code> method here. * * @param type a <code>GoodsType</code> value * @param amount an <code>int</code> value */ public boolean addGoods(GoodsType type, int amount) { return goodsContainer.addGoods(type, amount); }
/** * Removes all Goods of the given type from the Settlement. * * @param type a <code>GoodsType</code> value */ public Goods removeGoods(GoodsType type) { return goodsContainer.removeGoods(type); }
/** * Removes the given Goods from the Settlement. * * @param goods a <code>Goods</code> value */ public Goods removeGoods(AbstractGoods goods) { return goodsContainer.removeGoods(goods); }
/** * Removes a specified amount of a type of Goods from this Settlement. * * @param type The type of Goods to remove from this settlement. * @param amount The amount of Goods to remove from this settlement. */ public Goods removeGoods(GoodsType type, int amount) { return goodsContainer.removeGoods(type, amount); }
/** * Gets an <code>List</code> with every <code>Goods</code> in this <code>Colony</code>. There is * only one <code>Goods</code> for each type of goods. * * @return The <code>Iterator</code>. */ public List<Goods> getCompactGoods() { return goodsContainer.getCompactGoods(); }
/** * Gets an <code>Iterator</code> of every <code>Goods</code> in this <code>GoodsContainer</code>. * Each <code>Goods</code> have a maximum amount of GoodsContainer.CARGO_SIZE. * * @return The <code>Iterator</code>. */ public Iterator<Goods> getGoodsIterator() { return goodsContainer.getGoodsIterator(); }