< prev index next >

src/java.base/share/classes/java/util/Currency.java

Print this page
rev 58552 : [mq]: 8241727-Typos-empty-lines-in-javadoc-inconsistent-indents-etc
   1 /*
   2  * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 547                                 CurrencyNameGetter.INSTANCE,
 548                                 locale, currencyCode, SYMBOL);
 549         if (symbol != null) {
 550             return symbol;
 551         }
 552 
 553         // use currency code as symbol of last resort
 554         return currencyCode;
 555     }
 556 
 557     /**
 558      * Gets the default number of fraction digits used with this currency.
 559      * Note that the number of fraction digits is the same as ISO 4217's
 560      * minor unit for the currency.
 561      * For example, the default number of fraction digits for the Euro is 2,
 562      * while for the Japanese Yen it's 0.
 563      * In the case of pseudo-currencies, such as IMF Special Drawing Rights,
 564      * -1 is returned.
 565      *
 566      * @return the default number of fraction digits used with this currency
 567     */
 568     public int getDefaultFractionDigits() {
 569         return defaultFractionDigits;
 570     }
 571 
 572     /**
 573      * Returns the ISO 4217 numeric code of this currency.
 574      *
 575      * @return the ISO 4217 numeric code of this currency
 576      * @since 1.7
 577      */
 578     public int getNumericCode() {
 579         return numericCode;
 580     }
 581 
 582     /**
 583      * Returns the 3 digit ISO 4217 numeric code of this currency as a {@code String}.
 584      * Unlike {@link #getNumericCode()}, which returns the numeric code as {@code int},
 585      * this method always returns the numeric code as a 3 digit string.
 586      * e.g. a numeric value of 32 would be returned as "032",
 587      * and a numeric value of 6 would be returned as "006".


 922                 entry |= (fraction << SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT)
 923                         | (code.charAt(2) - 'A');
 924                 setMainTableEntry(code.charAt(0), code.charAt(1), entry);
 925             }
 926         }
 927     }
 928 
 929     /* Used to represent a special case currency entry
 930      * - cutOverTime: cut-over time in millis as returned by
 931      *   System.currentTimeMillis for special case countries that are changing
 932      *   currencies; Long.MAX_VALUE for countries that are not changing currencies
 933      * - oldCurrency: old currencies for special case countries
 934      * - newCurrency: new currencies for special case countries that are
 935      *   changing currencies; null for others
 936      * - oldCurrencyFraction: default fraction digits for old currencies
 937      * - newCurrencyFraction: default fraction digits for new currencies, 0 for
 938      *   countries that are not changing currencies
 939      * - oldCurrencyNumericCode: numeric code for old currencies
 940      * - newCurrencyNumericCode: numeric code for new currencies, 0 for countries
 941      *   that are not changing currencies
 942     */
 943     private static class SpecialCaseEntry {
 944 
 945         final private long cutOverTime;
 946         final private String oldCurrency;
 947         final private String newCurrency;
 948         final private int oldCurrencyFraction;
 949         final private int newCurrencyFraction;
 950         final private int oldCurrencyNumericCode;
 951         final private int newCurrencyNumericCode;
 952 
 953         private SpecialCaseEntry(long cutOverTime, String oldCurrency, String newCurrency,
 954                 int oldCurrencyFraction, int newCurrencyFraction,
 955                 int oldCurrencyNumericCode, int newCurrencyNumericCode) {
 956             this.cutOverTime = cutOverTime;
 957             this.oldCurrency = oldCurrency;
 958             this.newCurrency = newCurrency;
 959             this.oldCurrencyFraction = oldCurrencyFraction;
 960             this.newCurrencyFraction = newCurrencyFraction;
 961             this.oldCurrencyNumericCode = oldCurrencyNumericCode;
 962             this.newCurrencyNumericCode = newCurrencyNumericCode;


   1 /*
   2  * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 547                                 CurrencyNameGetter.INSTANCE,
 548                                 locale, currencyCode, SYMBOL);
 549         if (symbol != null) {
 550             return symbol;
 551         }
 552 
 553         // use currency code as symbol of last resort
 554         return currencyCode;
 555     }
 556 
 557     /**
 558      * Gets the default number of fraction digits used with this currency.
 559      * Note that the number of fraction digits is the same as ISO 4217's
 560      * minor unit for the currency.
 561      * For example, the default number of fraction digits for the Euro is 2,
 562      * while for the Japanese Yen it's 0.
 563      * In the case of pseudo-currencies, such as IMF Special Drawing Rights,
 564      * -1 is returned.
 565      *
 566      * @return the default number of fraction digits used with this currency
 567      */
 568     public int getDefaultFractionDigits() {
 569         return defaultFractionDigits;
 570     }
 571 
 572     /**
 573      * Returns the ISO 4217 numeric code of this currency.
 574      *
 575      * @return the ISO 4217 numeric code of this currency
 576      * @since 1.7
 577      */
 578     public int getNumericCode() {
 579         return numericCode;
 580     }
 581 
 582     /**
 583      * Returns the 3 digit ISO 4217 numeric code of this currency as a {@code String}.
 584      * Unlike {@link #getNumericCode()}, which returns the numeric code as {@code int},
 585      * this method always returns the numeric code as a 3 digit string.
 586      * e.g. a numeric value of 32 would be returned as "032",
 587      * and a numeric value of 6 would be returned as "006".


 922                 entry |= (fraction << SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT)
 923                         | (code.charAt(2) - 'A');
 924                 setMainTableEntry(code.charAt(0), code.charAt(1), entry);
 925             }
 926         }
 927     }
 928 
 929     /* Used to represent a special case currency entry
 930      * - cutOverTime: cut-over time in millis as returned by
 931      *   System.currentTimeMillis for special case countries that are changing
 932      *   currencies; Long.MAX_VALUE for countries that are not changing currencies
 933      * - oldCurrency: old currencies for special case countries
 934      * - newCurrency: new currencies for special case countries that are
 935      *   changing currencies; null for others
 936      * - oldCurrencyFraction: default fraction digits for old currencies
 937      * - newCurrencyFraction: default fraction digits for new currencies, 0 for
 938      *   countries that are not changing currencies
 939      * - oldCurrencyNumericCode: numeric code for old currencies
 940      * - newCurrencyNumericCode: numeric code for new currencies, 0 for countries
 941      *   that are not changing currencies
 942      */
 943     private static class SpecialCaseEntry {
 944 
 945         final private long cutOverTime;
 946         final private String oldCurrency;
 947         final private String newCurrency;
 948         final private int oldCurrencyFraction;
 949         final private int newCurrencyFraction;
 950         final private int oldCurrencyNumericCode;
 951         final private int newCurrencyNumericCode;
 952 
 953         private SpecialCaseEntry(long cutOverTime, String oldCurrency, String newCurrency,
 954                 int oldCurrencyFraction, int newCurrencyFraction,
 955                 int oldCurrencyNumericCode, int newCurrencyNumericCode) {
 956             this.cutOverTime = cutOverTime;
 957             this.oldCurrency = oldCurrency;
 958             this.newCurrency = newCurrency;
 959             this.oldCurrencyFraction = oldCurrencyFraction;
 960             this.newCurrencyFraction = newCurrencyFraction;
 961             this.oldCurrencyNumericCode = oldCurrencyNumericCode;
 962             this.newCurrencyNumericCode = newCurrencyNumericCode;


< prev index next >