001 package data; 002 003 import java.text.ParseException; 004 005 /** 006 * A special {@link Catalog} that represents a currency. 007 * 008 * <p>Currencies contain {@link CurrencyItem CurrencyItems} and work together with {@link MoneyBag MoneyBags}. 009 * They are capable of parsing user input that is formatted according to the currency format for the specific 010 * currency they represent. It is recommended that you use a Locale specific algorithm for implementation, but 011 * this cannot be enforced.</p> 012 * 013 * @author Steffen Zschaler 014 * @version 2.0 18/08/1999 015 * @since v0.5 016 */ 017 public interface Currency<T extends CurrencyItem> extends Catalog<T> { 018 019 /** 020 * Convert the given value into a {@link String} representation according to the currency format of the 021 * specific currency. <code>nv</code> must be given in the smallest unit of the currency, i.e. if you want 022 * to specify 5,05 DM <code>nv</code> should be 505. 023 * 024 * @override Always 025 * 026 * @param nv the value to be converted 027 */ 028 public String toString(NumberValue nv); 029 030 /** 031 * Try to interpret the given {@link String} according to the currency format of the specific currency. 032 * 033 * @override Always 034 * 035 * @param s the text to be parsed 036 * 037 * @return the interpreted value in the smallest unit of the currency. 038 * 039 * @exception ParseException if the input could not be parsed. 040 */ 041 public NumberValue parse(String s) throws ParseException; 042 }