package data.ooimpl;

import data.*;

/**
  * Pure Java implementation of the {@link CurrencyItem} interface.
  *
  * @author Steffen Zschaler
  * @version 2.0 19/08/1999
  * @since v2.0
  */
public class CurrencyItemImpl extends CatalogItemImpl implements CurrencyItem {

  /**
    * Create a new CurrencyItemImpl.
    *
    * @param sName the name of the currency item.
    * @param nValue the value of the item, expressed in the smallest unit of the associated currency.
    */
  public CurrencyItemImpl (String sName, int nValue) {
    super (sName, new IntegerValue (nValue));
  }

  /**
    * @override Never
    */
  public CatalogItemImpl getShallowClone() {
    return new CurrencyItemImpl (getName(), ((NumberValue) getValue()).getValue().intValue());
  }

  /**
    * @override Never
    */
  public String toString() {
    return getName() + ": " + ((getCatalog() != null)?
                               (((Currency) getCatalog()).toString ((NumberValue) getValue())):
                               (getValue().toString()));
  }
}