task4/solution04/src/org/apidesign/apifest08/currency/InvalidConversionException.java
changeset 61 58ec6da75f6f
parent 45 251d0ed461fb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/task4/solution04/src/org/apidesign/apifest08/currency/InvalidConversionException.java	Sat Oct 11 23:38:46 2008 +0200
     1.3 @@ -0,0 +1,95 @@
     1.4 +package org.apidesign.apifest08.currency;
     1.5 +
     1.6 +      
     1.7 +import java.util.Currency;
     1.8 +
     1.9 +
    1.10 +/**
    1.11 + * Thrown when a currency is invalid for a given Convertor.
    1.12 + * 
    1.13 + * @author D'Arcy Smith
    1.14 + * @version 1.0
    1.15 + */
    1.16 +public class InvalidConversionException
    1.17 +    extends Exception
    1.18 +{
    1.19 +    /**
    1.20 +     * The currency that was tried.
    1.21 +     */
    1.22 +    private final Currency badCurrency;
    1.23 +    
    1.24 +    /**
    1.25 +     * A currency that is valid for the Convertor.
    1.26 +     */
    1.27 +    private final Currency currencyA;
    1.28 +
    1.29 +    /**
    1.30 +     * A currency that is valid for the Convertor.
    1.31 +     */
    1.32 +    private final Currency currencyB;
    1.33 +    
    1.34 +    
    1.35 +    /**
    1.36 +     * Construct a new InvalidConversionException with the specified message.
    1.37 +     * 
    1.38 +     * @param msg the message for getMessage.
    1.39 +     * @param bad the currency that is not valid.
    1.40 +     */
    1.41 +    public InvalidConversionException(final String   msg,
    1.42 +                                      final Currency bad)
    1.43 +    {
    1.44 +        this(msg, bad, null, null);
    1.45 +    }
    1.46 +
    1.47 +    /**
    1.48 +     * Construct a new InvalidConversionException with the specified message.
    1.49 +     * 
    1.50 +     * @param msg the message for getMessage.
    1.51 +     * @param bad the currency that is not valid.
    1.52 +     * @param a a valid currency.
    1.53 +     * @param b a valid currency.
    1.54 +     */
    1.55 +    public InvalidConversionException(final String   msg,
    1.56 +                                      final Currency bad,
    1.57 +                                      final Currency a,
    1.58 +                                      final Currency b)
    1.59 +    {
    1.60 +        super(msg);
    1.61 +
    1.62 +        badCurrency = bad;
    1.63 +        currencyA   = a;
    1.64 +        currencyB   = b;
    1.65 +    }
    1.66 +
    1.67 +    /**
    1.68 +     * Get the currency that is not valid.
    1.69 +     * 
    1.70 +     * @return the badCurrency
    1.71 +     */
    1.72 +    public Currency getBadCurrency()
    1.73 +    {
    1.74 +        return (badCurrency);
    1.75 +    }
    1.76 +
    1.77 +    /**
    1.78 +     * Get a currency that is valid.
    1.79 +     * 
    1.80 +     * @return the currencyA passed to the constructor.
    1.81 +     */
    1.82 +    public Currency getCurrencyA()
    1.83 +    {
    1.84 +        return (currencyA);
    1.85 +    }
    1.86 +
    1.87 +    /**
    1.88 +     * Get a currency that is valid.
    1.89 +     * 
    1.90 +     * @return the currencyB passed to the constructor.
    1.91 +     */
    1.92 +    public Currency getCurrencyB()
    1.93 +    {
    1.94 +        return (currencyB);
    1.95 +    }
    1.96 +
    1.97 +
    1.98 +}
    1.99 \ No newline at end of file