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