src/java.base/share/classes/java/text/DecimalFormatSymbols.java
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 58242 94bb65cb37d3
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
     2
 * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 *   The original version of this source code and documentation is copyrighted
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * materials are provided under terms of a License Agreement between Taligent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * and Sun. This technology is protected by multiple US and International
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * patents. This notice and attribution to Taligent may not be removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *   Taligent is a registered trademark of Taligent, Inc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
package java.text;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
    41
import java.io.InvalidObjectException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import java.text.spi.DecimalFormatSymbolsProvider;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import java.util.Currency;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import java.util.Locale;
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
    48
import java.util.Objects;
48251
57148c79bd75 8176841: Additional Unicode Language-Tag Extensions
naoto
parents: 47216
diff changeset
    49
import sun.util.locale.provider.CalendarDataUtility;
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
    50
import sun.util.locale.provider.LocaleProviderAdapter;
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
    51
import sun.util.locale.provider.LocaleServiceProviderPool;
15260
7af2d7a87806 7162007: Clean up i18n related caches
naoto
parents: 14336
diff changeset
    52
import sun.util.locale.provider.ResourceBundleBasedAdapter;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * This class represents the set of symbols (such as the decimal separator,
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
    56
 * the grouping separator, and so on) needed by {@code DecimalFormat}
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
    57
 * to format numbers. {@code DecimalFormat} creates for itself an instance of
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
    58
 * {@code DecimalFormatSymbols} from its locale data.  If you need to change any
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
    59
 * of these symbols, you can get the {@code DecimalFormatSymbols} object from
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
    60
 * your {@code DecimalFormat} and modify it.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *
48251
57148c79bd75 8176841: Additional Unicode Language-Tag Extensions
naoto
parents: 47216
diff changeset
    62
 * <p>If the locale contains "rg" (region override)
57148c79bd75 8176841: Additional Unicode Language-Tag Extensions
naoto
parents: 47216
diff changeset
    63
 * <a href="../util/Locale.html#def_locale_extension">Unicode extension</a>,
57148c79bd75 8176841: Additional Unicode Language-Tag Extensions
naoto
parents: 47216
diff changeset
    64
 * the symbols are overridden for the designated region.
57148c79bd75 8176841: Additional Unicode Language-Tag Extensions
naoto
parents: 47216
diff changeset
    65
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * @see          java.util.Locale
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * @see          DecimalFormat
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * @author       Mark Davis
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * @author       Alan Liu
45434
4582657c7260 8181082: class-level since tag issues in java.base & java.datatransfer module
mli
parents: 34774
diff changeset
    70
 * @since 1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
public class DecimalFormatSymbols implements Cloneable, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    /**
16010
2727163b5df5 7092447: Clarify the default locale used in each locale sensitive operation
naoto
parents: 15260
diff changeset
    76
     * Create a DecimalFormatSymbols object for the default
2727163b5df5 7092447: Clarify the default locale used in each locale sensitive operation
naoto
parents: 15260
diff changeset
    77
     * {@link java.util.Locale.Category#FORMAT FORMAT} locale.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * This constructor can only construct instances for the locales
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * supported by the Java runtime environment, not for those
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * supported by installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * {@link java.text.spi.DecimalFormatSymbolsProvider DecimalFormatSymbolsProvider}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * implementations. For full locale coverage, use the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * {@link #getInstance(Locale) getInstance} method.
16010
2727163b5df5 7092447: Clarify the default locale used in each locale sensitive operation
naoto
parents: 15260
diff changeset
    84
     * <p>This is equivalent to calling
2727163b5df5 7092447: Clarify the default locale used in each locale sensitive operation
naoto
parents: 15260
diff changeset
    85
     * {@link #DecimalFormatSymbols(Locale)
2727163b5df5 7092447: Clarify the default locale used in each locale sensitive operation
naoto
parents: 15260
diff changeset
    86
     *     DecimalFormatSymbols(Locale.getDefault(Locale.Category.FORMAT))}.
2727163b5df5 7092447: Clarify the default locale used in each locale sensitive operation
naoto
parents: 15260
diff changeset
    87
     * @see java.util.Locale#getDefault(java.util.Locale.Category)
2727163b5df5 7092447: Clarify the default locale used in each locale sensitive operation
naoto
parents: 15260
diff changeset
    88
     * @see java.util.Locale.Category#FORMAT
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    public DecimalFormatSymbols() {
6489
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
    91
        initialize( Locale.getDefault(Locale.Category.FORMAT) );
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * Create a DecimalFormatSymbols object for the given locale.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * This constructor can only construct instances for the locales
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * supported by the Java runtime environment, not for those
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * supported by installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * {@link java.text.spi.DecimalFormatSymbolsProvider DecimalFormatSymbolsProvider}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * implementations. For full locale coverage, use the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * {@link #getInstance(Locale) getInstance} method.
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   102
     * If the specified locale contains the {@link java.util.Locale#UNICODE_LOCALE_EXTENSION}
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   103
     * for the numbering system, the instance is initialized with the specified numbering
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   104
     * system if the JRE implementation supports it. For example,
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   105
     * <pre>
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   106
     * NumberFormat.getNumberInstance(Locale.forLanguageTag("th-TH-u-nu-thai"))
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   107
     * </pre>
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   108
     * This may return a {@code NumberFormat} instance with the Thai numbering system,
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   109
     * instead of the Latin numbering system.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     *
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   111
     * @param locale the desired locale
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 57956
diff changeset
   112
     * @throws    NullPointerException if {@code locale} is null
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    public DecimalFormatSymbols( Locale locale ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        initialize( locale );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * Returns an array of all locales for which the
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   120
     * {@code getInstance} methods of this class can return
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * localized instances.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * The returned array represents the union of locales supported by the Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * runtime and by installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * {@link java.text.spi.DecimalFormatSymbolsProvider DecimalFormatSymbolsProvider}
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   125
     * implementations.  It must contain at least a {@code Locale}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * instance equal to {@link java.util.Locale#US Locale.US}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     *
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   128
     * @return an array of locales for which localized
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   129
     *         {@code DecimalFormatSymbols} instances are available.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    public static Locale[] getAvailableLocales() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        LocaleServiceProviderPool pool =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            LocaleServiceProviderPool.getPool(DecimalFormatSymbolsProvider.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        return pool.getAvailableLocales();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    /**
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   139
     * Gets the {@code DecimalFormatSymbols} instance for the default
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   140
     * locale.  This method provides access to {@code DecimalFormatSymbols}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * instances for locales supported by the Java runtime itself as well
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * as for those supported by installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * {@link java.text.spi.DecimalFormatSymbolsProvider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * DecimalFormatSymbolsProvider} implementations.
16010
2727163b5df5 7092447: Clarify the default locale used in each locale sensitive operation
naoto
parents: 15260
diff changeset
   145
     * <p>This is equivalent to calling
2727163b5df5 7092447: Clarify the default locale used in each locale sensitive operation
naoto
parents: 15260
diff changeset
   146
     * {@link #getInstance(Locale)
2727163b5df5 7092447: Clarify the default locale used in each locale sensitive operation
naoto
parents: 15260
diff changeset
   147
     *     getInstance(Locale.getDefault(Locale.Category.FORMAT))}.
2727163b5df5 7092447: Clarify the default locale used in each locale sensitive operation
naoto
parents: 15260
diff changeset
   148
     * @see java.util.Locale#getDefault(java.util.Locale.Category)
2727163b5df5 7092447: Clarify the default locale used in each locale sensitive operation
naoto
parents: 15260
diff changeset
   149
     * @see java.util.Locale.Category#FORMAT
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   150
     * @return a {@code DecimalFormatSymbols} instance.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    public static final DecimalFormatSymbols getInstance() {
6489
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   154
        return getInstance(Locale.getDefault(Locale.Category.FORMAT));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    /**
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   158
     * Gets the {@code DecimalFormatSymbols} instance for the specified
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   159
     * locale.  This method provides access to {@code DecimalFormatSymbols}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * instances for locales supported by the Java runtime itself as well
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * as for those supported by installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * {@link java.text.spi.DecimalFormatSymbolsProvider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * DecimalFormatSymbolsProvider} implementations.
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   164
     * If the specified locale contains the {@link java.util.Locale#UNICODE_LOCALE_EXTENSION}
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   165
     * for the numbering system, the instance is initialized with the specified numbering
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   166
     * system if the JRE implementation supports it. For example,
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   167
     * <pre>
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   168
     * NumberFormat.getNumberInstance(Locale.forLanguageTag("th-TH-u-nu-thai"))
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   169
     * </pre>
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   170
     * This may return a {@code NumberFormat} instance with the Thai numbering system,
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   171
     * instead of the Latin numbering system.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   172
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * @param locale the desired locale.
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   174
     * @return a {@code DecimalFormatSymbols} instance.
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 57956
diff changeset
   175
     * @throws    NullPointerException if {@code locale} is null
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    public static final DecimalFormatSymbols getInstance(Locale locale) {
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   179
        LocaleProviderAdapter adapter;
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   180
        adapter = LocaleProviderAdapter.getAdapter(DecimalFormatSymbolsProvider.class, locale);
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   181
        DecimalFormatSymbolsProvider provider = adapter.getDecimalFormatSymbolsProvider();
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   182
        DecimalFormatSymbols dfsyms = provider.getInstance(locale);
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   183
        if (dfsyms == null) {
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   184
            provider = LocaleProviderAdapter.forJRE().getDecimalFormatSymbolsProvider();
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   185
            dfsyms = provider.getInstance(locale);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        }
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   187
        return dfsyms;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * Gets the character used for zero. Different for Arabic, etc.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   192
     *
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   193
     * @return the character used for zero
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    public char getZeroDigit() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        return zeroDigit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * Sets the character used for zero. Different for Arabic, etc.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   201
     *
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   202
     * @param zeroDigit the character used for zero
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    public void setZeroDigit(char zeroDigit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        this.zeroDigit = zeroDigit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * Gets the character used for thousands separator. Different for French, etc.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   210
     *
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   211
     * @return the grouping separator
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    public char getGroupingSeparator() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        return groupingSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * Sets the character used for thousands separator. Different for French, etc.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   219
     *
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   220
     * @param groupingSeparator the grouping separator
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    public void setGroupingSeparator(char groupingSeparator) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        this.groupingSeparator = groupingSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * Gets the character used for decimal sign. Different for French, etc.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   228
     *
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   229
     * @return the character used for decimal sign
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    public char getDecimalSeparator() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        return decimalSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * Sets the character used for decimal sign. Different for French, etc.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   237
     *
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   238
     * @param decimalSeparator the character used for decimal sign
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    public void setDecimalSeparator(char decimalSeparator) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        this.decimalSeparator = decimalSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * Gets the character used for per mille sign. Different for Arabic, etc.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   246
     *
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   247
     * @return the character used for per mille sign
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    public char getPerMill() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        return perMill;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * Sets the character used for per mille sign. Different for Arabic, etc.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   255
     *
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   256
     * @param perMill the character used for per mille sign
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    public void setPerMill(char perMill) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        this.perMill = perMill;
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   260
        this.perMillText = Character.toString(perMill);
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   261
    }
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   262
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   263
    /**
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   264
     * Gets the string used for per mille sign. Different for Arabic, etc.
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   265
     *
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   266
     * @return the string used for per mille sign
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   267
     * @since 13
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   268
     */
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   269
    String getPerMillText() {
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   270
        return perMillText;
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   271
    }
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   272
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   273
    /**
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   274
     * Sets the string used for per mille sign. Different for Arabic, etc.
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   275
     *
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   276
     * Setting the {@code perMillText} affects the return value of
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   277
     * {@link #getPerMill()}, in which the first non-format character of
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   278
     * {@code perMillText} is returned.
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   279
     *
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   280
     * @param perMillText the string used for per mille sign
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   281
     * @throws NullPointerException if {@code perMillText} is null
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   282
     * @throws IllegalArgumentException if {@code perMillText} is an empty string
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   283
     * @see #getPerMill()
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   284
     * @see #getPerMillText()
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   285
     * @since 13
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   286
     */
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   287
    void setPerMillText(String perMillText) {
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   288
        Objects.requireNonNull(perMillText);
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   289
        if (perMillText.isEmpty()) {
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   290
            throw new IllegalArgumentException("Empty argument string");
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   291
        }
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   292
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   293
        this.perMillText = perMillText;
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   294
        this.perMill = findNonFormatChar(perMillText, '\u2030');
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * Gets the character used for percent sign. Different for Arabic, etc.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   299
     *
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   300
     * @return the character used for percent sign
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    public char getPercent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        return percent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * Sets the character used for percent sign. Different for Arabic, etc.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   308
     *
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   309
     * @param percent the character used for percent sign
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    public void setPercent(char percent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        this.percent = percent;
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   313
        this.percentText = Character.toString(percent);
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   314
    }
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   315
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   316
    /**
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   317
     * Gets the string used for percent sign. Different for Arabic, etc.
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   318
     *
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   319
     * @return the string used for percent sign
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   320
     * @since 13
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   321
     */
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   322
    String getPercentText() {
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   323
        return percentText;
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   324
    }
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   325
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   326
    /**
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   327
     * Sets the string used for percent sign. Different for Arabic, etc.
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   328
     *
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   329
     * Setting the {@code percentText} affects the return value of
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   330
     * {@link #getPercent()}, in which the first non-format character of
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   331
     * {@code percentText} is returned.
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   332
     *
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   333
     * @param percentText the string used for percent sign
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   334
     * @throws NullPointerException if {@code percentText} is null
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   335
     * @throws IllegalArgumentException if {@code percentText} is an empty string
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   336
     * @see #getPercent()
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   337
     * @see #getPercentText()
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   338
     * @since 13
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   339
     */
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   340
    void setPercentText(String percentText) {
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   341
        Objects.requireNonNull(percentText);
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   342
        if (percentText.isEmpty()) {
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   343
            throw new IllegalArgumentException("Empty argument string");
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   344
        }
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   345
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   346
        this.percentText = percentText;
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   347
        this.percent = findNonFormatChar(percentText, '%');
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * Gets the character used for a digit in a pattern.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   352
     *
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   353
     * @return the character used for a digit in a pattern
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    public char getDigit() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        return digit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * Sets the character used for a digit in a pattern.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   361
     *
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   362
     * @param digit the character used for a digit in a pattern
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    public void setDigit(char digit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        this.digit = digit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * Gets the character used to separate positive and negative subpatterns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * in a pattern.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   371
     *
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   372
     * @return the pattern separator
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    public char getPatternSeparator() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        return patternSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * Sets the character used to separate positive and negative subpatterns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * in a pattern.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   381
     *
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   382
     * @param patternSeparator the pattern separator
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    public void setPatternSeparator(char patternSeparator) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        this.patternSeparator = patternSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * Gets the string used to represent infinity. Almost always left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * unchanged.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   391
     *
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   392
     * @return the string representing infinity
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    public String getInfinity() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        return infinity;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * Sets the string used to represent infinity. Almost always left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * unchanged.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   401
     *
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   402
     * @param infinity the string representing infinity
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    public void setInfinity(String infinity) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        this.infinity = infinity;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * Gets the string used to represent "not a number". Almost always left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * unchanged.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   411
     *
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   412
     * @return the string representing "not a number"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    public String getNaN() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        return NaN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * Sets the string used to represent "not a number". Almost always left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * unchanged.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   421
     *
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   422
     * @param NaN the string representing "not a number"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    public void setNaN(String NaN) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        this.NaN = NaN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * Gets the character used to represent minus sign. If no explicit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * negative format is specified, one is formed by prefixing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * minusSign to the positive format.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   432
     *
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   433
     * @return the character representing minus sign
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    public char getMinusSign() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        return minusSign;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * Sets the character used to represent minus sign. If no explicit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     * negative format is specified, one is formed by prefixing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * minusSign to the positive format.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   443
     *
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   444
     * @param minusSign the character representing minus sign
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    public void setMinusSign(char minusSign) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        this.minusSign = minusSign;
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   448
        this.minusSignText = Character.toString(minusSign);
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   449
    }
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   450
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   451
    /**
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   452
     * Gets the string used to represent minus sign. If no explicit
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   453
     * negative format is specified, one is formed by prefixing
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   454
     * minusSignText to the positive format.
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   455
     *
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   456
     * @return the string representing minus sign
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   457
     * @since 13
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   458
     */
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   459
    String getMinusSignText() {
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   460
        return minusSignText;
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   461
    }
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   462
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   463
    /**
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   464
     * Sets the string used to represent minus sign. If no explicit
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   465
     * negative format is specified, one is formed by prefixing
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   466
     * minusSignText to the positive format.
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   467
     *
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   468
     * Setting the {@code minusSignText} affects the return value of
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   469
     * {@link #getMinusSign()}, in which the first non-format character of
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   470
     * {@code minusSignText} is returned.
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   471
     *
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   472
     * @param minusSignText the character representing minus sign
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   473
     * @throws NullPointerException if {@code minusSignText} is null
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   474
     * @throws IllegalArgumentException if {@code minusSignText} is an
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   475
     *  empty string
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   476
     * @see #getMinusSign()
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   477
     * @see #getMinusSignText()
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   478
     * @since 13
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   479
     */
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   480
    void setMinusSignText(String minusSignText) {
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   481
        Objects.requireNonNull(minusSignText);
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   482
        if (minusSignText.isEmpty()) {
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   483
            throw new IllegalArgumentException("Empty argument string");
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   484
        }
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   485
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   486
        this.minusSignText = minusSignText;
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   487
        this.minusSign = findNonFormatChar(minusSignText, '-');
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * Returns the currency symbol for the currency of these
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * DecimalFormatSymbols in their locale.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   493
     *
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   494
     * @return the currency symbol
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    public String getCurrencySymbol()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    {
33310
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   499
        initializeCurrency(locale);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        return currencySymbol;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * Sets the currency symbol for the currency of these
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * DecimalFormatSymbols in their locale.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   506
     *
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   507
     * @param currency the currency symbol
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    public void setCurrencySymbol(String currency)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    {
33310
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   512
        initializeCurrency(locale);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        currencySymbol = currency;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * Returns the ISO 4217 currency code of the currency of these
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * DecimalFormatSymbols.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   519
     *
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   520
     * @return the currency code
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    public String getInternationalCurrencySymbol()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
    {
33310
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   525
        initializeCurrency(locale);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        return intlCurrencySymbol;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * Sets the ISO 4217 currency code of the currency of these
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     * DecimalFormatSymbols.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     * If the currency code is valid (as defined by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * {@link java.util.Currency#getInstance(java.lang.String) Currency.getInstance}),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * this also sets the currency attribute to the corresponding Currency
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * instance and the currency symbol attribute to the currency's symbol
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     * in the DecimalFormatSymbols' locale. If the currency code is not valid,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     * then the currency attribute is set to null and the currency symbol
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     * attribute is not modified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     *
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   540
     * @param currencyCode the currency code
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     * @see #setCurrency
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     * @see #setCurrencySymbol
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    public void setInternationalCurrencySymbol(String currencyCode)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    {
33310
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   547
        initializeCurrency(locale);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        intlCurrencySymbol = currencyCode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        currency = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        if (currencyCode != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
                currency = Currency.getInstance(currencyCode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
                currencySymbol = currency.getSymbol();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
            } catch (IllegalArgumentException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     * Gets the currency of these DecimalFormatSymbols. May be null if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     * currency symbol attribute was previously set to a value that's not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     * a valid ISO 4217 currency code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     * @return the currency used, or null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
    public Currency getCurrency() {
33310
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   568
        initializeCurrency(locale);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        return currency;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     * Sets the currency of these DecimalFormatSymbols.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     * This also sets the currency symbol attribute to the currency's symbol
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     * in the DecimalFormatSymbols' locale, and the international currency
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * symbol attribute to the currency's ISO 4217 currency code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * @param currency the new currency to be used
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 57956
diff changeset
   579
     * @throws    NullPointerException if {@code currency} is null
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     * @see #setCurrencySymbol
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     * @see #setInternationalCurrencySymbol
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
    public void setCurrency(Currency currency) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        if (currency == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
            throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        }
33310
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   588
        initializeCurrency(locale);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        this.currency = currency;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
        intlCurrencySymbol = currency.getCurrencyCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        currencySymbol = currency.getSymbol(locale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     * Returns the monetary decimal separator.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   597
     *
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   598
     * @return the monetary decimal separator
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
    public char getMonetaryDecimalSeparator()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        return monetarySeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     * Sets the monetary decimal separator.
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   608
     *
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 16010
diff changeset
   609
     * @param sep the monetary decimal separator
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    public void setMonetaryDecimalSeparator(char sep)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        monetarySeparator = sep;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
    //------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
    // BEGIN   Package Private methods ... to be made public later
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
    //------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     * Returns the character used to separate the mantissa from the exponent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
    char getExponentialSymbol()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        return exponential;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    }
33310
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   628
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   629
    /**
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   630
     * Returns the string used to separate the mantissa from the exponent.
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   631
     * Examples: "x10^" for 1.23x10^4, "E" for 1.23E4.
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   632
     *
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   633
     * @return the exponent separator string
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   634
     * @see #setExponentSeparator(java.lang.String)
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   635
     * @since 1.6
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   636
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    public String getExponentSeparator()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
        return exponentialSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     * Sets the character used to separate the mantissa from the exponent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    void setExponentialSymbol(char exp)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        exponential = exp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
33310
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   650
    /**
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   651
     * Sets the string used to separate the mantissa from the exponent.
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   652
     * Examples: "x10^" for 1.23x10^4, "E" for 1.23E4.
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   653
     *
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   654
     * @param exp the exponent separator string
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 57956
diff changeset
   655
     * @throws    NullPointerException if {@code exp} is null
33310
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   656
     * @see #getExponentSeparator()
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   657
     * @since 1.6
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   658
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    public void setExponentSeparator(String exp)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        if (exp == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
            throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
        exponentialSeparator = exp;
33310
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   665
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
    //------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    // END     Package Private methods ... to be made public later
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
    //------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
     * Standard override.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     */
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   675
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    public Object clone() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
            return (DecimalFormatSymbols)super.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
            // other fields are bit-copied
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        } catch (CloneNotSupportedException e) {
10419
12c063b39232 7084245: Update usages of InternalError to use exception chaining
sherman
parents: 6501
diff changeset
   681
            throw new InternalError(e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     * Override equals.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     */
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   688
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
    public boolean equals(Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
        if (obj == null) return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
        if (this == obj) return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
        if (getClass() != obj.getClass()) return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
        DecimalFormatSymbols other = (DecimalFormatSymbols) obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
        return (zeroDigit == other.zeroDigit &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
        groupingSeparator == other.groupingSeparator &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
        decimalSeparator == other.decimalSeparator &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
        percent == other.percent &&
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   698
        percentText.equals(other.percentText) &&
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
        perMill == other.perMill &&
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   700
        perMillText.equals(other.perMillText) &&
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
        digit == other.digit &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
        minusSign == other.minusSign &&
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   703
        minusSignText.equals(other.minusSignText) &&
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
        patternSeparator == other.patternSeparator &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
        infinity.equals(other.infinity) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
        NaN.equals(other.NaN) &&
33310
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   707
        getCurrencySymbol().equals(other.getCurrencySymbol()) && // possible currency init occurs here
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
        intlCurrencySymbol.equals(other.intlCurrencySymbol) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
        currency == other.currency &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
        monetarySeparator == other.monetarySeparator &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
        exponentialSeparator.equals(other.exponentialSeparator) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
        locale.equals(other.locale));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
     * Override hashCode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     */
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   718
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
    public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
            int result = zeroDigit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
            result = result * 37 + groupingSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
            result = result * 37 + decimalSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
            return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
     * Initializes the symbols from the FormatData resource bundle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
    private void initialize( Locale locale ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
        this.locale = locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
48251
57148c79bd75 8176841: Additional Unicode Language-Tag Extensions
naoto
parents: 47216
diff changeset
   732
        // check for region override
57148c79bd75 8176841: Additional Unicode Language-Tag Extensions
naoto
parents: 47216
diff changeset
   733
        Locale override = locale.getUnicodeLocaleType("nu") == null ?
57148c79bd75 8176841: Additional Unicode Language-Tag Extensions
naoto
parents: 47216
diff changeset
   734
            CalendarDataUtility.findRegionOverride(locale) :
57148c79bd75 8176841: Additional Unicode Language-Tag Extensions
naoto
parents: 47216
diff changeset
   735
            locale;
57148c79bd75 8176841: Additional Unicode Language-Tag Extensions
naoto
parents: 47216
diff changeset
   736
15260
7af2d7a87806 7162007: Clean up i18n related caches
naoto
parents: 14336
diff changeset
   737
        // get resource bundle data
48251
57148c79bd75 8176841: Additional Unicode Language-Tag Extensions
naoto
parents: 47216
diff changeset
   738
        LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DecimalFormatSymbolsProvider.class, override);
15260
7af2d7a87806 7162007: Clean up i18n related caches
naoto
parents: 14336
diff changeset
   739
        // Avoid potential recursions
7af2d7a87806 7162007: Clean up i18n related caches
naoto
parents: 14336
diff changeset
   740
        if (!(adapter instanceof ResourceBundleBasedAdapter)) {
7af2d7a87806 7162007: Clean up i18n related caches
naoto
parents: 14336
diff changeset
   741
            adapter = LocaleProviderAdapter.getResourceBundleBased();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
        }
48251
57148c79bd75 8176841: Additional Unicode Language-Tag Extensions
naoto
parents: 47216
diff changeset
   743
        Object[] data = adapter.getLocaleResources(override).getDecimalFormatSymbolsData();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
        String[] numberElements = (String[]) data[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
        decimalSeparator = numberElements[0].charAt(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
        groupingSeparator = numberElements[1].charAt(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        patternSeparator = numberElements[2].charAt(0);
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   749
        percentText = numberElements[3];
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   750
        percent = findNonFormatChar(percentText, '%');
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
        zeroDigit = numberElements[4].charAt(0); //different for Arabic,etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
        digit = numberElements[5].charAt(0);
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   753
        minusSignText = numberElements[6];
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   754
        minusSign = findNonFormatChar(minusSignText, '-');
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
        exponential = numberElements[7].charAt(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
        exponentialSeparator = numberElements[7]; //string representation new since 1.6
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   757
        perMillText = numberElements[8];
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   758
        perMill = findNonFormatChar(perMillText, '\u2030');
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        infinity  = numberElements[9];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
        NaN = numberElements[10];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
33310
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   762
        // maybe filled with previously cached values, or null.
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   763
        intlCurrencySymbol = (String) data[1];
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   764
        currencySymbol = (String) data[2];
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   765
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   766
        // Currently the monetary decimal separator is the same as the
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   767
        // standard decimal separator for all locales that we support.
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   768
        // If that changes, add a new entry to NumberElements.
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   769
        monetarySeparator = decimalSeparator;
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   770
    }
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   771
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   772
    /**
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   773
     * Obtains non-format single character from String
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   774
     */
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   775
    private char findNonFormatChar(String src, char defChar) {
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   776
        return (char)src.chars()
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   777
            .filter(c -> Character.getType(c) != Character.FORMAT)
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   778
            .findFirst()
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   779
            .orElse(defChar);
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   780
    }
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   781
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   782
    /**
33310
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   783
     * Lazy initialization for currency related fields
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   784
     */
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   785
    private void initializeCurrency(Locale locale) {
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   786
        if (currencyInitialized) {
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   787
            return;
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   788
        }
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   789
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
        // Try to obtain the currency used in the locale's country.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
        // Check for empty country string separately because it's a valid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
        // country ID for Locale (and used for the C locale), but not a valid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        // ISO 3166 country code, and exceptions are expensive.
53018
8bf9268df0e2 8215281: Use String.isEmpty() when applicable in java.base
redestad
parents: 48251
diff changeset
   794
        if (!locale.getCountry().isEmpty()) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
                currency = Currency.getInstance(locale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
            } catch (IllegalArgumentException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
                // use default values below for compatibility
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
        }
33310
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   801
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
        if (currency != null) {
33310
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   803
            // get resource bundle data
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   804
            LocaleProviderAdapter adapter =
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   805
                LocaleProviderAdapter.getAdapter(DecimalFormatSymbolsProvider.class, locale);
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   806
            // Avoid potential recursions
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   807
            if (!(adapter instanceof ResourceBundleBasedAdapter)) {
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   808
                adapter = LocaleProviderAdapter.getResourceBundleBased();
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   809
            }
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   810
            Object[] data = adapter.getLocaleResources(locale).getDecimalFormatSymbolsData();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
            intlCurrencySymbol = currency.getCurrencyCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
            if (data[1] != null && data[1] == intlCurrencySymbol) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
                currencySymbol = (String) data[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
                currencySymbol = currency.getSymbol(locale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
                data[1] = intlCurrencySymbol;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
                data[2] = currencySymbol;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
            // default values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
            intlCurrencySymbol = "XXX";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
                currency = Currency.getInstance(intlCurrencySymbol);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
            } catch (IllegalArgumentException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
            currencySymbol = "\u00A4";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
        }
33310
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   828
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   829
        currencyInitialized = true;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
     * Reads the default serializable fields, provides default values for objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
     * in older serial versions, and initializes non-serializable fields.
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   835
     * If {@code serialVersionOnStream}
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   836
     * is less than 1, initializes {@code monetarySeparator} to be
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   837
     * the same as {@code decimalSeparator} and {@code exponential}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
     * to be 'E'.
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   839
     * If {@code serialVersionOnStream} is less than 2,
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   840
     * initializes {@code locale}to the root locale, and initializes
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   841
     * If {@code serialVersionOnStream} is less than 3, it initializes
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   842
     * {@code exponentialSeparator} using {@code exponential}.
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   843
     * If {@code serialVersionOnStream} is less than 4, it initializes
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   844
     * {@code perMillText}, {@code percentText}, and
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   845
     * {@code minusSignText} using {@code perMill}, {@code percent}, and
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   846
     * {@code minusSign} respectively.
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   847
     * Sets {@code serialVersionOnStream} back to the maximum allowed value so that
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
     * default serialization will work properly if this object is streamed out again.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
     * Initializes the currency from the intlCurrencySymbol field.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
     *
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   851
     * @throws InvalidObjectException if {@code char} and {@code String}
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   852
     *      representations of either percent, per mille, and/or minus sign disagree.
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 19054
diff changeset
   853
     * @since  1.1.6
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
     */
57956
e0b8b019d2f5 8229997: Apply java.io.Serial annotations in java.base
darcy
parents: 54252
diff changeset
   855
    @java.io.Serial
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
    private void readObject(ObjectInputStream stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
            throws IOException, ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
        stream.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
        if (serialVersionOnStream < 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
            // Didn't have monetarySeparator or exponential field;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
            // use defaults.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
            monetarySeparator = decimalSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
            exponential       = 'E';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
        if (serialVersionOnStream < 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
            // didn't have locale; use root locale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
            locale = Locale.ROOT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
        if (serialVersionOnStream < 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
            // didn't have exponentialSeparator. Create one using exponential
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
            exponentialSeparator = Character.toString(exponential);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
        }
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   873
        if (serialVersionOnStream < 4) {
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   874
            // didn't have perMillText, percentText, and minusSignText.
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   875
            // Create one using corresponding char variations.
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   876
            perMillText = Character.toString(perMill);
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   877
            percentText = Character.toString(percent);
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   878
            minusSignText = Character.toString(minusSign);
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   879
        } else {
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   880
            // Check whether char and text fields agree
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   881
            if (findNonFormatChar(perMillText, '\uFFFF') != perMill ||
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   882
                findNonFormatChar(percentText, '\uFFFF') != percent ||
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   883
                findNonFormatChar(minusSignText, '\uFFFF') != minusSign) {
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   884
                throw new InvalidObjectException(
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   885
                    "'char' and 'String' representations of either percent, " +
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   886
                    "per mille, and/or minus sign disagree.");
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   887
            }
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   888
        }
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
   889
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
        serialVersionOnStream = currentSerialVersion;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
        if (intlCurrencySymbol != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
                 currency = Currency.getInstance(intlCurrencySymbol);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
            } catch (IllegalArgumentException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
            }
33310
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
   897
            currencyInitialized = true;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
     * Character used for zero.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
     * @see #getZeroDigit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
    private  char    zeroDigit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
     * Character used for thousands separator.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
     * @see #getGroupingSeparator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
    private  char    groupingSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
     * Character used for decimal sign.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
     * @see #getDecimalSeparator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
    private  char    decimalSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
     * Character used for per mille sign.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
     * @see #getPerMill
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
    private  char    perMill;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
     * Character used for percent sign.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
     * @see #getPercent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
    private  char    percent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
     * Character used for a digit in a pattern.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
     * @see #getDigit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
    private  char    digit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
     * Character used to separate positive and negative subpatterns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
     * in a pattern.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
     * @see #getPatternSeparator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
    private  char    patternSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
     * String used to represent infinity.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
     * @see #getInfinity
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
    private  String  infinity;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
     * String used to represent "not a number".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
     * @see #getNaN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
    private  String  NaN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
     * Character used to represent minus sign.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
     * @see #getMinusSign
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
    private  char    minusSign;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
     * String denoting the local currency, e.g. "$".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
     * @see #getCurrencySymbol
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
    private  String  currencySymbol;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
     * ISO 4217 currency code denoting the local currency, e.g. "USD".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
     * @see #getInternationalCurrencySymbol
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
    private  String  intlCurrencySymbol;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
     * The decimal separator used when formatting currency values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
     * @serial
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 19054
diff changeset
   995
     * @since  1.1.6
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
     * @see #getMonetaryDecimalSeparator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
    private  char    monetarySeparator; // Field new in JDK 1.1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
     * The character used to distinguish the exponent in a number formatted
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
     * in exponential notation, e.g. 'E' for a number such as "1.23E45".
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
     * Note that the public API provides no way to set this field,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
     * even though it is supported by the implementation and the stream format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
     * The intent is that this will be added to the API in the future.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
     * @serial
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 19054
diff changeset
  1009
     * @since  1.1.6
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
    private  char    exponential;       // Field new in JDK 1.1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
33310
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
  1013
    /**
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
  1014
     * The string used to separate the mantissa from the exponent.
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
  1015
     * Examples: "x10^" for 1.23x10^4, "E" for 1.23E4.
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
  1016
     * <p>
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1017
     * If both {@code exponential} and {@code exponentialSeparator}
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1018
     * exist, this {@code exponentialSeparator} has the precedence.
33310
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
  1019
     *
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
  1020
     * @serial
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
  1021
     * @since 1.6
2701a9854bb5 8134720: Lazy initialization support for currency names in DecimalFormatSymbols
naoto
parents: 25859
diff changeset
  1022
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
    private  String    exponentialSeparator;       // Field new in JDK 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
     * The locale of these currency format symbols.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
    private Locale locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1033
    /**
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1034
     * String representation of per mille sign, which may include
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1035
     * formatting characters, such as BiDi control characters.
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1036
     * The first non-format character of this string is the same as
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1037
     * {@code perMill}.
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1038
     *
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1039
     * @serial
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1040
     * @since 13
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1041
     */
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1042
    private  String perMillText;
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1043
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1044
    /**
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1045
     * String representation of percent sign, which may include
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1046
     * formatting characters, such as BiDi control characters.
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1047
     * The first non-format character of this string is the same as
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1048
     * {@code percent}.
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1049
     *
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1050
     * @serial
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1051
     * @since 13
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1052
     */
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1053
    private  String percentText;
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1054
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1055
    /**
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1056
     * String representation of minus sign, which may include
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1057
     * formatting characters, such as BiDi control characters.
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1058
     * The first non-format character of this string is the same as
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1059
     * {@code minusSign}.
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1060
     *
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1061
     * @serial
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1062
     * @since 13
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1063
     */
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1064
    private  String minusSignText;
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1065
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
    // currency; only the ISO code is serialized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
    private transient Currency currency;
34774
03b4e6dc367b 8145680: Remove unnecessary explicit initialization of volatile variables in java.base
redestad
parents: 33310
diff changeset
  1068
    private transient volatile boolean currencyInitialized;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
    // Proclaim JDK 1.1 FCS compatibility
57956
e0b8b019d2f5 8229997: Apply java.io.Serial annotations in java.base
darcy
parents: 54252
diff changeset
  1071
    @java.io.Serial
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
    static final long serialVersionUID = 5772796243397350300L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
    // The internal serial version which says which version was written
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
    // - 0 (default) for version up to JDK 1.1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
    // - 1 for version from JDK 1.1.6, which includes two new fields:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
    //     monetarySeparator and exponential.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
    // - 2 for version from J2SE 1.4, which includes locale field.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
    // - 3 for version from J2SE 1.6, which includes exponentialSeparator field.
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1080
    // - 4 for version from Java SE 13, which includes perMillText, percentText,
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1081
    //      and minusSignText field.
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1082
    private static final int currentSerialVersion = 4;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
    /**
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1085
     * Describes the version of {@code DecimalFormatSymbols} present on the stream.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
     * Possible values are:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
     * <li><b>0</b> (or uninitialized): versions prior to JDK 1.1.6.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
     * <li><b>1</b>: Versions written by JDK 1.1.6 or later, which include
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1091
     *      two new fields: {@code monetarySeparator} and {@code exponential}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
     * <li><b>2</b>: Versions written by J2SE 1.4 or later, which include a
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1093
     *      new {@code locale} field.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
     * <li><b>3</b>: Versions written by J2SE 1.6 or later, which include a
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1095
     *      new {@code exponentialSeparator} field.
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1096
     * <li><b>4</b>: Versions written by Java SE 13 or later, which include
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1097
     *      new {@code perMillText}, {@code percentText}, and
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1098
     *      {@code minusSignText} field.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
     * </ul>
54252
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1100
     * When streaming out a {@code DecimalFormatSymbols}, the most recent format
83deaa8f0c8e 8220224: With CLDR provider, NumberFormat.format could not handle locale with number extension correctly.
naoto
parents: 53018
diff changeset
  1101
     * (corresponding to the highest allowable {@code serialVersionOnStream})
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
     * is always written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
     * @serial
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 19054
diff changeset
  1105
     * @since  1.1.6
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
    private int serialVersionOnStream = currentSerialVersion;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
}