task2/solution04/src/org/apidesign/apifest08/currency/InvalidConversionException.java
changeset 29 f6073056b9fe
parent 17 37c9921c653e
child 35 8898c620fe96
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/task2/solution04/src/org/apidesign/apifest08/currency/InvalidConversionException.java	Wed Oct 01 10:43:05 2008 +0200
     1.3 @@ -0,0 +1,82 @@
     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 +     * Construct a new InvalidConversionException wit the specified message.
    1.36 +     * 
    1.37 +     * @param msg the message for getMessage.
    1.38 +     * @param bad the currency that is not valid.
    1.39 +     * @param a a valid currency.
    1.40 +     * @param b a valid currency.
    1.41 +     */
    1.42 +    public InvalidConversionException(final String    msg,
    1.43 +                                       final Currency bad,
    1.44 +                                       final Currency a,
    1.45 +                                       final Currency b)
    1.46 +    {
    1.47 +        super(msg);
    1.48 +
    1.49 +        badCurrency = bad;
    1.50 +        currencyA   = a;
    1.51 +        currencyB   = b;
    1.52 +    }
    1.53 +
    1.54 +    /**
    1.55 +     * Get the currency that is not valid.
    1.56 +     * 
    1.57 +     * @return the badCurrency
    1.58 +     */
    1.59 +    public Currency getBadCurrency()
    1.60 +    {
    1.61 +        return (badCurrency);
    1.62 +    }
    1.63 +
    1.64 +    /**
    1.65 +     * Get a currency that is valid.
    1.66 +     * 
    1.67 +     * @return the currencyA passed to the constructor.
    1.68 +     */
    1.69 +    public Currency getCurrencyA()
    1.70 +    {
    1.71 +        return (currencyA);
    1.72 +    }
    1.73 +
    1.74 +    /**
    1.75 +     * Get a currency that is valid.
    1.76 +     * 
    1.77 +     * @return the currencyB passed to the constructor.
    1.78 +     */
    1.79 +    public Currency getCurrencyB()
    1.80 +    {
    1.81 +        return (currencyB);
    1.82 +    }
    1.83 +
    1.84 +
    1.85 +}
    1.86 \ No newline at end of file