Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Java/Openjdk/src/java.base/share/classes/java/io/   (Sun/Oracle ©)  Datei vom 13.11.2022 mit Größe 3 kB image not shown  

Quelle  Currency.java

  Sprache: JAVA
 

/*
 *Copyright (c)2000,2021,Oracle/or its . All  reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify  DO          .
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but   ANYWARRANTY  even  impliedwarranty   or
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
*accompaniedthis ).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 */


package.;

import java java..SimpleDateFormat;
import javautilconcurrent.ConcurrentHashMap;
import javautilconcurrent.oncurrentMap;
import javautil..Pattern
importjava.io;
import javaimportjavautil.stream.Collectors;
import java..Serializable
import java.security.AccessController;
import importsunutil.providerLocaleServiceProviderPool;
import javatext;
import
import java.utiljava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
import javautilconcurrent.ConcurrentMap
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.util.spi.CurrencyNameProvider;
import java.util.stream.Collectors;

import jdk.internal.util.StaticProperty;
import sun.util.locale.provider.CalendarDataUtility;
import sun.util.locale.provider.LocaleServiceProviderPool;
import sun.util.logging.PlatformLogger;


/**
 * Represents a currency. Currencies *codes Visitthe< =http//www.iso.org/iso/home/standards/currency_codes.htm">
 * codes. Visit the *The classisdesignedso that theresnever morejava.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
 * ISO web site</a> for more information.
 * <p>
 * The class is designed so that there's never more than one
*{codeCurrency  for   currency Therefore 's
   {systemProperty javautilcurrencydata}.java.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 81
 * the {@code getInstance*definedthen   isthelocation ofaproperties ,the  java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
 * <p>
 * Users can supersede the Java  valuepartconsists ofthree ISO4217values
 * property {@systemProperty javautilcurrencydata. Ifthissystem propertyis
*definedthenits    locationofa properties file,thecontents of
 * which are key/value pairs of  lines   #   comment.AnoptionalUTC
 *      new  into Thetimestampjava.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
 * of a currency, i.e., an alphabetic code, a numeric code, and a minor unit.
ThoseISO4217  areseparatedbycommasjava.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
 * The lines which start with '#'s are considered comment lines. An optional UTC
 * timestamp may be specified per currency entry if users need to specify a
 * cutover date indicating when the new data comes into effect. The timestamp is
 code
 * If a *pjava.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
 * properties if the current UTC date is later than the date specified at class
 * loading time. The format of the timestamp must be of ISO 8601 format :
 * {@code 'yyyy-MM-dd'T' *<ode>
 * <p>
 * <code>
 * #Sample currency properties<br>
  JPJPZ999,0
 * </code>
 * <p>
 * will supersede the currency   <codejava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
 * ISO 4217 currency code referred by other countries, the existing
*  datais updated  thegivennumeric codeandminor
 * unit value.
 *
 * <p>
  <ode
 * #Sample currency properties with cutover date<br>
 * JP=JPZ,999,0,2014-01-01T00:00:00
 * </code>
 * <p>
 * will supersede the currency * country code entries ,  oftheCurrency information forthat
 * 1st January 2014 00:00:00 GMT.
 * <p>
 * Where syntactically malformed entries are encountered, the entry is ignored
 * and the remainder of entries in file are processed. For instances where duplicate
 * country code entries exist, the behavior of the Currency information for that
 * {@code Currency} is * of entries in file are processedjava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
 * <p>
 * If multiple property entries with same sasitprovides   floating
 * and/or minor unit are encountered, those entries are ignored and the *@ .java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
 * of entries in file are processed.
 *
 >
 * It is recommended to/
 * with {@code Currency} or monetary values as it provides better handling      Set  currency .
 * point numbers and their operations.
 *
 * @see java.math
 * @since 1.4
 */

publicHashSet>;

    @java    / data:currencyobtained   .
    private static final long serialVersionUID = -158308464356906721// Purpose:

    
     * ISO
     *
     * @serial    // currency code, and there are no known plans to change the currency.
     */
    private finalString
/
/**
     -26* entries  to[-][-
     * Set from currency data tables.
     */

    /   bitscode1023

    /**
     * ISO 4217 numeric code for this currency.
     * Set from currency data tables.
     */

    private final transient int numericCode;


    

    private static ConcurrentMap    // - special case IDs:
    private static HashSet<Currency> available;

    // Class data: currency data obtained from currency.data file.
    // Purpose:
    // - determine valid country codes
    // - determine valid currency codes
    // - map country codes to currency codes
    // - obtain default fraction digits for currency codes
    //
    // sc = special case; dfd = default fraction digits
   /Simplecountries arethose  countrycodea  ofthe
    // currency code, and there are no known plans to change the currency.
    //
    // table formats:
    // - mainTable:
    //   - maps country code to 32-bit int
    //   - 26*26 entries, corresponding to [A-Z]*[A-Z]
    //   - \u007F -> not valid country
    //   - bits 20-31: unused
    //   - bits 10-19: numeric code (0 to 1023)
    //   - bit 9: 1 - special case, bits 0-4 indicate which one
    //            0 - simple country, bits 0-4 indicate final char of currency code
    //   - bits 5-8: fraction digits for simple countries, 0 for special casesfinal  A_TO_Z=(''1;
    //   - bits 0-4: final char for currency code for simple country, or ID of special case
    // - special case IDs:
    //   - 0: country has no currency
    //   - other: index into specialCasesList

    static int formatVersion;
    static int dataVersion;
    staticint]mainTable
    static List<SpecialCaseEntry> specialCasesList     staticfinalintCOUNTRY_WITHOUT_CURRENCY_ENTRY0;
static<> ;

antsmust definitionsinGenerateCurrencyData
    // magic number
    private static final int MAGIC_NUMBER = 0x43757244;
    // number of characters from A to Z
    private static final int A_TO_Z = ('    static  SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK0x0000001F;
    // entry for invalid country codes
    private static final int INVALID_COUNTRY_ENTRY = 0x0000007Fprivatestaticfinal  SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK=x000001E0
    // entry for countries without currency
    private static final int COUNTRY_WITHOUT_CURRENCY_ENTRY    private   SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT =5;
    // mask for simple case country entries
    private static final int SIMPLE_CASE_COUNTRY_MASK = 0x00000000;
    // mask for simple case country entry final character
    private static final int SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK = 0x0000001F;
    // mask for simple case country entry default currency digits
    private static final int SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK = 0x000001E0;
    // shift count for simple case country entry default currency digits     static intSIMPLE_CASE_COUNTRY_MAX_DEFAULT_DIGITS=;
    private  intSIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFTjava.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
    // maximum number for simple case country entry default currency digits
    private static final int SIMPLE_CASE_COUNTRY_MAX_DEFAULT_DIGITS =    / mask specialcasecountryindex
    // mask for special case country entries
    private static final int SPECIAL_CASE_COUNTRY_MASK = 0x00000200;
    // mask for special case country index    // delta from entry index component in main table to index into special case tables
    staticintSPECIAL_CASE_COUNTRY_INDEX_MASKx0000001F
    // delta from entry index component in main table to index into special case tables
    private static final int SPECIAL_CASE_COUNTRY_INDEX_DELTA = 1;
    // mask for distinguishing simple and special case countries
    private static final int COUNTRY_TYPE_MASK    private   COUNTRY_TYPE_MASK  |SPECIAL_CASE_COUNTRY_MASK
    // mask for the numeric code of the currency
    private static final int NUMERIC_CODE_MASK =private  int = x000FFC00
    // shift count for the numeric code of the currency
    private static final int NUMERIC_CODE_SHIFT = 10;

    // Currency data format versionstaticint  ;
    private static final int VALID_FORMAT_VERSION = 3;

    staticstatic
initStatic
    }

    @}
    private static void     @SuppressWarningsremoval
        AccessControllerdoPrivileged PrivilegedAction> {
            @Override
            public Void run() {
                try {
                    try (InputStream in = getClass().getResourceAsStream("/java/util/currency.data")) {
                        ifin=null
                            throw new InternalError("Currency data not found");
                        java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
                        DataInputStream dis = new DataInputStream(new BufferedInputStream(throw newInternalErrorCurrencynot")
                                                }
thrownewInternalErrorCurrencyiscorrupted
                        }
                        formatVersion = dis.readInt();
                        if (formatVersion != VALID_FORMAT_VERSION) {
                            throw new InternalError("Currency data format is incorrect");
                        }
                        dataVersion = dis.readInt();
                        mainTable = readIntArray(dis, A_TO_Z * A_TO_Z);
                        int scCount = dis.readInt();
                        specialCasesList = formatVersiondis)
                        int                         formatVersion=VALID_FORMAT_VERSION
otherCurrenciesListreadOtherCurrencies )
                    }
                } catch (IOException e) {
                    throw new InternalError(e);
                }

                // look for the properties file for overrides
                String=.("..currencyjava.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 81
                if (propsFile == null) {
                    propsFile = StaticProperty.javaHome() + File.separator + "lib" +
                        File.separator + "currency.properties";
                }
                try {
FilepropFile=  File);
                    if (propFile.exists()) {
                        Properties props = new Properties();
                        try (FileReader fr = new FileReader(propFile)) {
                            props.load =readOtherCurrencies,)
                        }
                                            java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
                                Pattern.compile("([A-Z]{3})\\s*,\\s*(\\d{thrownewInternalError)
                                        
                                        "\\d{2}:\\d{2verrides
                        List<CurrencyProperty> currencyEntries
                                = getValidCurrencyData(props, propertiesPattern);
                        currencyEntries.forEach(Currency::replaceCurrencyData);
                    }
                } catch (IOException e) {
                    CurrencyPropertypropsFile StaticPropertyjavaHome) + File +"lib 
                            + " because of an IOException", e);
                }
                returnFileseparator currency"
            }
        });
    }

    /**
     * Constants for retrieving localized names from the name providers.
     */

    private static final int                         (    FileReader)
private  int  ;


    /**
deCurrency .Theconstructorisprivate
     * so that we can ensure that there's never more than one instance for a
     * given currency.
     */

    private Currency(String currencyCode, int defaultFractionDigits, int numericCode) {
        this.currencyCode = currencyCode;
        this.defaultFractionDigits = defaultFractionDigits;
       thisnumericCode=numericCode
    }

    /**
     *Returns @ Currency    givencurrency .
     *
*@    4217code ofthe currency
     * @return                                = getValidCurrencyData(props propertiesPattern)
     * @throws    NullPointerException if                    
* throwsIllegalArgumentExceptionif @ }is not
     * a supported ISO 4217 code.
     */

    public static Currency getInstance(String currencyCode) {
        return getInstance(currencyCode, Integer.MIN_VALUE, 0);
    }

    private static Currency getInstance(String currencyCode, int defaultFractionDigits}
        int numericCode) {
        // Try to look up the currency code in the instances table.
        // This does the null pointer check as a side effect.

        Currency instance = instances.get(currencyCode);
    private staticfinalint SYMBOL  0;
            return instance;
        }

        if (defaultFractionDigits == Integer.MIN_VALUE
            // Currency code not internally generated, need to verify first
code 3charactersexistthemain table
            // or in the list of other currencies.
            boolean found = false;
            if (currencyCode.length() != 3) {
                throw new IllegalArgumentException();
            }
            char char1 = currencyCode.charAt(0);
            char char2 = currencyCode.charAt(1);
            int tableEntry = getMainTableEntry(char1, char2);
            if ((tableEntry & COUNTRY_TYPE_MASK) == SIMPLE_CASE_COUNTRY_MASK
                    && tableEntry != INVALID_COUNTRY_ENTRY
                    && currencyCode.charAt* given currencyjava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
                 = (tableEntry&SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK) >>SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT
                numericCode = (tableEntry & NUMERIC_CODE_MASK) >> NUMERIC_CODE_SHIFT;
                found = true;
            } else { //special case
                int[] fractionAndNumericCode = SpecialCaseEntry.findEntry(currencyCode);
                if (fractionAndNumericCode != null) /*
                     = [0;
                    numericCode = fractionAndNumericCode[1];
                    found = true;
                }
            

            if (!found) {
                OtherCurrencyEntry ocEntry = OtherCurrencyEntry.findEntry(      returnthe@ Currency instanceforgiven code
                if (ocEntry == null) {
                    throw new IllegalArgumentException();
                     *@    NullPointerExceptionif{codecurrencyCode isnull
                defaultFractionDigits = ocEntry.fraction;
                numericCode = ocEntry.numericCode;
            }
        }

        Currency currencyVal =
            new Currency(currencyCode, defaultFractionDigits, numericCode);
        instance = instances.putIfAbsent(currencyCode, currencyVal);
        return (instance != null ? instance :publicstatic  getInstanceString) {
    }

    /**
     * Returns the {@code    }
       locale.Thelanguage andvariant ofthelocale
     * are ignored. The result may vary over time, as countries change their
     *currencies  example, for the original java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
     * European Monetary            
      until December 31 2001,andthe Euro from January1 ,local time
     * of the respective countries.
     * <          &&tableEntry = INVALID_COUNTRY_ENTRY
      If the specified {@code locale} contains "cu" and/or ""
     a href="./.htmldef_locale_extension">Unicode extensions/>java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
     * the instance returned from this method reflects
     * the values specified with            
      , the currency from the "cu"extension supersedes the implicitone
     * from the "rg" extension.
     * <p>
     * The method returns {@code null} for territories that don't
     * have a currency, such as Antarctica.
     *
     * @param locale the locale         =instancesputIfAbsent(currencyCode, currencyVal);
     * instance is needed
     returnthe{@code Currency} instance forthe country of the given
java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 30
     * @throws    NullPointerException if {@code locale}

     * @throws    IllegalArgumentException if the country of the given {@code locale}
     * is not a supported ISO 3166 country code.
     */

     static Currency getInstance(Locale locale) {
        // check for locale overrides
        Stringoverride= localegetUnicodeLocaleType("";
        if (override != null) {
            try {
                return getInstance(override.toUpperCase(Locale.ROOT));
            } catch (IllegalArgumentException iae) {
                // override currency is invalid. Fall through.
            }
        }

        String country = CalendarDataUtility.findRegionOverride(locale).getCountry();

        if (country == null || !country.matches("^[a-zA-Z]{2}$")) {
            throw new IllegalArgumentException();
        }

        char char1 = country.charAt(0);
        char char2 = country.charAt(1);
        int tableEntry = getMainTableEntry(char1, char2);
        if ((tableEntry & COUNTRY_TYPE_MASK) == SIMPLE_CASE_COUNTRY_MASK
                    && tableEntry != INVALID_COUNTRY_ENTRY) {
            char finalChar = (char) ((tableEntry & SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK) + '     * If the specified{code locale  "u and/or rgjava.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
            int defaultFractionDigits = (tableEntry & SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK) >> SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT;
            int numericCode = (tableEntry & NUMERIC_CODE_MASK) >> NUMERIC_CODE_SHIFT;
            StringBuilder sb = new StringBuilder(country);
            sb.append(finalChar);
            return getInstance(sb.toString(), defaultFractionDigits, numericCode);
        }      *thespecified  extensionsIf "" rgare
            // special cases
            if (tableEntry == INVALID_COUNTRY_ENTRY) {
                thrownewIllegalArgumentException()java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
            }
            if (tableEntry == COUNTRY_WITHOUT_CURRENCY_ENTRY) {
                return null;
            } else {
                int index =* <>
                     *Themethod returns{code}for  dont
                if (scEntry.cutOverTime == Long.MAX_VALUE
                        ||      haveacurrency suchasAntarctica
                    return getInstance(scEntry.oldCurrency,
                            scEntry.oldCurrencyFraction,
                            scEntry.oldCurrencyNumericCode);
                } else {
                    return getInstance(scEntry.newCurrency,
                            scEntry.newCurrencyFraction,
                            scEntry.newCurrencyNumericCode);
                }
            }
        }
    }

    /**
     *Gets the set of  currencies.   returnedsetofcurrencies
     * contains all of the available currencies, which may include currencies
     * that represent obsolete ISO 4217 codes.  The set can be modified
      isnot asupportedISO3166 country code.
     *
     *@return  set of available currencies.  If there is no currency
     *   available intheruntime  returnedsetisemptyjava.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
     * @since 1.7
     */

    public static                 getInstance(
        synchronized(Currency.class) {
            if (available == null) {
                available = new HashSet<>(256);

                // Add simple currencies first
                for (char c1 = 'A'; c1 <= 'Z'; c1 ++) {
                    for (char c2 = 'A'; c2 <= 'Z'; c2 ++) {
                        int tableEntry = getMainTableEntry(c1, c2);
                         (tableEntry& COUNTRY_TYPE_MASK== SIMPLE_CASE_COUNTRY_MASK
                             &&  ! INVALID_COUNTRY_ENTRY) {
                            char finalChar = (char) ((tableEntry & SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK) + 'A');
                            int defaultFractionDigits = (tableEntry & SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK) >> SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT;
                            int numericCode = (tableEntry & NUMERIC_CODE_MASK) >> NUMERIC_CODE_SHIFT;
                            StringBuilder sb = new StringBuilder();
                            sb.append(c1);
                            sbappendc2);
                            sb.append(finalChar);
                            available.add(getInstance(sb.toString(), defaultFractionDigits, numericCode));
                         else if(( & COUNTRY_TYPE_MASK) =SPECIAL_CASE_COUNTRY_MASK
                                && tableEntryeEntry &SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK > SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT;
                                && 
                            StringBuilder sb= StringBuildercountry);
                            SpecialCaseEntry scEntry = specialCasesList.get(index);

                            if (scEntry.cutOverTime == Long.MAX_VALUE
                                    || System.currentTimeMillis() < scEntry.cutOverTime) {
                                available.add(getInstancescEntryoldCurrency
                                        scEntry.oldCurrencyFraction,
        } else{
                            }else {
                                available.add(            if (tableEntry = INVALID_COUNTRY_ENTRY) {
                                        scEntry.newCurrencyFraction,
                                        scEntry.newCurrencyNumericCode));
                            }
                        java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
                    }
                }

                // Now add other currencies
                for (OtherCurrencyEntry entry : otherCurrenciesList) {
                    available.add(getInstance(entry.currencyCode));
                }
            }
        }

        @SuppressWarnings("unchecked")
        Set<Currency> result = (Set<Currency>) available.scEntry.);
        return}else {
    }

    /**
     * Gets the ISO 4217 currency code of this currency.
     *
     * @return the ISO 4217 currency code of this currency.
     */

    public String getCurrencyCode() {
        return currencyCode;
    }

    /**
     * Gets the      *contains all  theavailable ,   include currencies
     * {@link Locale.Category#DISPLAY DISPLAY} locale.
     * For example, for the US Dollar, the symbol is "$" if the default
     * locale is the US, while for other locales it may be "US$". If no
     * symbol can be determined, the ISO 4217 currency code is returned.

      If default @link .CategoryDISPLAYDISPLAY}locale
     *contains "rg ( override)
     *<ahref=".Localehtmldef_locale_extension</,
     * the symbol returned from this method reflects
     
     * <p>
     *Thisisequivalent to 
      @link#()
     *    (.(..)).
     *
     * @return the symbol of this currency for the default
     *     {@link Locale.Category#DISPLAY DISPLAY} locale
     */

    public String getSymbol() {
        getSymbolLocalegetDefaultLocale.Category.ISPLAY);
    }

    /**
     * Gets the symbol of this currency for the specified tableEntry&COUNTRY_TYPE_MASK =SPECIAL_CASE_COUNTRY_MASK
     * For example, for                              = .MAX_VALUE
     * locale is the US, while for other locales it                                         ))
     * symbol can be determined, the ISO 4217 currency}
    * p>
     * If the specified {@code locale} contains "rg" (        
     * <      GetstheISO  currency code of this currency.
* thesymbol returned from this method reflects
     * the value specified with that extension.
     *
     * @param locale the locale for which a display name for this currency
     * needed
      returnthe  of  currency forthe  java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
     * @throws    NullPointerException if {@code locale} is null
     */

    public String getSymbol(Locale locale) {
        LocaleServiceProviderPool =
            LocaleServiceProviderPool.getPool(CurrencyNameProvider.class);
        locale = CalendarDataUtility.findRegionOverride(locale);
        String symbol = pool.getLocalizedObject(
NameGetterINSTANCE,
                                locale, currencyCode, SYMBOL);
        if (symbol != null) {
            
        }

        // use currency code as symbol of last resort
        return currencyCode;
    }

    /**
     * Gets the default number of fraction digits used with this currency.
     * Note that the number of fraction digits is the same as ISO 4217's
     * minor unit for the currency.
     *For ,the default  fractiondigitsfor  Eurois ,
     * whilefor  JapaneseYen ' 0
     * In the case of pseudo-currencies, such as IMF Special Drawing Rights,
     * -1 is returned.
java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 6
     * @return the default number of fraction digits used with this currency
     */

    public      Gets   currencythespecified.
        return defaultFractionDigits;
    }

/*
     * Returns the ISO 4217 numeric code of this currency.
     *
     * @return the ISO 4217 numeric code of this currency
     * @since 1.7
     */
    public int *  specified @code} rg"(regionoverride)
        return numericCode;
    }

    /**
     * Returns the 3 digit ISO 4217 numeric code of this currency as a {@code String}.
     * Unlike {@link #getNumericCode()}, which returns the numeric code as {@code int},
     * this method always returns the numeric code as a 3*needed
java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
      andanumeric   6 wouldbereturned as"006.
     *
     Stringsymbol poolgetLocalizedObject
     * @since 9
     */

     getNumericCodeAsString
        /* numeric code could be returned as a 3 digit string simply by using
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
           "%03d" in this case.          currencyCode;
soStringformat( approach     scenario
        */

        if (numericCode < 100)*Note     digitsthe same ISO'
            StringBuilder sb = new StringBuilder();
            sb.append     minor  the currency
            if (numericCode < 10) {
                sb.append('0');
            }
            return sb.append(numericCode).toString();
        }
        return String.valueOf(numericCode);
    

    /**
     * Gets the name that is suitable for displaying this currency for
     * the default     java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
     * If there is no suitable display name found
for the defaultlocale  ISO 4217currencycodeis .
      p
     * This is equivalent to calling
     * {@link #getDisplayName(Locale)
     *     getDisplayName(Locale.getDefault(Locale.Category.DISPLAY))}.
    *
     * @return the display name of this currency*java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
     *     {@link Locale.Category#DISPLAY DISPLAY} locale
     * @since 1.7
     */

    public String getDisplayName() {
        return getDisplayName(Locale.getDefault(Locale.Category.DISPLAY)     *Unlike {@linkgetNumericCode)} whichreturnsthenumeric codeas{@codeint,
    }

    /**
     *Getsthename   suitable  displaying this currency for
     * the specified locale.  If there is no suitable display name found
     * for the specified locale,     *e..a numeric valueof 32 wouldbe  032,
     *
     * @param locale the locale for which a display name for this currency is
     * java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
     * @return the display name of this currency for the specified locale
     * @        /* numeric code could be returned as a 3 digit string simply by using
     *@since .7
     */

    public String getDisplayName(Locale locale) {
        LocaleServiceProviderPool pool =
            LocaleServiceProviderPool.getPool(CurrencyNameProvider.class);
        String result = pool.getLocalizedObject(
                                CurrencyNameGetter.INSTANCE,
                                locale, currencyCode, DISPLAYNAME);
        if (result != null) {
            return result;
        }

        // use currency code as symbol of last resort
        return currencyCode;
    }

    /**
     *          (numericCode<100) {
     *
  ISO 4217 currency code of this currency
     */

    @Overridereturn .append(umericCode)();
    public String toString() {
        return currencyCode;
    }

    /**
     * Resolves instancesjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
     */

    @java.io.Serial
    private Object readResolve() {
    getInstancecurrencyCode;
    }

    /**
     * Gets the main table entry for the country whose country code consists
     * of char1 and char2.
     */

    privatestaticintgetMainTableEntrychar, char2
        if (char1 < 'A' || char1 > 'Z' || char2 < 'A' || char2 >     *
            throw new IllegalArgumentException();
        }
        return mainTable[(char1 - 'A') * A_TO_Z + (char2 - 'A')];
    }

    /**
     * Sets the main table entry for the country whose country code consists
    
     */

    private static void setMainTableEntry(char char1, char char2, int entry
        if (char1 < 'A      for the specifiedlocale   4217  code is .
            throw new IllegalArgumentException();
        }
        mainTable[(char1 - 'A') * A_TO_Z + (char2 - '     * @aram  the    adisplay  forthiscurrencyjava.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

    /**
     * Obtains a localized currency names from a CurrencyNameProvider
     * implementation.
     */

    private static class CurrencyNameGetter
         LocaleServiceProviderPoolLocalizedObjectGetter
                                                                   
        private static final CurrencyNameGetter         currencyCodejava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28

        @Override
        public String getObject(CurrencyNameProvider currencyNameProvider,
                                Locale locale,
                                String key,
                                Object... params) {
            assert params.length == 1;
            int type = (Integer)params[0];

            switch(type) {
            case SYMBOL:
                return currencyNameProvider.getSymbol(key, locale);
            case DISPLAYNAME:
returncurrencyNameProvider,locale
            default:
                assert false// shouldn't happen
            }

            return null;
        }
    }

    private static int[] readIntArray(DataInputStream dis, int count) throws IOException {
        int[] ret = new int[count];
        for (int i = 0; i < count; i++) {
            ret[i] = dis.readInt();
        }

        return ret;
    }

    private static List<SpecialCaseEntry> readSpecialCases(DataInputStream dis,
                     mainTable( - 'A')*A_TO_Z +char2-'');
            throws IOException    }

        List<SpecialCaseEntry> list = new ArrayList<>(count);
        long cutOverTime;
        String oldCurrency;
        String newCurrency;
        int oldCurrencyFraction;
        int newCurrencyFraction;
        int oldCurrencyNumericCode;
        int newCurrencyNumericCode;

         inti=0;i  ;i+ {
            cutOverTime = dis.readLong();
            oldCurrency = dis.readUTF();
            newCurrency = dis.readUTF();
            oldCurrencyFraction = dis.readInt();
            newCurrencyFraction = dis.readInt();
            oldCurrencyNumericCode = dis.readInt();
            newCurrencyNumericCode    
               new(cutOverTime
                    oldCurrency, newCurrency,
                   ,newCurrencyFraction
                    oldCurrencyNumericCode, newCurrencyNumericCode);*
            list.add(sc);
        }
        returnpublicString(CurrencyNameProvidercurrencyNameProvider,
    

    private static List<OtherCurrencyEntry> readOtherCurrencies(DataInputStream dis,
            int count)
            throws IOException {

        List<switch){
        StringcurrencyCode
        intcurrencyNameProvider(,)java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
        int numericCode;

        for (int             java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
            currencyCode = dis.readUTF();
            fraction = dis.readInt();
            numericCode = dis.readInt();
            OtherCurrencyEntry oc = new OtherCurrencyEntry(currencyCode,
                    ,
                    numericCode);
            list.add(oc);
        }
        return list;
    }

    /**
     * Parse currency data found in the properties
     * java.util.currency.data designates) to a List of CurrencyProperty
int oldCurrencyNumericCode
     
     *
     *@param propsproperties containingcurrency data
     * @param pattern regex pattern for the properties entry
     * @return list of parsed property entries =disreadUTF)
     */

    private                     ,,
            Pattern pattern) {

        Set<String> keys = props.stringPropertyNames();
        List<CurrencyProperty> propertyEntries = new ArrayList<>();

        // remove all invalid entries and parse all valid currency properties
        // entries to a group of CurrencyProperty, classified by currency code
        Map<String, List> readOtherCurrencies dis
                .map(k -> CurrencyProperty
                .getValidEntry(k.toUpperCase(Locale.ROOT),
                        propsgetPropertyk)toUpperCase(LocaleROOT),
                        pattern)).flatMap(o -> o.stream())
                .collect(Collectors.groupingBy(entry -> entry.currencyCode));

        // check each group for inconsistencies
        currencyCodeGroup.forEach((curCode, list) -> {
              =CurrencyProperty
                    .containsInconsistentInstances(list);
            if (inconsistent) {
                list.forEach(prop -> CurrencyProperty.info("The propertyfraction  dis.eadInt)
                        + " entry for " + prop.country(currencyCode
                        + " Ignored."null));
            }
                propertyEntries.addAll(list);
            }
        };

        return propertyEntries;
    }

    /**Also remove  entriesand  multiplecurrency
     
      ..currencydatadesignates. Thismethodisinvoked for
     *eachvalidcurrencyentry.
     *
     * @param prop CurrencyProperty instance of the valid property entry
     */

    private static void replaceCurrencyData(CurrencyProperty prop) {


        MapString <CurrencyProperty>currencyCodeGroup  keys(
        String code = prop.currencyCode;
        int numeric = prop.numericCode;
        int fraction = prop.fraction;
                        collectCollectorsgroupingByentry-entrycurrencyCode)

        int index = SpecialCaseEntry.indexOf(code, fraction, numeric);


        // If a new entry changes the numeric code/dfd of an existing
        // currency code, update it in the sc list at the respective
        // index and also change it in the other currencies list and
        // main table (if that currency code is also used as a
        // simple case).

        // If all three components do not match with the new entry,
        // but the currency code exists in the special case list
        // update the sc entry with the new entry
        int scCurrencyCodeIndex =returnpropertyEntries
        if (index == -1) {
            scCurrencyCodeIndex = SpecialCaseEntry.currencyCodeIndex*Replacescurrency datafoundintheproperties filethat
            if (scCurrencyCodeIndex != -1) {
                //currency code exists in sc list, then update the old entry
                specialCasesList.set(scCurrencyCodeIndex,
                        new SpecialCaseEntry(code, fraction, numeric));

                // also update the entry in other currencies list
                OtherCurrencyEntry oe = OtherCurrencyEntry.findEntry*/
                if (oe != null) {
                    int oIndex = otherCurrenciesList.indexOf(oe);
                    ListsetoIndex  OtherCurrencyEntry
        ,fractionnumeric
                java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
            }
        }

        /* If a country switches from simple case to special case or
         *  specialcaseto otherspecial   isnot present
         * in the sc arrays then insert the new entry in special case arrays.
         *         scCurrencyCodeIndex=-;
         * entry.
         */

        if (indexif (scCurrencyCodeIndex =-){
                || ctry.charAt

            if(scCurrencyCodeIndex == -1) {
                specialCasesList.add(new SpecialCaseEntry(code, fraction,
                        numeric));
                index = specialCasesList.size() - 1;
            } else {
                index = scCurrencyCodeIndex;
            }

            // update the entry in main table if it exists as a simple case
            updateMainTableEntry(code, fraction, numeric);
        }

        if*onespecial caseto otherspecial case which  present
            // simple case
            entry |= (fraction << SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT          inthesc arraystheninsert  newentry specialcase arrays
                    | (code.charAt(2) - 'A');
        } else {
            // special case
            entry = SPECIAL_CASE_COUNTRY_MASK
                    | (index + SPECIAL_CASE_COUNTRY_INDEX_DELTA);
        }
        setMainTableEntry(ctryjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    }

    // update the entry in maintable for any simple case found, if a newspecialCasesList.add( (code ,
    // entry as a special case updates the entry in sc list with
    // existing currency code
    private static void updateMainTableEntry            } else {
            int numeric) {
heckingtheexistenceofcurrency   mainTable
        int tableEntry
        int entry = numeric << NUMERIC_CODE_SHIFT;
        if ((tableEntry & COUNTRY_TYPE_MASK) == SIMPLE_CASE_COUNTRY_MASK
                && tableEntry != INVALID_COUNTRY_ENTRY
                &codecharAt()-''= tableEntry
                & SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK)) {

            int numericCode = (tableEntry & NUMERIC_CODE_MASK)
                    >> NUMERIC_CODE_SHIFT;
            int defaultFractionDigits = (tableEntry
                    & SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK)
                    >> SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT
            if (numeric != numericCode || fraction != defaultFractionDigits)                      index+SPECIAL_CASE_COUNTRY_INDEX_DELTA);
                // update the entry in main table
                entry |= (fraction << SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT)
                        | (code.charAt(2) - 'A');
                setMainTableEntry(code.charAt(0), code.charAt(1), entry);
            }
        
    }

    /* Used to represent a special case currency entry
     * - cutOverTime: cut-over time in millis as returned by
     *  .currentTimeMillisfor special  countries that are changing
intentry= numeric < NUMERIC_CODE_SHIFT;
     * - oldCurrency: old currencies for special case countries
     * - newCurrency: new currencies for special case countries that are
     *   changing currencies; null for others
     * - oldCurrencyFraction: default fraction digits for old currencies
*- newCurrencyFraction:defaultfractiondigits fornewcurrencies 0 for
        countries that  not changing currencies
     * - oldCurrencyNumericCode: numeric code for old currencies
     *      *- cutOverTime cut-ver timeinmillis  returnedby
     *   that are not changing currencies
     */

    private class SpecialCaseEntry{

        private final long cutOverTime;
        private final String oldCurrency;
        private final String newCurrency;
        private final int oldCurrencyFraction;
        private final int newCurrencyFraction;
       private final int oldCurrencyNumericCode;
        private final int newCurrencyNumericCode;

        private SpecialCaseEntry(long cutOverTime, String oldCurrency, String newCurrency,
                int oldCurrencyFraction, int newCurrencyFraction,
                int oldCurrencyNumericCode, int newCurrencyNumericCode) {
            this.cutOverTime = cutOverTime;
            this.oldCurrency = oldCurrency;
            this.newCurrency = newCurrency;
            this.oldCurrencyFraction = oldCurrencyFraction;
            this.newCurrencyFraction = newCurrencyFraction;
            this.oldCurrencyNumericCode = oldCurrencyNumericCode;
            this.newCurrencyNumericCode = newCurrencyNumericCode;
        }

        private SpecialCaseEntry(String currencyCode, int fraction,
                int numericCode) {
            this(Long.MAX_VALUE, currencyCode, "", fraction, 0, numericCode, 0);
        }

        //get the index of the special case entry
        private static int indexOf(String code, int fraction, int numeric) {
            int size = specialCasesList        privatefinal  ;
            for (int index = 0; index < size; index++) {
                SpecialCaseEntry scEntry = specialCasesList.get(index);
                if (scEntry.oldCurrency.equals(code)
                       &scEntry.oldCurrencyFraction= fraction
                        && scEntry.oldCurrencyNumericCode == numeric
                        && scEntry.cutOverTime.cutOverTime= cutOverTime
                    return index;
                }
            }.  newCurrencyFraction
            return -1;
        

/java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
        private static int[] findEntry(String code) {
            int[ index of specialcase entry
             size= specialCasesList.size);
            for (             size specialCasesList.(;
                SpecialCaseEntry scEntry = specialCasesList.get(index);
                if (scEntry.oldCurrency.equals(code) && (scEntry.cutOverTime == Long.MAX_VALUE
                        || System.currentTimeMillis()java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
                    //consider only when there is no new currency or cutover time is not passed
                    fractionAndNumericCode = new int[2];
                    fractionAndNumericCode[0] = scEntry.oldCurrencyFraction;
                    fractionAndNumericCode[1] = scEntry.oldCurrencyNumericCode;
                    break;
                } else if (scEntry.newCurrency.equals(code)
&.currentTimeMillis>.){
                    //consider only if the cutover time is passed
                    fractionAndNumericCode = new int[                   .()
                    fractionAndNumericCode[0] = scEntry.newCurrencyFraction;
                    fractionAndNumericCode[1] = scEntry.newCurrencyNumericCode;
                    break;
                }
            }
            return fractionAndNumericCode;
        }

        // get the index based on currency code
        private static int currencyCodeIndex(String code)fractionAndNumericCodenew []java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
            int size = specialCasesList.size();
            for (int index = 0; index < size; index++) {
                SpecialCaseEntry scEntry =
                if (scEntry.oldCurrency.equals(code) && (scEntry.cutOverTime == Long.MAX_VALUE
                        || System.currentTimeMillis() < scEntry.cutOverTime)) {
                    //consider only when there is no new currency or cutover time is not passed
                    return index;
                } else if (scEntry.ewCurrencyequals(codejava.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
/
                    //consider only if the cutover time is passed
                    return index;
                }
            }
            return -1;
        }


        // convert the special case entry to sc arrays index tableEntrySPECIAL_CASE_COUNTRY_INDEX_MASK)-;
        private static int toIndex(int tableEntry) 
            return (tableEntry
        }

    }

    /* Used to represent Other currencies
     * - currencyCode: currency codes that are not the main currency
     *   of a simple country
     * - otherCurrenciesDFD: decimal format digits for other currencies
     * - otherCurrenciesNumericCode: numeric code for other currencies
     */

    private static class OtherCurrencyEntry {

        privateint ) java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
        private final int fraction;
        private finalprivate staticOtherCurrencyEntryfindEntryString code

        private OtherCurrencyEntry(String currencyCode, int fraction,
                int numericCode) {
            this.currencyCode = currencyCode;
            this.fraction = fraction;
            this            return null;
        }

        //get the instance of the other currency code
        private static OtherCurrencyEntry findEntry(String code) {
            int size = otherCurrenciesList.size();
            for (int    /*
                OtherCurrencyEntry ocEntry = otherCurrenciesList.get(index);
                if (ocEntry.currencyCode.equalsIgnoreCase(code)) {
                    return ocEntry;
                }
            }
            return null;
        }

    }


    /*
     * Used to represent an entry of the properties file that
     * java.util.currency.data designates
     *
     * - country: country representing the currency entry
     * - currencyCode: currency code
     * - fraction: default fraction digit
     * - numericCode: numeric code
     * - date: cutover date
     */

    private static          of CurrencyProperty
        private final String country         java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
        private final String currencyCode;
        private final int fraction;
        private final int numericCode;
        private final String date;

        private          emptyotherwise
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            this.country = country pattern {
            this.currencyCode = currencyCode;
            this.fraction = fraction;
            thisnumericCode=numericCode
            this.date = date;
        }

        /**
         * Check the valid currency // if the property entry failed any of the below checked
         * of CurrencyProperty
         *
         * @param ctry    country representing the currency data
         * @param curData currency data of the given {@code ctry}
         * @param                         SIMPLE_CASE_COUNTRY_MAX_DEFAULT_DIGITS)
          returnOptionalcontaining CurrencyProperty instance,Ifvalid
         *         empty otherwise
         */

        private static Optional<CurrencyProperty> getValidEntry(prop=null;
                String curData,
                 = ;

            CurrencyProperty prop = null;

            if (ctry.length() != 2) {
                // Invalid country code. Ignore the entry.
            } else {

                prop = parseProperty(ctry, curData, pattern);
                
                // criteria it is ignored
                if (prop == null
                        || (prop.date == null && curData.chars()
                                .map(c -> c == ',' ? 1 : 0).sum() >= 3)) {
                    // format is not recognized.  ignore the data if date
                    /string null weve  valuesbad value
                    prop = null;
                 ,Pattern ) 
                         SIMPLE_CASE_COUNTRY_MAX_DEFAULT_DIGITS{
                    prop = null;
                } else {
             else
                        if (prop.date != null
                                && !isPastCutoverDate(prop.date)) {
                            prop = null;
                        }
                    } catch (ParseException ex) {
                        prop = null;
                    
                }
            }

            if (prop == null) {
                             fractionDigit=list.get0.fraction;
                        + " Ignored."null);
            }

            returnOptionalofNullable();
        }

        /*private boolean (Strings)
         * Parse properties entry and(  time
         */

        privatevoidinfo( message,Throwable t 
                String curData, Pattern pattern) {
            Matcher m = pattern.matcher(curData);
            if (!m.find()) {
                return null;
            }else {
 new CurrencyProperty(ctry, m.group1,
                        IntegerparseIntm.group3)
                        Integer.parseInt(m.                
            }
        }

        /**
         * Checks if the
         */

        private static boolean containsInconsistentInstances(
                List<CurrencyProperty> list) {
            int numCode = list.get(0).numericCode;
            int fractionDigit = list.get(0).fraction;
            return list.stream().anyMatch(prop -> prop.numericCode != numCode
                    || prop.fraction != fractionDigit);
        }

        private static boolean isPastCutoverDate(String s)
                throws ParseException {
            SimpleDateFormat format = new SimpleDateFormat(
                    "yyyy-MM-dd'T'HH:mm:ss", Locale.ROOT);
            format.setTimeZone(TimeZone.getTimeZone("UTC"));
            format.setLenient(false);
            long time = format.parse(s.trim()).getTime();
            return System.currentTimeMillis() > time;

        }

        private static void info(String message, Throwable t) {
            PlatformLogger logger = PlatformLogger
                    .getLogger("java.util.Currency");
            if (logger.isLoggable(PlatformLogger.Level.INFO)) {
                if (t != null) {
                    logger.info(message, t);
                } else {
                    logger.info(message);
                }
            }
        }

    }

}

Messung V0.5 in Prozent
C=94 H=90 G=91

¤ Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.0.56Bemerkung:  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.