package com.beaglebuddy.id3.enums;

import com.beaglebuddy.id3.enums.v23.Encoding;                    // imported to obtain an ISO 8859 character set encoding



/**
 * <table class="logos_width">
 *    <tbody>
 *       <tr>
 *          <td                               ><img src="../../../../resources/id3v2.gif"                     width="56"  height="54"  alt="ID3 logo"        /></td>
 *          <td class="logos_horz_align_right"><img src="../../../../resources/beaglebuddy_software_logo.gif" width="340" height="110" alt="Beaglebuddy logo"/></td>
 *       </tr>
 *    </tbody>
 * </table>
 * <a href="http://www.iso.org/iso/home/standards/currency_codes.htm">ISO-4217</a> currency codes and names.
 */
public enum Currency
{                                                                   /** United Arab Emirates Dirham                              */
   AED("United Arab Emirates Dirham"                             ), /** Afghanistan Afghani                                      */
   AFN("Afghanistan Afghani"                                     ), /** Albania Lek                                              */
   ALL("Albania Lek"                                             ), /** Armenia Dram                                             */
   AMD("Armenia Dram"                                            ), /** Netherlands Antilles Guilder                             */
   ANG("Netherlands Antilles Guilder"                            ), /** Angola Kwanza                                            */
   AOA("Angola Kwanza"                                           ), /** Argentina Peso                                           */
   ARS("Argentina Peso"                                          ), /** Australia Dollar                                         */
   AUD("Australia Dollar"                                        ), /** Aruba Guilder                                            */
   AWG("Aruba Guilder"                                           ), /** Azerbaijan New Manat                                     */
   AZN("Azerbaijan New Manat"                                    ), /** Bosnia and Herzegovina Convertible Marka                 */
   BAM("Bosnia and Herzegovina Convertible Marka"                ), /** Barbados Dollar                                          */
   BBD("Barbados Dollar"                                         ), /** Bangladesh Taka                                          */
   BDT("Bangladesh Taka"                                         ), /** Bulgaria Lev                                             */
   BGN("Bulgaria Lev"                                            ), /** Bahrain Dinar                                            */
   BHD("Bahrain Dinar"                                           ), /** Burundi Franc                                            */
   BIF("Burundi Franc"                                           ), /** Bermuda Dollar                                           */
   BMD("Bermuda Dollar"                                          ), /** Brunei Darussalam Dollar                                 */
   BND("Brunei Darussalam Dollar"                                ), /** Bolivia Boliviano                                        */
   BOB("Bolivia Boliviano"                                       ), /** Brazil Real                                              */
   BRL("Brazil Real"                                             ), /** Bahamas Dollar                                           */
   BSD("Bahamas Dollar"                                          ), /** Bhutan Ngultrum                                          */
   BTN("Bhutan Ngultrum"                                         ), /** Botswana Pula                                            */
   BWP("Botswana Pula"                                           ), /** Belarus Ruble                                            */
   BYR("Belarus Ruble"                                           ), /** Belize Dollar                                            */
   BZD("Belize Dollar"                                           ), /** Canada Dollar                                            */
   CAD("Canada Dollar"                                           ), /** Congo/Kinshasa Franc                                     */
   CDF("Congo/Kinshasa Franc"                                    ), /** Switzerland Franc                                        */
   CHF("Switzerland Franc"                                       ), /** Chile Peso                                               */
   CLP("Chile Peso"                                              ), /** China Yuan Renminbi                                      */
   CNY("China Yuan Renminbi"                                     ), /** Colombia Peso                                            */
   COP("Colombia Peso"                                           ), /** Costa Rica Colon                                         */
   CRC("Costa Rica Colon"                                        ), /** Cuba Convertible Peso                                    */
   CUC("Cuba Convertible Peso"                                   ), /** Cuba Peso                                                */
   CUP("Cuba Peso"                                               ), /** Cape Verde Escudo                                        */
   CVE("Cape Verde Escudo"                                       ), /** Czech Republic Koruna                                    */
   CZK("Czech Republic Koruna"                                   ), /** Djibouti Franc                                           */
   DJF("Djibouti Franc"                                          ), /** Denmark Krone                                            */
   DKK("Denmark Krone"                                           ), /** Dominican Republic Peso                                  */
   DOP("Dominican Republic Peso"                                 ), /** Algeria Dinar                                            */
   DZD("Algeria Dinar"                                           ), /** Egypt Pound                                              */
   EGP("Egypt Pound"                                             ), /** Eritrea Nakfa                                            */
   ERN("Eritrea Nakfa"                                           ), /** Ethiopia Birr                                            */
   ETB("Ethiopia Birr"                                           ), /** Euro Member Countries                                    */
   EUR("Euro Member Countries"                                   ), /** Fiji Dollar                                              */
   FJD("Fiji Dollar"                                             ), /** Falkland Islands (Malvinas) Pound                        */
   FKP("Falkland Islands (Malvinas) Pound"                       ), /** United Kingdom Pound                                     */
   GBP("United Kingdom Pound"                                    ), /** Georgia Lari                                             */
   GEL("Georgia Lari"                                            ), /** Guernsey Pound                                           */
   GGP("Guernsey Pound"                                          ), /** Ghana Cedi                                               */
   GHS("Ghana Cedi"                                              ), /** Gibraltar Pound                                          */
   GIP("Gibraltar Pound"                                         ), /** Gambia Dalasi                                            */
   GMD("Gambia Dalasi"                                           ), /** Guinea Franc                                             */
   GNF("Guinea Franc"                                            ), /** Guatemala Quetzal                                        */
   GTQ("Guatemala Quetzal"                                       ), /** Guyana Dollar                                            */
   GYD("Guyana Dollar"                                           ), /** Hong Kong Dollar                                         */
   HKD("Hong Kong Dollar"                                        ), /** Honduras Lempira                                         */
   HNL("Honduras Lempira"                                        ), /** Croatia Kuna                                             */
   HRK("Croatia Kuna"                                            ), /** Haiti Gourde                                             */
   HTG("Haiti Gourde"                                            ), /** Hungary Forint                                           */
   HUF("Hungary Forint"                                          ), /** Indonesia Rupiah                                         */
   IDR("Indonesia Rupiah"                                        ), /** Israel Shekel                                            */
   ILS("Israel Shekel"                                           ), /** Isle of Man Pound                                        */
   IMP("Isle of Man Pound"                                       ), /** India Rupee                                              */
   INR("India Rupee"                                             ), /** Iraq Dinar                                               */
   IQD("Iraq Dinar"                                              ), /** Iran Rial                                                */
   IRR("Iran Rial"                                               ), /** Iceland Krona                                            */
   ISK("Iceland Krona"                                           ), /** Jersey Pound                                             */
   JEP("Jersey Pound"                                            ), /** Jamaica Dollar                                           */
   JMD("Jamaica Dollar"                                          ), /** Jordan Dinar                                             */
   JOD("Jordan Dinar"                                            ), /** Japan Yen                                                */
   JPY("Japan Yen"                                               ), /** Kenya Shilling                                           */
   KES("Kenya Shilling"                                          ), /** Kyrgyzstan Som                                           */
   KGS("Kyrgyzstan Som"                                          ), /** Cambodia Riel                                            */
   KHR("Cambodia Riel"                                           ), /** Comoros Franc                                            */
   KMF("Comoros Franc"                                           ), /** Korea (North) Won                                        */
   KPW("Korea (North) Won"                                       ), /** Korea (South) Won                                        */
   KRW("Korea (South) Won"                                       ), /** Kuwait Dinar                                             */
   KWD("Kuwait Dinar"                                            ), /** Cayman Islands Dollar                                    */
   KYD("Cayman Islands Dollar"                                   ), /** Kazakhstan Tenge                                         */
   KZT("Kazakhstan Tenge"                                        ), /** Laos Kip                                                 */
   LAK("Laos Kip"                                                ), /** Lebanon Pound                                            */
   LBP("Lebanon Pound"                                           ), /** Sri Lanka Rupee                                          */
   LKR("Sri Lanka Rupee"                                         ), /** Liberia Dollar                                           */
   LRD("Liberia Dollar"                                          ), /** Lesotho Loti                                             */
   LSL("Lesotho Loti"                                            ), /** Lithuania Litas                                          */
   LTL("Lithuania Litas"                                         ), /** Latvia Lat                                               */
   LVL("Latvia Lat"                                              ), /** Libya Dinar                                              */
   LYD("Libya Dinar"                                             ), /** Morocco Dirham                                           */
   MAD("Morocco Dirham"                                          ), /** Moldova Leu                                              */
   MDL("Moldova Leu"                                             ), /** Madagascar Ariary                                        */
   MGA("Madagascar Ariary"                                       ), /** Macedonia Denar                                          */
   MKD("Macedonia Denar"                                         ), /** Myanmar (Burma) Kyat                                     */
   MMK("Myanmar (Burma) Kyat"                                    ), /** Mongolia Tughrik                                         */
   MNT("Mongolia Tughrik"                                        ), /** Macau Pataca                                             */
   MOP("Macau Pataca"                                            ), /** Mauritania Ouguiya                                       */
   MRO("Mauritania Ouguiya"                                      ), /** Mauritius Rupee                                          */
   MUR("Mauritius Rupee"                                         ), /** Maldives (Maldive Islands) Rufiyaa                       */
   MVR("Maldives (Maldive Islands) Rufiyaa"                      ), /** Malawi Kwacha                                            */
   MWK("Malawi Kwacha"                                           ), /** Mexico Peso                                              */
   MXN("Mexico Peso"                                             ), /** Malaysia Ringgit                                         */
   MYR("Malaysia Ringgit"                                        ), /** Mozambique Metical                                       */
   MZN("Mozambique Metical"                                      ), /** Namibia Dollar                                           */
   NAD("Namibia Dollar"                                          ), /** Nigeria Naira                                            */
   NGN("Nigeria Naira"                                           ), /** Nicaragua Cordoba                                        */
   NIO("Nicaragua Cordoba"                                       ), /** Norway Krone                                             */
   NOK("Norway Krone"                                            ), /** Nepal Rupee                                              */
   NPR("Nepal Rupee"                                             ), /** New Zealand Dollar                                       */
   NZD("New Zealand Dollar"                                      ), /** Oman Rial                                                */
   OMR("Oman Rial"                                               ), /** Panama Balboa                                            */
   PAB("Panama Balboa"                                           ), /** Peru Nuevo Sol                                           */
   PEN("Peru Nuevo Sol"                                          ), /** Papua New Guinea Kina                                    */
   PGK("Papua New Guinea Kina"                                   ), /** Philippines Peso                                         */
   PHP("Philippines Peso"                                        ), /** Pakistan Rupee                                           */
   PKR("Pakistan Rupee"                                          ), /** Poland Zloty                                             */
   PLN("Poland Zloty"                                            ), /** Paraguay Guarani                                         */
   PYG("Paraguay Guarani"                                        ), /** Qatar Riyal                                              */
   QAR("Qatar Riyal"                                             ), /** Romania New Leu                                          */
   RON("Romania New Leu"                                         ), /** Serbia Dinar                                             */
   RSD("Serbia Dinar"                                            ), /** Russia Ruble                                             */
   RUB("Russia Ruble"                                            ), /** Rwanda Franc                                             */
   RWF("Rwanda Franc"                                            ), /** Saudi Arabia Riyal                                       */
   SAR("Saudi Arabia Riyal"                                      ), /** Solomon Islands Dollar                                   */
   SBD("Solomon Islands Dollar"                                  ), /** Seychelles Rupee                                         */
   SCR("Seychelles Rupee"                                        ), /** Sudan Pound                                              */
   SDG("Sudan Pound"                                             ), /** Sweden Krona                                             */
   SEK("Sweden Krona"                                            ), /** Singapore Dollar                                         */
   SGD("Singapore Dollar"                                        ), /** Saint Helena Pound                                       */
   SHP("Saint Helena Pound"                                      ), /** Sierra Leone Leone                                       */
   SLL("Sierra Leone Leone"                                      ), /** Somalia Shilling                                         */
   SOS("Somalia Shilling"                                        ), /** Seborga Luigino                                          */
   SPL("Seborga Luigino"                                         ), /** Suriname Dollar                                          */
   SRD("Suriname Dollar"                                         ), /** São Principe and Tome Dobra                              */
   STD("São Principe and Tome Dobra"                             ), /** El Salvador Colon                                        */
   SVC("El Salvador Colon"                                       ), /** Syria Pound                                              */
   SYP("Syria Pound"                                             ), /** Swaziland Lilangeni                                      */
   SZL("Swaziland Lilangeni"                                     ), /** Thailand Baht                                            */
   THB("Thailand Baht"                                           ), /** Tajikistan Somoni                                        */
   TJS("Tajikistan Somoni"                                       ), /** Turkmenistan Manat                                       */
   TMT("Turkmenistan Manat"                                      ), /** Tunisia Dinar                                            */
   TND("Tunisia Dinar"                                           ), /** Tonga Pa'anga                                            */
   TOP("Tonga Pa'anga"                                           ), /** Turkey Lira                                              */
   TRY("Turkey Lira"                                             ), /** Trinidad and Tobago Dollar                               */
   TTD("Trinidad and Tobago Dollar"                              ), /** Tuvalu Dollar                                            */
   TVD("Tuvalu Dollar"                                           ), /** Taiwan New Dollar                                        */
   TWD("Taiwan New Dollar"                                       ), /** Tanzania Shilling                                        */
   TZS("Tanzania Shilling"                                       ), /** Ukraine Hryvna                                           */
   UAH("Ukraine Hryvna"                                          ), /** Uganda Shilling                                          */
   UGX("Uganda Shilling"                                         ), /** United States Dollar                                     */
   USD("United States Dollar"                                    ), /** Uruguay Peso                                             */
   UYU("Uruguay Peso"                                            ), /** Uzbekistan Som                                           */
   UZS("Uzbekistan Som"                                          ), /** Venezuela Bolivar Fuerte                                 */
   VEF("Venezuela Bolivar Fuerte"                                ), /** Viet Nam Dong                                            */
   VND("Viet Nam Dong"                                           ), /** Vanuatu Vatu                                             */
   VUV("Vanuatu Vatu"                                            ), /** Samoa Tala                                               */
   WST("Samoa Tala"                                              ), /** Communauté Financière Africaine (BEAC) CFA Franc BEAC    */
   XAF("Communauté Financière Africaine (BEAC) CFA Franc BEAC"   ), /** East Caribbean Dollar                                    */
   XCD("East Caribbean Dollar"                                   ), /** International Monetary Fund (IMF) Special Drawing Rights */
   XDR("International Monetary Fund (IMF) Special Drawing Rights"), /** Communauté Financière Africaine (BCEAO) Franc            */
   XOF("Communauté Financière Africaine (BCEAO) Franc"           ), /** Comptoirs Français du Pacifique (CFP) Franc              */
   XPF("Comptoirs Français du Pacifique (CFP) Franc"             ), /** Yemen Rial                                               */
   YER("Yemen Rial"                                              ), /** South Africa Rand                                        */
   ZAR("South Africa Rand"                                       ), /** Zambia Kwacha                                            */
   ZMK("Zambia Kwacha"                                           ), /** Zimbabwe Dollar                                          */
   ZWD("Zimbabwe Dollar"                                         );

   // data members
   private String code;
   private String name;

   /**
    * constructor.
    * @param name   name of the currency.
    */
   private Currency(String name)
   {
      this.code = super.toString().toLowerCase();
      this.name = name;
   }

   /**
    * gets the ISO-4217 currency code.
    * @return the ISO-4217 currency code.
    */
   public String getCode()
   {
      return code;
   }

   /**
    * gets the three character ISO-4217 currency code as an array of bytes, using 1 byte for each character.
    * @return the three character ISO-4217 currency code as an array of bytes.
    */
   public byte[] getCodeBytes()
   {
      return code.getBytes(Encoding.ISO_8859_1.getCharacterSet());
   }

   /**
    * gets the name of the ISO-4217 currency.
    * @return the name of the currency.
    */
   public String getName()
   {
      return name;
   }

   /**
    * converts a three character String currency code value to its corresponding ISO-4217 currency enum.
    * @return an ISO-4217 currency enum corresponding to the string value.
    * @param code  string value of the currency code to be converted to an ISO-4217 currency enum.
    * @throws IllegalArgumentException   if the string currency code is not a valid ISO-4217 currency code.
    */
   public static Currency getCurrency(String code) throws IllegalArgumentException
   {
      if (code == null || code.length() != 3)
         throw new IllegalArgumentException("Invalid currency " + code + ".");

      for (Currency c : Currency.values())
         if (code.equalsIgnoreCase(c.getCode()))
            return c;
      throw new IllegalArgumentException("Invalid currency " + code + ".");
   }

   /**
    * gets a string representation of the ISO-4217 currency enum.
    * @return a string representation of the ISO-4217 currency enum.
    */
   public String toString()
   {
      return code + " - " + name;
   }
}
