task4/solution04/src/org/apidesign/apifest08/currency/InvalidConversionException.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Sat, 11 Oct 2008 23:38:46 +0200
changeset 61 58ec6da75f6f
parent 45 task3/solution04/src/org/apidesign/apifest08/currency/InvalidConversionException.java@251d0ed461fb
permissions -rw-r--r--
Copying structure for task4
     1 package org.apidesign.apifest08.currency;
     2 
     3       
     4 import java.util.Currency;
     5 
     6 
     7 /**
     8  * Thrown when a currency is invalid for a given Convertor.
     9  * 
    10  * @author D'Arcy Smith
    11  * @version 1.0
    12  */
    13 public class InvalidConversionException
    14     extends Exception
    15 {
    16     /**
    17      * The currency that was tried.
    18      */
    19     private final Currency badCurrency;
    20     
    21     /**
    22      * A currency that is valid for the Convertor.
    23      */
    24     private final Currency currencyA;
    25 
    26     /**
    27      * A currency that is valid for the Convertor.
    28      */
    29     private final Currency currencyB;
    30     
    31     
    32     /**
    33      * Construct a new InvalidConversionException with the specified message.
    34      * 
    35      * @param msg the message for getMessage.
    36      * @param bad the currency that is not valid.
    37      */
    38     public InvalidConversionException(final String   msg,
    39                                       final Currency bad)
    40     {
    41         this(msg, bad, null, null);
    42     }
    43 
    44     /**
    45      * Construct a new InvalidConversionException with the specified message.
    46      * 
    47      * @param msg the message for getMessage.
    48      * @param bad the currency that is not valid.
    49      * @param a a valid currency.
    50      * @param b a valid currency.
    51      */
    52     public InvalidConversionException(final String   msg,
    53                                       final Currency bad,
    54                                       final Currency a,
    55                                       final Currency b)
    56     {
    57         super(msg);
    58 
    59         badCurrency = bad;
    60         currencyA   = a;
    61         currencyB   = b;
    62     }
    63 
    64     /**
    65      * Get the currency that is not valid.
    66      * 
    67      * @return the badCurrency
    68      */
    69     public Currency getBadCurrency()
    70     {
    71         return (badCurrency);
    72     }
    73 
    74     /**
    75      * Get a currency that is valid.
    76      * 
    77      * @return the currencyA passed to the constructor.
    78      */
    79     public Currency getCurrencyA()
    80     {
    81         return (currencyA);
    82     }
    83 
    84     /**
    85      * Get a currency that is valid.
    86      * 
    87      * @return the currencyB passed to the constructor.
    88      */
    89     public Currency getCurrencyB()
    90     {
    91         return (currencyB);
    92     }
    93 
    94 
    95 }