classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] Re: java.util.Currency


From: Bryce McKinlay
Subject: [cp-patches] Re: java.util.Currency
Date: Tue, 16 Nov 2004 20:50:10 -0500
User-agent: Mozilla Thunderbird 0.9 (X11/20041103)

Hi Andrew,

A while back I was hacking on java.util.Currency and decided to change our strategy a little. Rather than get the currency data from the Locales, I've put a separate table containing the data for each currency into the Currency class itself. This seems to be the logical thing to do since there isn't a 1:1 correspondence between a locale and a currency anyway. This should improve getInstance() performance a lot since we no longer need to go fishing through all locales to find a given currency code, as well as improving correctness and completeness for things like getDefaultFractionDigits().

I haven't yet tested this extensively, and haven't run your new mauve tests against it, but perhaps you'd like to take a look at this code and let me know what you think based on your knowledge of the Currency class.

Regards

Bryce


Andrew John Hughes wrote:

The attached patch adds missing documentation to
java.util.Currency, as well as implementing correct
serialization and maintainence of its singleton status
via a cache.
One problem I found in testing this is that retrieving
a instance based on a country code will never work,
as getAllAvailableLocales() is not implemented correctly
(it currently returns a static list of four locales,
most of which refer to particular languages rather than
countries, which isn't too helpful as regards currencies
-- I could retrieve the UK currency via getInstance(Locale.UK)
but not via getInstance("GBP")).  Can this now be properly
implemented?  I don't know the status regarding the locales,
but I suppose we could at least include all the constant
locales in Locale, if not something better.  From browsing
through gnu.java.locale, there are quite a few now implemented
(but I don't know to what degree).

Index: java/util/Currency.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/util/Currency.java,v
retrieving revision 1.5
diff -u -r1.5 Currency.java
--- java/util/Currency.java     7 Nov 2004 11:29:03 -0000       1.5
+++ java/util/Currency.java     17 Nov 2004 01:49:05 -0000
@@ -41,6 +41,8 @@
 import java.io.Serializable;
 import java.text.NumberFormat;
 
+import gnu.java.locale.LocaleHelper;
+
 /**
  * Representation of a currency for a particular locale.  Each currency
  * is identified by its ISO 4217 code, and only one instance of this
@@ -62,25 +64,9 @@
    * For compatability with Sun's JDK
    */
   static final long serialVersionUID = -158308464356906721L;
-
-  /**
-   * The locale associated with this currency.
-   *
-   * @see #Currency(java.util.Locale)
-   * @see #getInstance(java.util.Locale)
-   * @see #getSymbol(java.util.Locale)
-   * @serial ignored.
-   */
-  private transient Locale locale;
-
-  /**
-   * The resource bundle which maps the currency to
-   * a ISO 4217 currency code.
-   *
-   * @see #getCurrencyCode()
-   * @serial ignored.
-   */
-  private transient ResourceBundle res;
+  
+  /** Map associating ISO 4217 currency codes with Currency instances. */
+  private static HashMap codes = new HashMap(275);
 
   /**
    * The ISO 4217 currency code associated with this
@@ -91,30 +77,29 @@
    */
   private String currencyCode;
 
+  private transient int fractionDigits;
+  
   /**
-   * A cache of <code>Currency</code> instances to
-   * ensure the singleton nature of this class.  The key
-   * is the locale of the currency.
-   *
-   * @see #getInstance(java.util.Locale)
-   * @see #readResolve()
-   * @serial ignored.
-   */
-  private transient static Map cache;
-
-  /**
-   * Instantiates the cache.
+   * Default constructor for deserialization
    */
-  static
+  private Currency ()
   {
-    cache = new HashMap();
   }
-
+  
   /**
-   * Default constructor for deserialization
+   * Resolves a serialized currency to its unique instance. Called during
+   * deserialization.
+   *
+   * @return the singleton instance for the currency specified by the
+   *         currency code of the serialized object.  This replaces
+   *         the serialized object as the returned object from
+   *         deserialization.
+   * @throws ObjectStreamException if a problem occurs with deserializing
+   *         the object.
    */
-  private Currency ()
+  private Object readResolve() throws ObjectStreamException
   {
+    return getInstance(this.currencyCode);
   }
 
   /**
@@ -126,26 +111,17 @@
    * a particular country changes.  For countries without
    * a given currency (e.g. Antarctica), the result is null. 
    *
-   * @param loc the locale for the new currency.
+   * @param currencyCode
+   * @param fractionDigits
    */
-  private Currency (Locale loc)
+  private Currency(String currencyCode, int fractionDigits)
   {
-    this.locale = loc;
-    this.res = ResourceBundle.getBundle ("gnu.java.locale.LocaleInformation", 
-      locale, ClassLoader.getSystemClassLoader());
-    /* Retrieve the ISO4217 currency code */
-    try
-      {
-       currencyCode = res.getString ("intlCurrencySymbol");
-      }
-    catch (Exception _)
-      {
-       currencyCode = null;
-      }
+    this.currencyCode = currencyCode;
+    this.fractionDigits = fractionDigits;
   }
 
   /**
-   * Returns the ISO4217 currency code of this currency.
+   * Returns the ISO 4217 currency code of this currency.
    *
    * @return a <code>String</code> containing currency code.
    */
@@ -168,9 +144,7 @@
    */   
   public int getDefaultFractionDigits ()
   {
-    NumberFormat currency = NumberFormat.getCurrencyInstance (locale);
-    
-    return currency.getMaximumFractionDigits();
+    return fractionDigits;
   }
     
   /**
@@ -183,6 +157,7 @@
    *
    * @param locale a <code>Locale</code> instance.
    * @return a new <code>Currency</code> instance.
+   *
    * @throws NullPointerException if the locale or its
    *         country code is null.
    * @throws IllegalArgumentException if the country of
@@ -190,27 +165,9 @@
    */ 
   public static Currency getInstance (Locale locale)
   {
-    /**
-     * The new instance must be the only available instance
-     * for the currency it supports.  We ensure this happens,
-     * while maintaining a suitable performance level, by
-     * creating the appropriate object on the first call to
-     * this method, and returning the cached instance on
-     * later calls.
-     */
-    Currency newCurrency;
-
-    /* Attempt to get the currency from the cache */
-    newCurrency = (Currency) cache.get(locale);
-    if (newCurrency == null)
-      {
-        /* Create the currency for this locale */
-        newCurrency = new Currency (locale);
-        /* Cache it */
-        cache.put(locale, newCurrency);
-      }
-    /* Return the instance */
-    return newCurrency;
+    ResourceBundle rb = LocaleHelper.getLocaleInformation(locale);
+    String code = rb.getString("intlCurrencySymbol");
+    return getInstance(code);
   }
 
   /**
@@ -224,22 +181,12 @@
    */
   public static Currency getInstance (String currencyCode)
   {
-    Locale[] allLocales = Locale.getAvailableLocales ();
-    
-    for (int i = 0;i < allLocales.length; i++)
-      {
-       Currency testCurrency = getInstance (allLocales[i]);
-       
-       if (testCurrency.getCurrencyCode() != null &&
-           testCurrency.getCurrencyCode().equals(currencyCode))
-         return testCurrency;
-      }
-    /* 
-     * If we get this far, the code is not supported by any of
-     * our locales.
-     */
-    throw new IllegalArgumentException("The currency code, " + currencyCode +
-                                       ", is not supported.");
+    // No need to synchronize, because "codes" is immutable.
+    Object obj = codes.get(currencyCode);
+    if (obj == null)
+      throw new IllegalArgumentException();
+      
+    return (Currency) obj;
   }
 
   /**
@@ -253,15 +200,7 @@
    */
   public String getSymbol()
   {
-    try
-      {
-        /* What does this return if there is no mapping? */
-       return res.getString ("currencySymbol");
-      }
-    catch (Exception _)
-      {
-       return null;
-      }
+    return getSymbol(Locale.getDefault());
   }
 
   /**
@@ -291,37 +230,20 @@
    */
   public String getSymbol(Locale locale)
   {
-    // TODO. The behaviour is unclear if locale != this.locale.
-    // First we need to implement fully LocaleInformation*.java
-
-    /* 
-     * FIXME: My reading of how this method works has this implementation
-     * as wrong.  It should return a value relating to how the specified
-     * locale handles the symbol for this currency.  This implementation
-     * seems to just do a variation of getInstance(locale).
-     */
     try
-      {
-       ResourceBundle localeResource = 
-         ResourceBundle.getBundle ("gnu.java.locale.LocaleInformation", 
-                                   locale, Currency.class.getClassLoader());
-
-       if (localeResource.equals(res))
-         return localeResource.getString ("currencySymbol");
-       else
-         return localeResource.getString ("intlCurrencySymbol");
-      }
-    catch (Exception e1)
-      {
-       try
-         {
-           return res.getString ("intlCurrencySymbol");
-         }
-       catch (Exception e2)
-         {
-           return null;
-         }
-      }
+    {
+      ResourceBundle res = LocaleHelper.getLocaleInformation(locale);
+
+      String intlSymbol = res.getString("intlCurrencySymbol");
+      if (intlSymbol.equals(this.currencyCode))
+       return res.getString("currencySymbol");
+      else
+       return intlSymbol;
+    }
+    catch (MissingResourceException x)
+    {
+      throw new IllegalArgumentException();
+    }
   }
 
   /**
@@ -331,25 +253,213 @@
    */
   public String toString()
   {
-    return getCurrencyCode();
+    return currencyCode;
   }
 
-  /**
-   * Resolves the deserialized object to the singleton instance for its
-   * particular currency.  The currency code of the deserialized instance
-   * is used to return the correct instance.
-   *
-   * @return the singleton instance for the currency specified by the
-   *         currency code of the deserialized object.  This replaces
-   *         the deserialized object as the returned object from
-   *         deserialization.
-   * @throws ObjectStreamException if a problem occurs with deserializing
-   *         the object.
-   */
-  private Object readResolve()
-    throws ObjectStreamException
+  static
   {
-    return getInstance(currencyCode);
+    codes.put("AED", new Currency ("AED", 2));  /* United Arab Emirates Dirham 
*/
+    codes.put("AFN", new Currency ("AFN", 2));  /* Afghani */
+    codes.put("ALL", new Currency ("ALL", 2));  /* Albanian Lek */
+    codes.put("AMD", new Currency ("AMD", 2));  /* Armenian Dram */
+    codes.put("ANG", new Currency ("ANG", 2));  /* Netherlands Antillian 
Guilder */
+    codes.put("AOA", new Currency ("AOA", 2));  /* Angolan Kwanza */
+    codes.put("ARS", new Currency ("ARS", 2));  /* Argentine Peso */
+    codes.put("AUD", new Currency ("AUD", 2));  /* Australian Dollar */
+    codes.put("AWG", new Currency ("AWG", 2));  /* Aruban Guilder */
+    codes.put("AZM", new Currency ("AZM", 2));  /* Azerbaijani Manat */
+    codes.put("BAM", new Currency ("BAM", 2));  /* Bosnia-Herzegovina 
Convertible Marks */
+    codes.put("BBD", new Currency ("BBD", 2));  /* Barbados Dollar */
+    codes.put("BDT", new Currency ("BDT", 2));  /* Bangladesh Taka */
+    codes.put("BGN", new Currency ("BGN", 2));  /* Bulgarian Lev (since 
1999-07-05) */
+    codes.put("BHD", new Currency ("BHD", 3));  /* Bahraini Dinar */
+    codes.put("BIF", new Currency ("BIF", 0));  /* Burundi Franc */
+    codes.put("BMD", new Currency ("BMD", 2));  /* Bermuda Dollar */
+    codes.put("BND", new Currency ("BND", 2));  /* Brunei Dollar */
+    codes.put("BOB", new Currency ("BOB", 2));  /* Bolivian Boliviano */
+    codes.put("BOV", new Currency ("BOV", 2));  /* Bolivian Mvdol (Funds code) 
*/
+    codes.put("BRL", new Currency ("BRL", 2));  /* Brazilian Real */
+    codes.put("BSD", new Currency ("BSD", 2));  /* Bahamian Dollar */
+    codes.put("BTN", new Currency ("BTN", 2));  /* Bhutan Ngultrum */
+    codes.put("BWP", new Currency ("BWP", 2));  /* Botswana Pula */
+    codes.put("BYR", new Currency ("BYR", 0));  /* Belarussian Ruble */
+    codes.put("BZD", new Currency ("BZD", 2));  /* Belize Dollar */
+    codes.put("CAD", new Currency ("CAD", 2));  /* Canadian Dollar */
+    codes.put("CDF", new Currency ("CDF", 2));  /* Franc Congolais */
+    codes.put("CHF", new Currency ("CHF", 2));  /* Swiss franc */
+    codes.put("CLF", new Currency ("CLF", 0));  /* Chilean Unidades de fomento 
(Funds code) */
+    codes.put("CLP", new Currency ("CLP", 0));  /* Chilean Peso */
+    codes.put("CNY", new Currency ("CNY", 2));  /* Yuan Renminbi */
+    codes.put("COP", new Currency ("COP", 2));  /* Colombian peso */
+    codes.put("CRC", new Currency ("CRC", 2));  /* Costa Rican Col�n */
+    codes.put("CSD", new Currency ("CSD", 2));  /* Serbian Dinar */
+    codes.put("CUP", new Currency ("CUP", 2));  /* Cuban Peso */
+    codes.put("CVE", new Currency ("CVE", 2));  /* Cape Verde Escudo */
+    codes.put("CYP", new Currency ("CYP", 2));  /* Cyprus Pound */
+    codes.put("CZK", new Currency ("CZK", 2));  /* Czech Koruna */
+    codes.put("DJF", new Currency ("DJF", 0));  /* Djibouti Franc */
+    codes.put("DKK", new Currency ("DKK", 2));  /* Danish Krone */
+    codes.put("DOP", new Currency ("DOP", 2));  /* Dominican Peso */
+    codes.put("DZD", new Currency ("DZD", 2));  /* Algerian Dinar */
+    codes.put("EEK", new Currency ("EEK", 2));  /* Estonian Kroon */
+    codes.put("EGP", new Currency ("EGP", 2));  /* Egyptian Pound */
+    codes.put("ERN", new Currency ("ERN", 2));  /* Eritrea Nakfa */
+    codes.put("ETB", new Currency ("ETB", 2));  /* Ethiopian Birr */
+    codes.put("EUR", new Currency ("EUR", 2));  /* Euro */
+    codes.put("FJD", new Currency ("FJD", 2));  /* Fiji Dollar */
+    codes.put("FKP", new Currency ("FKP", 2));  /* Falkland Islands Pound */
+    codes.put("GBP", new Currency ("GBP", 2));  /* Pound Sterling */
+    codes.put("GEL", new Currency ("GEL", 2));  /* Georgian Lari */
+    codes.put("GHC", new Currency ("GHC", 2));  /* Ghana Cedi */
+    codes.put("GIP", new Currency ("GIP", 2));  /* Gibraltar Pound */
+    codes.put("GMD", new Currency ("GMD", 2));  /* Gambian Dalasi */
+    codes.put("GNF", new Currency ("GNF", 0));  /* Guinea Franc */
+    codes.put("GTQ", new Currency ("GTQ", 2));  /* Guatemalan Quetzal */
+    codes.put("GWP", new Currency ("GWP", 2));  /* Guinea-Bissau Peso */
+    codes.put("GYD", new Currency ("GYD", 2));  /* Guyana Dollar */
+    codes.put("HKD", new Currency ("HKD", 2));  /* Hong Kong Dollar */
+    codes.put("HNL", new Currency ("HNL", 2));  /* Honduran Lempira */
+    codes.put("HRK", new Currency ("HRK", 2));  /* Croatian Kuna */
+    codes.put("HTG", new Currency ("HTG", 2));  /* Haitian Gourde */
+    codes.put("HUF", new Currency ("HUF", 2));  /* Hungarian Forint */
+    codes.put("IDR", new Currency ("IDR", 2));  /* Indonesian Rupiah */
+    codes.put("ILS", new Currency ("ILS", 2));  /* New Israeli Shekel */
+    codes.put("INR", new Currency ("INR", 2));  /* Indian Rupee */
+    codes.put("IQD", new Currency ("IQD", 3));  /* Iraqi Dinar */
+    codes.put("IRR", new Currency ("IRR", 2));  /* Iranian Rial */
+    codes.put("ISK", new Currency ("ISK", 2));  /* Iceland Krona */
+    codes.put("JMD", new Currency ("JMD", 2));  /* Jamaican Dollar */
+    codes.put("JOD", new Currency ("JOD", 3));  /* Jordanian Dinar */
+    codes.put("JPY", new Currency ("JPY", 0));  /* Japanese Yen */
+    codes.put("KES", new Currency ("KES", 2));  /* Kenyan Shilling */
+    codes.put("KGS", new Currency ("KGS", 2));  /* Kyrgyzstan Som */
+    codes.put("KHR", new Currency ("KHR", 2));  /* Cambodian Riel */
+    codes.put("KMF", new Currency ("KMF", 0));  /* Comoro Franc */
+    codes.put("KPW", new Currency ("KPW", 2));  /* North Korean Won */
+    codes.put("KRW", new Currency ("KRW", 0));  /* South Korean Won */
+    codes.put("KWD", new Currency ("KWD", 3));  /* Kuwaiti Dinar */
+    codes.put("KYD", new Currency ("KYD", 2));  /* Cayman Islands Dollar */
+    codes.put("KZT", new Currency ("KZT", 2));  /* Kazakhstan Tenge */
+    codes.put("LAK", new Currency ("LAK", 2));  /* Lao Kip */
+    codes.put("LBP", new Currency ("LBP", 2));  /* Lebanese Pound */
+    codes.put("LKR", new Currency ("LKR", 2));  /* Sri Lanka Rupee */
+    codes.put("LRD", new Currency ("LRD", 2));  /* Liberian Dollar */
+    codes.put("LSL", new Currency ("LSL", 2));  /* Lesotho Loti */
+    codes.put("LTL", new Currency ("LTL", 2));  /* Lithuanian Litus */
+    codes.put("LVL", new Currency ("LVL", 2));  /* Latvian Lats */
+    codes.put("LYD", new Currency ("LYD", 3));  /* Libyan Dinar */
+    codes.put("MAD", new Currency ("MAD", 2));  /* Moroccan Dirham */
+    codes.put("MDL", new Currency ("MDL", 2));  /* Moldovan Leu */
+    codes.put("MGF", new Currency ("MGF", 0));  /* Malagasy Franc */
+    codes.put("MKD", new Currency ("MKD", 2));  /* Macedonian(Former Yug. 
Rep.) Denar */
+    codes.put("MMK", new Currency ("MMK", 2));  /* Myanmar Kyat */
+    codes.put("MNT", new Currency ("MNT", 2));  /* Mongolian Tugrik */
+    codes.put("MOP", new Currency ("MOP", 2));  /* Macau Pataca */
+    codes.put("MRO", new Currency ("MRO", 2));  /* Mauritanian Ouguiya */
+    codes.put("MTL", new Currency ("MTL", 2));  /* Maltese Lira */
+    codes.put("MUR", new Currency ("MUR", 2));  /* Mauritius Rupee */
+    codes.put("MVR", new Currency ("MVR", 2));  /* Maldives Rufiyaa */
+    codes.put("MWK", new Currency ("MWK", 2));  /* Malawi Kwacha */
+    codes.put("MXN", new Currency ("MXN", 2));  /* Mexican Peso */
+    codes.put("MXV", new Currency ("MXV", 2));  /* Mexican Unidad de Inversion 
(UDI) (Funds code) */
+    codes.put("MYR", new Currency ("MYR", 2));  /* Malaysian Ringgit */
+    codes.put("MZM", new Currency ("MZM", 2));  /* Moazambique Metical */
+    codes.put("NAD", new Currency ("NAD", 2));  /* Namibian Dollar */
+    codes.put("NGN", new Currency ("NGN", 2));  /* Nigerian Naira */
+    codes.put("NIO", new Currency ("NIO", 2));  /* Nicaraguan C�rdoba Oro */
+    codes.put("NOK", new Currency ("NOK", 2));  /* Norwegian Krone */
+    codes.put("NPR", new Currency ("NPR", 2));  /* Nepalese Rupee */
+    codes.put("NZD", new Currency ("NZD", 2));  /* New Zealand Dollar */
+    codes.put("OMR", new Currency ("OMR", 3));  /* Omani Rial */
+    codes.put("PAB", new Currency ("PAB", 2));  /* Panama Balboa */
+    codes.put("PEN", new Currency ("PEN", 2));  /* Peruvian Nuevo Sol */
+    codes.put("PGK", new Currency ("PGK", 2));  /* Papua New Guinea Kina */
+    codes.put("PHP", new Currency ("PHP", 2));  /* Philippine peso */
+    codes.put("PKR", new Currency ("PKR", 2));  /* Pakistani Rupee */
+    codes.put("PLN", new Currency ("PLN", 2));  /* Polish Zloty */
+    codes.put("PYG", new Currency ("PYG", 0));  /* Paraguay Guarani */
+    codes.put("QAR", new Currency ("QAR", 2));  /* Qatari Rial */
+    codes.put("ROL", new Currency ("ROL", 2));  /* Romanian Leu */
+    codes.put("RUB", new Currency ("RUB", 2));  /* Russian Ruble */
+    codes.put("RWF", new Currency ("RWF", 0));  /* Rwanda Franc */
+    codes.put("SAR", new Currency ("SAR", 2));  /* Saudi Riya */
+    codes.put("SBD", new Currency ("SBD", 2));  /* Solomon Islands Dollar */
+    codes.put("SCR", new Currency ("SCR", 2));  /* Seychelles Rupee */
+    codes.put("SDD", new Currency ("SDD", 2));  /* Sudanese Dinar */
+    codes.put("SEK", new Currency ("SEK", 2));  /* Swedish Krona */
+    codes.put("SGD", new Currency ("SGD", 2));  /* Singapore Dollar */
+    codes.put("SHP", new Currency ("SHP", 2));  /* Saint Helena Pound */
+    codes.put("SIT", new Currency ("SIT", 2));  /* Slovene Tolar */
+    codes.put("SKK", new Currency ("SKK", 2));  /* Slovak Koruna */
+    codes.put("SLL", new Currency ("SLL", 2));  /* Sierra Leonean Leone */
+    codes.put("SOS", new Currency ("SOS", 2));  /* Somali Shilling */
+    codes.put("STD", new Currency ("STD", 2));  /* So Tom and Principe Dobra */
+    codes.put("SVC", new Currency ("SVC", 2));  /* El Salvador Col�n */
+    codes.put("SYP", new Currency ("SYP", 2));  /* Syrian Pound */
+    codes.put("SZL", new Currency ("SZL", 2));  /* Swaziland Lilangeni */
+    codes.put("THB", new Currency ("THB", 2));  /* Thai Baht */
+    codes.put("TJS", new Currency ("TJS", 2));  /* Tajikistani Somoni */
+    codes.put("TMM", new Currency ("TMM", 2));  /* Turkmenistan Manat */
+    codes.put("TND", new Currency ("TND", 3));  /* Tunisian Dinar */
+    codes.put("TOP", new Currency ("TOP", 2));  /* Tongan Pa'anga */
+    codes.put("TPE", new Currency ("TPE", 0));  /* Timor Escudo */
+    codes.put("TRL", new Currency ("TRL", 0));  /* Turkish Lira */
+    codes.put("TTD", new Currency ("TTD", 2));  /* Trinidad and Tobago Dollar 
*/
+    codes.put("TWD", new Currency ("TWD", 2));  /* New Taiwan Dollar */
+    codes.put("TZS", new Currency ("TZS", 2));  /* Tanzanian Shilling */
+    codes.put("UAH", new Currency ("UAH", 2));  /* Ukrainian Hryvnia */
+    codes.put("UGX", new Currency ("UGX", 2));  /* Uganda Shilling */
+    codes.put("USD", new Currency ("USD", 2));  /* United States Dollar */
+    codes.put("USN", new Currency ("USN", 2));  /* United States Dollar (Next 
day) (Funds code) */
+    codes.put("USS", new Currency ("USS", 2));  /* United States Dollar (Same 
day) (Funds code) */
+    codes.put("UYU", new Currency ("UYU", 2));  /* Peso Uruguayo */
+    codes.put("UZS", new Currency ("UZS", 2));  /* Uzbekistan Sum */
+    codes.put("VEB", new Currency ("VEB", 2));  /* Venezuelan Bolivar */
+    codes.put("VND", new Currency ("VND", 2));  /* Viet Nam Dong */
+    codes.put("VUV", new Currency ("VUV", 0));  /* Vanuatu Vatu */
+    codes.put("WST", new Currency ("WST", 2));  /* Samoa Tala */
+    codes.put("YER", new Currency ("YER", 2));  /* Yemeni Rial */
+    codes.put("ZAR", new Currency ("ZAR", 2));  /* South African Rand */
+    codes.put("ZMK", new Currency ("ZMK", 2));  /* Zambian Kwacha */
+    codes.put("ZWD", new Currency ("ZWD", 2));  /* Zimbabwe Dollar */
+
+    // Special codes.
+    codes.put("XAF", new Currency ("XAF", 0));  /* CFA Franc BEAC */
+    codes.put("XAG", new Currency ("XAG", -1));  /* Silver Ounce */
+    codes.put("XAU", new Currency ("XAU", -1));  /* Gold Ounce */
+    codes.put("XBA", new Currency ("XBA", -1));  /* European Composite Unit 
(EURCO) (Bonds market unit) */
+    codes.put("XBB", new Currency ("XBB", -1));  /* European Monetary Unit 
(E.M.U.-6) (Bonds market unit) */
+    codes.put("XBC", new Currency ("XBC", -1));  /* European Unit of Account 9 
(E.U.A.-9) (Bonds market unit) */
+    codes.put("XBD", new Currency ("XBD", -1));  /* European Unit of Account 
17 (E.U.A.-17) (Bonds market unit) */
+    codes.put("XCD", new Currency ("XCD", 2));  /* East Caribbean Dollar */
+    codes.put("XDR", new Currency ("XDR", -1));  /* Special Drawing Rights 
(IMF) */
+    codes.put("XFO", new Currency ("XFO", -1));  /* Gold-Franc (Special 
settlement currency) */
+    codes.put("XFU", new Currency ("XFU", -1));  /* UIC Franc (Special 
settlement currency) */
+    codes.put("XOF", new Currency ("XOF", 0));  /* CFA Franc BCEAO */
+    codes.put("XPD", new Currency ("XPD", -1));  /* Palladium Ounce */
+    codes.put("XPF", new Currency ("XPF", 0));  /* CFP Franc */
+    codes.put("XPT", new Currency ("XPT", -1));  /* Platinum Ounce */
+    codes.put("XTS", new Currency ("XTS", -1));  /* Code reserved for testing 
purposes */
+    codes.put("XXX", new Currency ("XXX", -1));  /* No currency */
+
+    // Obsolete codes.
+    codes.put("ADP", new Currency ("ADP", 0));  /* Andorran Peseta (Euro) */
+    codes.put("AFA", new Currency ("AFA", 2));  /* Afghani (replaced by AFN) */
+    codes.put("ATS", new Currency ("ATS", 2));  /* Austrian Schilling (Euro) */
+    codes.put("BEF", new Currency ("BEF", 0));  /* Belgian Franc (Euro) */
+    codes.put("BGL", new Currency ("BGL", 2));  /* Bulgarian Lev (before 
1999-07-05) */
+    codes.put("DEM", new Currency ("DEM", 2));  /* Deutsche Mark (Euro) */
+    codes.put("ESP", new Currency ("ESP", 0));  /* Spanish Peseta (Euro) */
+    codes.put("FIM", new Currency ("FIM", 2));  /* Finnish Markka (Euro) */
+    codes.put("FRF", new Currency ("FRF", 2));  /* French Franc (Euro) */
+    codes.put("GRD", new Currency ("GRD", 0));  /* Greek Drachma (Euro) */
+    codes.put("IEP", new Currency ("IEP", 2));  /* Irish Pound (Euro) */
+    codes.put("ITL", new Currency ("ITL", 0));  /* Italian Lira (Euro) */
+    codes.put("LUF", new Currency ("LUF", 0));  /* Luxembourg Franc (Euro) */
+    codes.put("NLG", new Currency ("NLG", 2));  /* Netherlands Guilder (Euro) 
*/
+    codes.put("PTE", new Currency ("PTE", 0));  /* Portuguese Escudo (Euro) */
+    codes.put("RUR", new Currency ("RUR", 2));  /* Russian Ruble (replaced by 
RUB) */
+    codes.put("SRG", new Currency ("SRG", 2));  /* Suriname Guilder (replaced 
by SRD) */
+    codes.put("YUM", new Currency ("YUM", 2));  /* Yugoslavian Dinar (Serbian 
dinar - CSD) */
   }
-
 }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]