package data.ooimpl; import data.*; /** * Pure Java implementation of the {@link MoneyBag} interface. * * @author Steffen Zschaler * @version 2.0 19/08/1999 * @since v2.0 */ public class MoneyBagImpl extends CountingStockImpl implements MoneyBag { /** * Create a new MoneyBagImpl. * * @param sName the name of the MoneyBag. * @param ci the Currency associated to the MoneyBag. */ public MoneyBagImpl (String sName, CurrencyImpl ci) { super (sName, ci); } /** * Return a String representation of the MoneyBag. * * <p>In addition to the representation created by the super class this will calculate the total amount of * this MoneyBag and append this in formatted form to the end of the representation.</p> * * @override Sometimes */ public String toString() { synchronized (getItemsLock()) { String sReturn = super.toString(); try { sReturn += ((getCatalog (null) != null)? (" Total: " + ((Currency) getCatalog (null)).toString ((NumberValue) sumStock (null, new CatalogItemValue(), new IntegerValue (0)))): ("")); } catch (DataBasketConflictException dbce) { // Catalog not accessible, do not compute total... } return sReturn; } } }