jdk/src/share/classes/java/text/DecimalFormatSymbols.java
author naoto
Tue, 21 Aug 2012 11:00:30 -0700
changeset 13583 dc0017b1a452
parent 10419 12c063b39232
child 14336 4a3418a2c07f
permissions -rw-r--r--
6336885: RFE: Locale Data Deployment Enhancements 4609153: Provide locale data for Indic locales 5104387: Support for gl_ES locale (galician language) 6337471: desktop/system locale preferences support 7056139: (cal) SPI support for locale-dependent Calendar parameters 7058206: Provide CalendarData SPI for week params and display field value names 7073852: Support multiple scripts for digits and decimal symbols per locale 7079560: [Fmt-Da] Context dependent month names support in SimpleDateFormat 7171324: getAvailableLocales() of locale sensitive services should return the actual availability of locales 7151414: (cal) Support calendar type identification 7168528: LocaleServiceProvider needs to be aware of Locale extensions 7171372: (cal) locale's default Calendar should be created if unknown calendar is specified Summary: JEP 127: Improve Locale Data Packaging and Adopt Unicode CLDR Data (part 1 w/o packaging changes. by Naoto Sato and Masayoshi Okutsu) Reviewed-by: erikj, sherman, peytoia
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
     2
 * Copyright (c) 1996, 2012, 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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import java.text.spi.DecimalFormatSymbolsProvider;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import java.util.Currency;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import java.util.Locale;
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
    47
import java.util.MissingResourceException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import java.util.ResourceBundle;
6501
684810d882b3 6875847: Java Locale Enhancement
naoto
parents: 6489
diff changeset
    49
import java.util.concurrent.ConcurrentHashMap;
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
    50
import java.util.concurrent.ConcurrentMap;
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
    51
import sun.util.locale.provider.LocaleProviderAdapter;
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
    52
import sun.util.locale.provider.LocaleServiceProviderPool;
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,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * the grouping separator, and so on) needed by <code>DecimalFormat</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * to format numbers. <code>DecimalFormat</code> creates for itself an instance of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * <code>DecimalFormatSymbols</code> from its locale data.  If you need to change any
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * of these symbols, you can get the <code>DecimalFormatSymbols</code> object from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * your <code>DecimalFormat</code> and modify it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * @see          java.util.Locale
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * @see          DecimalFormat
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * @author       Mark Davis
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * @author       Alan Liu
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
public class DecimalFormatSymbols implements Cloneable, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * Create a DecimalFormatSymbols object for the default locale.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * This constructor can only construct instances for the locales
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * supported by the Java runtime environment, not for those
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * supported by installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * {@link java.text.spi.DecimalFormatSymbolsProvider DecimalFormatSymbolsProvider}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * implementations. For full locale coverage, use the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * {@link #getInstance(Locale) getInstance} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    public DecimalFormatSymbols() {
6489
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
    80
        initialize( Locale.getDefault(Locale.Category.FORMAT) );
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * Create a DecimalFormatSymbols object for the given locale.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * This constructor can only construct instances for the locales
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * supported by the Java runtime environment, not for those
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * supported by installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * {@link java.text.spi.DecimalFormatSymbolsProvider DecimalFormatSymbolsProvider}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * implementations. For full locale coverage, use the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * {@link #getInstance(Locale) getInstance} method.
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
    91
     * 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
    92
     * for the numbering system, the instance is initialized with the specified numbering
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
    93
     * system if the JRE implementation supports it. For example,
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
    94
     * <pre>
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
    95
     * NumberFormat.getNumberInstance(Locale.forLanguageTag("th-TH-u-nu-thai"))
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
    96
     * </pre>
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
    97
     * This may return a {@code NumberFormat} instance with the Thai numbering system,
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
    98
     * instead of the Latin numbering system.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @exception NullPointerException if <code>locale</code> is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    public DecimalFormatSymbols( Locale locale ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        initialize( locale );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * Returns an array of all locales for which the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * <code>getInstance</code> methods of this class can return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * localized instances.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * The returned array represents the union of locales supported by the Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * runtime and by installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * {@link java.text.spi.DecimalFormatSymbolsProvider DecimalFormatSymbolsProvider}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * implementations.  It must contain at least a <code>Locale</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * instance equal to {@link java.util.Locale#US Locale.US}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @return An array of locales for which localized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     *         <code>DecimalFormatSymbols</code> instances are available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    public static Locale[] getAvailableLocales() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        LocaleServiceProviderPool pool =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            LocaleServiceProviderPool.getPool(DecimalFormatSymbolsProvider.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        return pool.getAvailableLocales();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * Gets the <code>DecimalFormatSymbols</code> instance for the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * locale.  This method provides access to <code>DecimalFormatSymbols</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * instances for locales supported by the Java runtime itself as well
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * as for those supported by installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * {@link java.text.spi.DecimalFormatSymbolsProvider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * DecimalFormatSymbolsProvider} implementations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @return a <code>DecimalFormatSymbols</code> instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    public static final DecimalFormatSymbols getInstance() {
6489
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   137
        return getInstance(Locale.getDefault(Locale.Category.FORMAT));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * Gets the <code>DecimalFormatSymbols</code> instance for the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * locale.  This method provides access to <code>DecimalFormatSymbols</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * instances for locales supported by the Java runtime itself as well
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * as for those supported by installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * {@link java.text.spi.DecimalFormatSymbolsProvider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * DecimalFormatSymbolsProvider} implementations.
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   147
     * 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
   148
     * for the numbering system, the instance is initialized with the specified numbering
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   149
     * system if the JRE implementation supports it. For example,
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   150
     * <pre>
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   151
     * NumberFormat.getNumberInstance(Locale.forLanguageTag("th-TH-u-nu-thai"))
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   152
     * </pre>
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   153
     * This may return a {@code NumberFormat} instance with the Thai numbering system,
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   154
     * instead of the Latin numbering system.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * @param locale the desired locale.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * @return a <code>DecimalFormatSymbols</code> instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * @exception NullPointerException if <code>locale</code> is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    public static final DecimalFormatSymbols getInstance(Locale locale) {
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   161
        LocaleProviderAdapter adapter;
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   162
        adapter = LocaleProviderAdapter.getAdapter(DecimalFormatSymbolsProvider.class, locale);
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   163
        DecimalFormatSymbolsProvider provider = adapter.getDecimalFormatSymbolsProvider();
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   164
        DecimalFormatSymbols dfsyms = provider.getInstance(locale);
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   165
        if (dfsyms == null) {
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   166
            provider = LocaleProviderAdapter.forJRE().getDecimalFormatSymbolsProvider();
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   167
            dfsyms = provider.getInstance(locale);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        }
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   169
        return dfsyms;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * Gets the character used for zero. Different for Arabic, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    public char getZeroDigit() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        return zeroDigit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * Sets the character used for zero. Different for Arabic, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    public void setZeroDigit(char zeroDigit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        this.zeroDigit = zeroDigit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * Gets the character used for thousands separator. Different for French, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    public char getGroupingSeparator() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        return groupingSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * Sets the character used for thousands separator. Different for French, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    public void setGroupingSeparator(char groupingSeparator) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        this.groupingSeparator = groupingSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * Gets the character used for decimal sign. Different for French, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    public char getDecimalSeparator() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        return decimalSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * Sets the character used for decimal sign. Different for French, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    public void setDecimalSeparator(char decimalSeparator) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        this.decimalSeparator = decimalSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * Gets the character used for per mille sign. Different for Arabic, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    public char getPerMill() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        return perMill;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * Sets the character used for per mille sign. Different for Arabic, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    public void setPerMill(char perMill) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        this.perMill = perMill;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * Gets the character used for percent sign. Different for Arabic, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    public char getPercent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        return percent;
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 percent sign. Different for Arabic, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    public void setPercent(char percent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        this.percent = percent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * Gets the character used for a digit in a pattern.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    public char getDigit() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        return digit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * Sets the character used for a digit in a pattern.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    public void setDigit(char digit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        this.digit = digit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * Gets the character used to separate positive and negative subpatterns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * in a pattern.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    public char getPatternSeparator() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        return patternSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * Sets the character used to separate positive and negative subpatterns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * in a pattern.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    public void setPatternSeparator(char patternSeparator) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        this.patternSeparator = patternSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * Gets the string used to represent infinity. Almost always left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * unchanged.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    public String getInfinity() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        return infinity;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * Sets the string used to represent infinity. Almost always left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * unchanged.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    public void setInfinity(String infinity) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        this.infinity = infinity;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * Gets the string used to represent "not a number". Almost always left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * unchanged.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    public String getNaN() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        return NaN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * Sets the string used to represent "not a number". Almost always left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * unchanged.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    public void setNaN(String NaN) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        this.NaN = NaN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * Gets the character used to represent minus sign. If no explicit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * negative format is specified, one is formed by prefixing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * minusSign to the positive format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    public char getMinusSign() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        return minusSign;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * Sets the character used to represent minus sign. If no explicit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * negative format is specified, one is formed by prefixing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * minusSign to the positive format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    public void setMinusSign(char minusSign) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        this.minusSign = minusSign;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * Returns the currency symbol for the currency of these
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * DecimalFormatSymbols in their locale.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    public String getCurrencySymbol()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        return currencySymbol;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * Sets the currency symbol for the currency of these
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * DecimalFormatSymbols in their locale.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    public void setCurrencySymbol(String currency)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        currencySymbol = currency;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * Returns the ISO 4217 currency code of the currency of these
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * DecimalFormatSymbols.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    public String getInternationalCurrencySymbol()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        return intlCurrencySymbol;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * Sets the ISO 4217 currency code of the currency of these
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * DecimalFormatSymbols.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * If the currency code is valid (as defined by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * {@link java.util.Currency#getInstance(java.lang.String) Currency.getInstance}),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * this also sets the currency attribute to the corresponding Currency
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * instance and the currency symbol attribute to the currency's symbol
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * in the DecimalFormatSymbols' locale. If the currency code is not valid,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * then the currency attribute is set to null and the currency symbol
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * attribute is not modified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * @see #setCurrency
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * @see #setCurrencySymbol
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    public void setInternationalCurrencySymbol(String currencyCode)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        intlCurrencySymbol = currencyCode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        currency = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        if (currencyCode != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                currency = Currency.getInstance(currencyCode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                currencySymbol = currency.getSymbol();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
            } catch (IllegalArgumentException e) {
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * Gets the currency of these DecimalFormatSymbols. May be null if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     * currency symbol attribute was previously set to a value that's not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     * a valid ISO 4217 currency code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * @return the currency used, or null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    public Currency getCurrency() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        return currency;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * Sets the currency of these DecimalFormatSymbols.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * This also sets the currency symbol attribute to the currency's symbol
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * in the DecimalFormatSymbols' locale, and the international currency
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * symbol attribute to the currency's ISO 4217 currency code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * @param currency the new currency to be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * @exception NullPointerException if <code>currency</code> is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * @see #setCurrencySymbol
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * @see #setInternationalCurrencySymbol
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    public void setCurrency(Currency currency) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        if (currency == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
            throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        this.currency = currency;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        intlCurrencySymbol = currency.getCurrencyCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        currencySymbol = currency.getSymbol(locale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * Returns the monetary decimal separator.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    public char getMonetaryDecimalSeparator()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        return monetarySeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * Sets the monetary decimal separator.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    public void setMonetaryDecimalSeparator(char sep)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
        monetarySeparator = sep;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    //------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    // BEGIN   Package Private methods ... to be made public later
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    //------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * Returns the character used to separate the mantissa from the exponent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    char getExponentialSymbol()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        return exponential;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
   * Returns the string used to separate the mantissa from the exponent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
   * Examples: "x10^" for 1.23x10^4, "E" for 1.23E4.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
   * @return the exponent separator string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
   * @see #setExponentSeparator(java.lang.String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
   * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    public String getExponentSeparator()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        return exponentialSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * Sets the character used to separate the mantissa from the exponent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    void setExponentialSymbol(char exp)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
        exponential = exp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
   * Sets the string used to separate the mantissa from the exponent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
   * Examples: "x10^" for 1.23x10^4, "E" for 1.23E4.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
   * @param exp the exponent separator string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
   * @exception NullPointerException if <code>exp</code> is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
   * @see #getExponentSeparator()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
   * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    public void setExponentSeparator(String exp)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        if (exp == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
            throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        exponentialSeparator = exp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
    //------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    // END     Package Private methods ... to be made public later
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    //------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * Standard override.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     */
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   489
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    public Object clone() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
            return (DecimalFormatSymbols)super.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            // other fields are bit-copied
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        } catch (CloneNotSupportedException e) {
10419
12c063b39232 7084245: Update usages of InternalError to use exception chaining
sherman
parents: 6501
diff changeset
   495
            throw new InternalError(e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * Override equals.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     */
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   502
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    public boolean equals(Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        if (obj == null) return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        if (this == obj) return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        if (getClass() != obj.getClass()) return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        DecimalFormatSymbols other = (DecimalFormatSymbols) obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        return (zeroDigit == other.zeroDigit &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        groupingSeparator == other.groupingSeparator &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        decimalSeparator == other.decimalSeparator &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        percent == other.percent &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        perMill == other.perMill &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        digit == other.digit &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
        minusSign == other.minusSign &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        patternSeparator == other.patternSeparator &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        infinity.equals(other.infinity) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        NaN.equals(other.NaN) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        currencySymbol.equals(other.currencySymbol) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        intlCurrencySymbol.equals(other.intlCurrencySymbol) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        currency == other.currency &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        monetarySeparator == other.monetarySeparator &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        exponentialSeparator.equals(other.exponentialSeparator) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
        locale.equals(other.locale));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     * Override hashCode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     */
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   529
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
            int result = zeroDigit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
            result = result * 37 + groupingSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
            result = result * 37 + decimalSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
            return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     * Initializes the symbols from the FormatData resource bundle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    private void initialize( Locale locale ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        this.locale = locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        // get resource bundle data - try the cache first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        boolean needCacheUpdate = false;
6501
684810d882b3 6875847: Java Locale Enhancement
naoto
parents: 6489
diff changeset
   545
        Object[] data = cachedLocaleData.get(locale);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        if (data == null) {  /* cache miss */
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   547
            LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DecimalFormatSymbolsProvider.class, locale);
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   548
            // Avoid potential recursions
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   549
            switch (adapter.getAdapterType()) {
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   550
            case HOST:
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   551
            case SPI:
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   552
                adapter = LocaleProviderAdapter.getResourceBundleBased();
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   553
                break;
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   554
            }
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   555
            ResourceBundle rb = adapter.getLocaleData().getNumberFormatData(locale);
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   556
            data = new Object[3];
6501
684810d882b3 6875847: Java Locale Enhancement
naoto
parents: 6489
diff changeset
   557
            String numberType = locale.getUnicodeLocaleType("nu");
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   558
            StringBuilder numElemKey =
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   559
                new StringBuilder(numberType != null ?
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   560
                                  numberType : rb.getString("DefaultNumberingSystem"));
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   561
            if (numElemKey.length() != 0) {
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   562
                numElemKey.append(".");
6501
684810d882b3 6875847: Java Locale Enhancement
naoto
parents: 6489
diff changeset
   563
            }
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   564
            numElemKey.append("NumberElements");
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   565
            try {
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   566
                data[0] = rb.getStringArray(numElemKey.toString());
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   567
            } catch (MissingResourceException mre) {
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   568
                // numberType must be bogus. Use the last resort numbering system.
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   569
                data[0] = rb.getStringArray("NumberElements");
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   570
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
            needCacheUpdate = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        String[] numberElements = (String[]) data[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
        decimalSeparator = numberElements[0].charAt(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
        groupingSeparator = numberElements[1].charAt(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        patternSeparator = numberElements[2].charAt(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        percent = numberElements[3].charAt(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        zeroDigit = numberElements[4].charAt(0); //different for Arabic,etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        digit = numberElements[5].charAt(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        minusSign = numberElements[6].charAt(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
        exponential = numberElements[7].charAt(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        exponentialSeparator = numberElements[7]; //string representation new since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        perMill = numberElements[8].charAt(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        infinity  = numberElements[9];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        NaN = numberElements[10];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        // Try to obtain the currency used in the locale's country.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
        // Check for empty country string separately because it's a valid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        // country ID for Locale (and used for the C locale), but not a valid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        // ISO 3166 country code, and exceptions are expensive.
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   593
        if (locale.getCountry().length() > 0) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                currency = Currency.getInstance(locale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
            } catch (IllegalArgumentException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                // use default values below for compatibility
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        if (currency != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
            intlCurrencySymbol = currency.getCurrencyCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
            if (data[1] != null && data[1] == intlCurrencySymbol) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
                currencySymbol = (String) data[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
                currencySymbol = currency.getSymbol(locale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
                data[1] = intlCurrencySymbol;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
                data[2] = currencySymbol;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                needCacheUpdate = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
            // default values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
            intlCurrencySymbol = "XXX";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
                currency = Currency.getInstance(intlCurrencySymbol);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
            } catch (IllegalArgumentException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
            currencySymbol = "\u00A4";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        // Currently the monetary decimal separator is the same as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        // standard decimal separator for all locales that we support.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
        // If that changes, add a new entry to NumberElements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        monetarySeparator = decimalSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        if (needCacheUpdate) {
6501
684810d882b3 6875847: Java Locale Enhancement
naoto
parents: 6489
diff changeset
   625
            cachedLocaleData.putIfAbsent(locale, data);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * Reads the default serializable fields, provides default values for objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     * in older serial versions, and initializes non-serializable fields.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     * If <code>serialVersionOnStream</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     * is less than 1, initializes <code>monetarySeparator</code> to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     * the same as <code>decimalSeparator</code> and <code>exponential</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     * to be 'E'.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     * If <code>serialVersionOnStream</code> is less than 2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     * initializes <code>locale</code>to the root locale, and initializes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
     * If <code>serialVersionOnStream</code> is less than 3, it initializes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
     * <code>exponentialSeparator</code> using <code>exponential</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     * Sets <code>serialVersionOnStream</code> back to the maximum allowed value so that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     * default serialization will work properly if this object is streamed out again.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     * Initializes the currency from the intlCurrencySymbol field.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     * @since JDK 1.1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
    private void readObject(ObjectInputStream stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
            throws IOException, ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
        stream.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
        if (serialVersionOnStream < 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
            // Didn't have monetarySeparator or exponential field;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
            // use defaults.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
            monetarySeparator = decimalSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
            exponential       = 'E';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        if (serialVersionOnStream < 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
            // didn't have locale; use root locale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
            locale = Locale.ROOT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
        if (serialVersionOnStream < 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
            // didn't have exponentialSeparator. Create one using exponential
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
            exponentialSeparator = Character.toString(exponential);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        serialVersionOnStream = currentSerialVersion;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        if (intlCurrencySymbol != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
                 currency = Currency.getInstance(intlCurrencySymbol);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
            } catch (IllegalArgumentException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
            }
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     * Character used for zero.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
     * @see #getZeroDigit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
    private  char    zeroDigit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     * Character used for thousands separator.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     * @see #getGroupingSeparator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
    private  char    groupingSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     * Character used for decimal sign.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
     * @see #getDecimalSeparator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
    private  char    decimalSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     * Character used for per mille sign.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     * @see #getPerMill
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
    private  char    perMill;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
     * Character used for percent sign.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
     * @see #getPercent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
    private  char    percent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
     * Character used for a digit in a pattern.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
     * @see #getDigit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
    private  char    digit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     * Character used to separate positive and negative subpatterns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     * in a pattern.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     * @see #getPatternSeparator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
    private  char    patternSeparator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     * String used to represent infinity.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
     * @see #getInfinity
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
    private  String  infinity;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
     * String used to represent "not a number".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
     * @see #getNaN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
    private  String  NaN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     * Character used to represent minus sign.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
     * @see #getMinusSign
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
    private  char    minusSign;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
     * String denoting the local currency, e.g. "$".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
     * @see #getCurrencySymbol
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
    private  String  currencySymbol;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
     * ISO 4217 currency code denoting the local currency, e.g. "USD".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
     * @see #getInternationalCurrencySymbol
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
    private  String  intlCurrencySymbol;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
     * The decimal separator used when formatting currency values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
     * @since JDK 1.1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
     * @see #getMonetaryDecimalSeparator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
    private  char    monetarySeparator; // Field new in JDK 1.1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
     * The character used to distinguish the exponent in a number formatted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
     * in exponential notation, e.g. 'E' for a number such as "1.23E45".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
     * Note that the public API provides no way to set this field,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
     * even though it is supported by the implementation and the stream format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
     * The intent is that this will be added to the API in the future.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
     * @since JDK 1.1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
    private  char    exponential;       // Field new in JDK 1.1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
   * The string used to separate the mantissa from the exponent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
   * Examples: "x10^" for 1.23x10^4, "E" for 1.23E4.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
   * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
   * If both <code>exponential</code> and <code>exponentialSeparator</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
   * exist, this <code>exponentialSeparator</code> has the precedence.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
   * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
   * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
    private  String    exponentialSeparator;       // Field new in JDK 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
     * The locale of these currency format symbols.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
    private Locale locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
    // currency; only the ISO code is serialized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
    private transient Currency currency;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
    // Proclaim JDK 1.1 FCS compatibility
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
    static final long serialVersionUID = 5772796243397350300L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
    // The internal serial version which says which version was written
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
    // - 0 (default) for version up to JDK 1.1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
    // - 1 for version from JDK 1.1.6, which includes two new fields:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
    //     monetarySeparator and exponential.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
    // - 2 for version from J2SE 1.4, which includes locale field.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
    // - 3 for version from J2SE 1.6, which includes exponentialSeparator field.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
    private static final int currentSerialVersion = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
     * Describes the version of <code>DecimalFormatSymbols</code> present on the stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
     * Possible values are:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
     * <li><b>0</b> (or uninitialized): versions prior to JDK 1.1.6.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
     * <li><b>1</b>: Versions written by JDK 1.1.6 or later, which include
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
     *      two new fields: <code>monetarySeparator</code> and <code>exponential</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
     * <li><b>2</b>: Versions written by J2SE 1.4 or later, which include a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
     *      new <code>locale</code> field.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
     * <li><b>3</b>: Versions written by J2SE 1.6 or later, which include a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
     *      new <code>exponentialSeparator</code> field.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
     * When streaming out a <code>DecimalFormatSymbols</code>, the most recent format
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
     * (corresponding to the highest allowable <code>serialVersionOnStream</code>)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
     * is always written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
     * @since JDK 1.1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
    private int serialVersionOnStream = currentSerialVersion;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
     * cache to hold the NumberElements and the Currency
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
     * of a Locale.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
     */
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   845
    private static final ConcurrentMap<Locale, Object[]> cachedLocaleData
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10419
diff changeset
   846
            = new ConcurrentHashMap<>(3);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
}