package data;

import java.text.ParseException;

/**
  * A special {@link Catalog} that represents a currency.
  *
  * <p>Currencies contain {@link CurrencyItem CurrencyItems} and work together with {@link MoneyBag MoneyBags}.
  * They are capable of parsing user input that is formatted according to the currency format for the specific
  * currency they represent. It is recommended that you use a Locale specific algorithm for implementation, but
  * this cannot be enforced.</p>
  *
  * @author Steffen Zschaler
  * @version 2.0 18/08/1999
  * @since v0.5
  */
public interface Currency extends Catalog {

  /**
    * Convert the given value into a {@link String} representation according to the currency format of the
    * specific currency. <code>nv</code> must be given in the smallest unit of the currency, i.e. if you want
    * to specify 5,05 DM <code>nv</code> should be 505.
    *
    * @override Always
    *
    * @param nv the value to be converted
    */
  public String toString (NumberValue nv);

  /**
    * Try to interpret the given {@link String} according to the currency format of the specific currency.
    *
    * @override Always
    *
    * @param s the text to be parsed
    *
    * @return the interpreted value in the smallest unit of the currency.
    *
    * @exception ParseException if the input could not be parsed.
    */
  public NumberValue parse (String s)
    throws ParseException;
}