0N/A/*
2712N/A * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
0N/A * (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved
0N/A *
0N/A * The original version of this source code and documentation is copyrighted
0N/A * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These
0N/A * materials are provided under terms of a License Agreement between Taligent
0N/A * and Sun. This technology is protected by multiple US and International
0N/A * patents. This notice and attribution to Taligent may not be removed.
0N/A * Taligent is a registered trademark of Taligent, Inc.
0N/A *
0N/A */
0N/A
0N/Apackage java.text;
0N/A
0N/Aimport java.io.IOException;
0N/Aimport java.io.ObjectInputStream;
0N/Aimport java.io.Serializable;
0N/Aimport java.text.spi.DecimalFormatSymbolsProvider;
0N/Aimport java.util.Currency;
0N/Aimport java.util.Locale;
0N/Aimport java.util.ResourceBundle;
2712N/Aimport java.util.concurrent.ConcurrentHashMap;
2712N/A
0N/Aimport sun.util.LocaleServiceProviderPool;
0N/Aimport sun.util.resources.LocaleData;
0N/A
0N/A/**
0N/A * This class represents the set of symbols (such as the decimal separator,
0N/A * the grouping separator, and so on) needed by <code>DecimalFormat</code>
0N/A * to format numbers. <code>DecimalFormat</code> creates for itself an instance of
0N/A * <code>DecimalFormatSymbols</code> from its locale data. If you need to change any
0N/A * of these symbols, you can get the <code>DecimalFormatSymbols</code> object from
0N/A * your <code>DecimalFormat</code> and modify it.
0N/A *
0N/A * @see java.util.Locale
0N/A * @see DecimalFormat
0N/A * @author Mark Davis
0N/A * @author Alan Liu
0N/A */
0N/A
0N/Apublic class DecimalFormatSymbols implements Cloneable, Serializable {
0N/A
0N/A /**
0N/A * Create a DecimalFormatSymbols object for the default locale.
0N/A * This constructor can only construct instances for the locales
0N/A * supported by the Java runtime environment, not for those
0N/A * supported by installed
0N/A * {@link java.text.spi.DecimalFormatSymbolsProvider DecimalFormatSymbolsProvider}
0N/A * implementations. For full locale coverage, use the
0N/A * {@link #getInstance(Locale) getInstance} method.
0N/A */
0N/A public DecimalFormatSymbols() {
2700N/A initialize( Locale.getDefault(Locale.Category.FORMAT) );
0N/A }
0N/A
0N/A /**
0N/A * Create a DecimalFormatSymbols object for the given locale.
0N/A * This constructor can only construct instances for the locales
0N/A * supported by the Java runtime environment, not for those
0N/A * supported by installed
0N/A * {@link java.text.spi.DecimalFormatSymbolsProvider DecimalFormatSymbolsProvider}
0N/A * implementations. For full locale coverage, use the
0N/A * {@link #getInstance(Locale) getInstance} method.
0N/A *
0N/A * @exception NullPointerException if <code>locale</code> is null
0N/A */
0N/A public DecimalFormatSymbols( Locale locale ) {
0N/A initialize( locale );
0N/A }
0N/A
0N/A /**
0N/A * Returns an array of all locales for which the
0N/A * <code>getInstance</code> methods of this class can return
0N/A * localized instances.
0N/A * The returned array represents the union of locales supported by the Java
0N/A * runtime and by installed
0N/A * {@link java.text.spi.DecimalFormatSymbolsProvider DecimalFormatSymbolsProvider}
0N/A * implementations. It must contain at least a <code>Locale</code>
0N/A * instance equal to {@link java.util.Locale#US Locale.US}.
0N/A *
0N/A * @return An array of locales for which localized
0N/A * <code>DecimalFormatSymbols</code> instances are available.
0N/A * @since 1.6
0N/A */
0N/A public static Locale[] getAvailableLocales() {
0N/A LocaleServiceProviderPool pool =
0N/A LocaleServiceProviderPool.getPool(DecimalFormatSymbolsProvider.class);
0N/A return pool.getAvailableLocales();
0N/A }
0N/A
0N/A /**
0N/A * Gets the <code>DecimalFormatSymbols</code> instance for the default
0N/A * locale. This method provides access to <code>DecimalFormatSymbols</code>
0N/A * instances for locales supported by the Java runtime itself as well
0N/A * as for those supported by installed
0N/A * {@link java.text.spi.DecimalFormatSymbolsProvider
0N/A * DecimalFormatSymbolsProvider} implementations.
0N/A * @return a <code>DecimalFormatSymbols</code> instance.
0N/A * @since 1.6
0N/A */
0N/A public static final DecimalFormatSymbols getInstance() {
2700N/A return getInstance(Locale.getDefault(Locale.Category.FORMAT));
0N/A }
0N/A
0N/A /**
0N/A * Gets the <code>DecimalFormatSymbols</code> instance for the specified
0N/A * locale. This method provides access to <code>DecimalFormatSymbols</code>
0N/A * instances for locales supported by the Java runtime itself as well
0N/A * as for those supported by installed
0N/A * {@link java.text.spi.DecimalFormatSymbolsProvider
0N/A * DecimalFormatSymbolsProvider} implementations.
0N/A * @param locale the desired locale.
0N/A * @return a <code>DecimalFormatSymbols</code> instance.
0N/A * @exception NullPointerException if <code>locale</code> is null
0N/A * @since 1.6
0N/A */
0N/A public static final DecimalFormatSymbols getInstance(Locale locale) {
0N/A
0N/A // Check whether a provider can provide an implementation that's closer
0N/A // to the requested locale than what the Java runtime itself can provide.
0N/A LocaleServiceProviderPool pool =
0N/A LocaleServiceProviderPool.getPool(DecimalFormatSymbolsProvider.class);
0N/A if (pool.hasProviders()) {
0N/A DecimalFormatSymbols providersInstance = pool.getLocalizedObject(
0N/A DecimalFormatSymbolsGetter.INSTANCE, locale);
0N/A if (providersInstance != null) {
0N/A return providersInstance;
0N/A }
0N/A }
0N/A
0N/A return new DecimalFormatSymbols(locale);
0N/A }
0N/A
0N/A /**
0N/A * Gets the character used for zero. Different for Arabic, etc.
0N/A */
0N/A public char getZeroDigit() {
0N/A return zeroDigit;
0N/A }
0N/A
0N/A /**
0N/A * Sets the character used for zero. Different for Arabic, etc.
0N/A */
0N/A public void setZeroDigit(char zeroDigit) {
0N/A this.zeroDigit = zeroDigit;
0N/A }
0N/A
0N/A /**
0N/A * Gets the character used for thousands separator. Different for French, etc.
0N/A */
0N/A public char getGroupingSeparator() {
0N/A return groupingSeparator;
0N/A }
0N/A
0N/A /**
0N/A * Sets the character used for thousands separator. Different for French, etc.
0N/A */
0N/A public void setGroupingSeparator(char groupingSeparator) {
0N/A this.groupingSeparator = groupingSeparator;
0N/A }
0N/A
0N/A /**
0N/A * Gets the character used for decimal sign. Different for French, etc.
0N/A */
0N/A public char getDecimalSeparator() {
0N/A return decimalSeparator;
0N/A }
0N/A
0N/A /**
0N/A * Sets the character used for decimal sign. Different for French, etc.
0N/A */
0N/A public void setDecimalSeparator(char decimalSeparator) {
0N/A this.decimalSeparator = decimalSeparator;
0N/A }
0N/A
0N/A /**
0N/A * Gets the character used for per mille sign. Different for Arabic, etc.
0N/A */
0N/A public char getPerMill() {
0N/A return perMill;
0N/A }
0N/A
0N/A /**
0N/A * Sets the character used for per mille sign. Different for Arabic, etc.
0N/A */
0N/A public void setPerMill(char perMill) {
0N/A this.perMill = perMill;
0N/A }
0N/A
0N/A /**
0N/A * Gets the character used for percent sign. Different for Arabic, etc.
0N/A */
0N/A public char getPercent() {
0N/A return percent;
0N/A }
0N/A
0N/A /**
0N/A * Sets the character used for percent sign. Different for Arabic, etc.
0N/A */
0N/A public void setPercent(char percent) {
0N/A this.percent = percent;
0N/A }
0N/A
0N/A /**
0N/A * Gets the character used for a digit in a pattern.
0N/A */
0N/A public char getDigit() {
0N/A return digit;
0N/A }
0N/A
0N/A /**
0N/A * Sets the character used for a digit in a pattern.
0N/A */
0N/A public void setDigit(char digit) {
0N/A this.digit = digit;
0N/A }
0N/A
0N/A /**
0N/A * Gets the character used to separate positive and negative subpatterns
0N/A * in a pattern.
0N/A */
0N/A public char getPatternSeparator() {
0N/A return patternSeparator;
0N/A }
0N/A
0N/A /**
0N/A * Sets the character used to separate positive and negative subpatterns
0N/A * in a pattern.
0N/A */
0N/A public void setPatternSeparator(char patternSeparator) {
0N/A this.patternSeparator = patternSeparator;
0N/A }
0N/A
0N/A /**
0N/A * Gets the string used to represent infinity. Almost always left
0N/A * unchanged.
0N/A */
0N/A public String getInfinity() {
0N/A return infinity;
0N/A }
0N/A
0N/A /**
0N/A * Sets the string used to represent infinity. Almost always left
0N/A * unchanged.
0N/A */
0N/A public void setInfinity(String infinity) {
0N/A this.infinity = infinity;
0N/A }
0N/A
0N/A /**
0N/A * Gets the string used to represent "not a number". Almost always left
0N/A * unchanged.
0N/A */
0N/A public String getNaN() {
0N/A return NaN;
0N/A }
0N/A
0N/A /**
0N/A * Sets the string used to represent "not a number". Almost always left
0N/A * unchanged.
0N/A */
0N/A public void setNaN(String NaN) {
0N/A this.NaN = NaN;
0N/A }
0N/A
0N/A /**
0N/A * Gets the character used to represent minus sign. If no explicit
0N/A * negative format is specified, one is formed by prefixing
0N/A * minusSign to the positive format.
0N/A */
0N/A public char getMinusSign() {
0N/A return minusSign;
0N/A }
0N/A
0N/A /**
0N/A * Sets the character used to represent minus sign. If no explicit
0N/A * negative format is specified, one is formed by prefixing
0N/A * minusSign to the positive format.
0N/A */
0N/A public void setMinusSign(char minusSign) {
0N/A this.minusSign = minusSign;
0N/A }
0N/A
0N/A /**
0N/A * Returns the currency symbol for the currency of these
0N/A * DecimalFormatSymbols in their locale.
0N/A * @since 1.2
0N/A */
0N/A public String getCurrencySymbol()
0N/A {
0N/A return currencySymbol;
0N/A }
0N/A
0N/A /**
0N/A * Sets the currency symbol for the currency of these
0N/A * DecimalFormatSymbols in their locale.
0N/A * @since 1.2
0N/A */
0N/A public void setCurrencySymbol(String currency)
0N/A {
0N/A currencySymbol = currency;
0N/A }
0N/A
0N/A /**
0N/A * Returns the ISO 4217 currency code of the currency of these
0N/A * DecimalFormatSymbols.
0N/A * @since 1.2
0N/A */
0N/A public String getInternationalCurrencySymbol()
0N/A {
0N/A return intlCurrencySymbol;
0N/A }
0N/A
0N/A /**
0N/A * Sets the ISO 4217 currency code of the currency of these
0N/A * DecimalFormatSymbols.
0N/A * If the currency code is valid (as defined by
0N/A * {@link java.util.Currency#getInstance(java.lang.String) Currency.getInstance}),
0N/A * this also sets the currency attribute to the corresponding Currency
0N/A * instance and the currency symbol attribute to the currency's symbol
0N/A * in the DecimalFormatSymbols' locale. If the currency code is not valid,
0N/A * then the currency attribute is set to null and the currency symbol
0N/A * attribute is not modified.
0N/A *
0N/A * @see #setCurrency
0N/A * @see #setCurrencySymbol
0N/A * @since 1.2
0N/A */
0N/A public void setInternationalCurrencySymbol(String currencyCode)
0N/A {
0N/A intlCurrencySymbol = currencyCode;
0N/A currency = null;
0N/A if (currencyCode != null) {
0N/A try {
0N/A currency = Currency.getInstance(currencyCode);
0N/A currencySymbol = currency.getSymbol();
0N/A } catch (IllegalArgumentException e) {
0N/A }
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Gets the currency of these DecimalFormatSymbols. May be null if the
0N/A * currency symbol attribute was previously set to a value that's not
0N/A * a valid ISO 4217 currency code.
0N/A *
0N/A * @return the currency used, or null
0N/A * @since 1.4
0N/A */
0N/A public Currency getCurrency() {
0N/A return currency;
0N/A }
0N/A
0N/A /**
0N/A * Sets the currency of these DecimalFormatSymbols.
0N/A * This also sets the currency symbol attribute to the currency's symbol
0N/A * in the DecimalFormatSymbols' locale, and the international currency
0N/A * symbol attribute to the currency's ISO 4217 currency code.
0N/A *
0N/A * @param currency the new currency to be used
0N/A * @exception NullPointerException if <code>currency</code> is null
0N/A * @since 1.4
0N/A * @see #setCurrencySymbol
0N/A * @see #setInternationalCurrencySymbol
0N/A */
0N/A public void setCurrency(Currency currency) {
0N/A if (currency == null) {
0N/A throw new NullPointerException();
0N/A }
0N/A this.currency = currency;
0N/A intlCurrencySymbol = currency.getCurrencyCode();
0N/A currencySymbol = currency.getSymbol(locale);
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Returns the monetary decimal separator.
0N/A * @since 1.2
0N/A */
0N/A public char getMonetaryDecimalSeparator()
0N/A {
0N/A return monetarySeparator;
0N/A }
0N/A
0N/A /**
0N/A * Sets the monetary decimal separator.
0N/A * @since 1.2
0N/A */
0N/A public void setMonetaryDecimalSeparator(char sep)
0N/A {
0N/A monetarySeparator = sep;
0N/A }
0N/A
0N/A //------------------------------------------------------------
0N/A // BEGIN Package Private methods ... to be made public later
0N/A //------------------------------------------------------------
0N/A
0N/A /**
0N/A * Returns the character used to separate the mantissa from the exponent.
0N/A */
0N/A char getExponentialSymbol()
0N/A {
0N/A return exponential;
0N/A }
0N/A /**
0N/A * Returns the string used to separate the mantissa from the exponent.
0N/A * Examples: "x10^" for 1.23x10^4, "E" for 1.23E4.
0N/A *
0N/A * @return the exponent separator string
0N/A * @see #setExponentSeparator(java.lang.String)
0N/A * @since 1.6
0N/A */
0N/A public String getExponentSeparator()
0N/A {
0N/A return exponentialSeparator;
0N/A }
0N/A
0N/A /**
0N/A * Sets the character used to separate the mantissa from the exponent.
0N/A */
0N/A void setExponentialSymbol(char exp)
0N/A {
0N/A exponential = exp;
0N/A }
0N/A
0N/A /**
0N/A * Sets the string used to separate the mantissa from the exponent.
0N/A * Examples: "x10^" for 1.23x10^4, "E" for 1.23E4.
0N/A *
0N/A * @param exp the exponent separator string
0N/A * @exception NullPointerException if <code>exp</code> is null
0N/A * @see #getExponentSeparator()
0N/A * @since 1.6
0N/A */
0N/A public void setExponentSeparator(String exp)
0N/A {
0N/A if (exp == null) {
0N/A throw new NullPointerException();
0N/A }
0N/A exponentialSeparator = exp;
0N/A }
0N/A
0N/A
0N/A //------------------------------------------------------------
0N/A // END Package Private methods ... to be made public later
0N/A //------------------------------------------------------------
0N/A
0N/A /**
0N/A * Standard override.
0N/A */
0N/A public Object clone() {
0N/A try {
0N/A return (DecimalFormatSymbols)super.clone();
0N/A // other fields are bit-copied
0N/A } catch (CloneNotSupportedException e) {
0N/A throw new InternalError();
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Override equals.
0N/A */
0N/A public boolean equals(Object obj) {
0N/A if (obj == null) return false;
0N/A if (this == obj) return true;
0N/A if (getClass() != obj.getClass()) return false;
0N/A DecimalFormatSymbols other = (DecimalFormatSymbols) obj;
0N/A return (zeroDigit == other.zeroDigit &&
0N/A groupingSeparator == other.groupingSeparator &&
0N/A decimalSeparator == other.decimalSeparator &&
0N/A percent == other.percent &&
0N/A perMill == other.perMill &&
0N/A digit == other.digit &&
0N/A minusSign == other.minusSign &&
0N/A patternSeparator == other.patternSeparator &&
0N/A infinity.equals(other.infinity) &&
0N/A NaN.equals(other.NaN) &&
0N/A currencySymbol.equals(other.currencySymbol) &&
0N/A intlCurrencySymbol.equals(other.intlCurrencySymbol) &&
0N/A currency == other.currency &&
0N/A monetarySeparator == other.monetarySeparator &&
0N/A exponentialSeparator.equals(other.exponentialSeparator) &&
0N/A locale.equals(other.locale));
0N/A }
0N/A
0N/A /**
0N/A * Override hashCode.
0N/A */
0N/A public int hashCode() {
0N/A int result = zeroDigit;
0N/A result = result * 37 + groupingSeparator;
0N/A result = result * 37 + decimalSeparator;
0N/A return result;
0N/A }
0N/A
0N/A /**
0N/A * Initializes the symbols from the FormatData resource bundle.
0N/A */
0N/A private void initialize( Locale locale ) {
0N/A this.locale = locale;
0N/A
0N/A // get resource bundle data - try the cache first
0N/A boolean needCacheUpdate = false;
2712N/A Object[] data = cachedLocaleData.get(locale);
0N/A if (data == null) { /* cache miss */
2712N/A // When numbering system is thai (Locale's extension contains u-nu-thai),
2712N/A // we read the data from th_TH_TH.
2712N/A Locale lookupLocale = locale;
2712N/A String numberType = locale.getUnicodeLocaleType("nu");
2712N/A if (numberType != null && numberType.equals("thai")) {
2712N/A lookupLocale = new Locale("th", "TH", "TH");
2712N/A }
0N/A data = new Object[3];
2712N/A ResourceBundle rb = LocaleData.getNumberFormatData(lookupLocale);
0N/A data[0] = rb.getStringArray("NumberElements");
0N/A needCacheUpdate = true;
0N/A }
0N/A
0N/A String[] numberElements = (String[]) data[0];
0N/A
0N/A decimalSeparator = numberElements[0].charAt(0);
0N/A groupingSeparator = numberElements[1].charAt(0);
0N/A patternSeparator = numberElements[2].charAt(0);
0N/A percent = numberElements[3].charAt(0);
0N/A zeroDigit = numberElements[4].charAt(0); //different for Arabic,etc.
0N/A digit = numberElements[5].charAt(0);
0N/A minusSign = numberElements[6].charAt(0);
0N/A exponential = numberElements[7].charAt(0);
0N/A exponentialSeparator = numberElements[7]; //string representation new since 1.6
0N/A perMill = numberElements[8].charAt(0);
0N/A infinity = numberElements[9];
0N/A NaN = numberElements[10];
0N/A
0N/A // Try to obtain the currency used in the locale's country.
0N/A // Check for empty country string separately because it's a valid
0N/A // country ID for Locale (and used for the C locale), but not a valid
0N/A // ISO 3166 country code, and exceptions are expensive.
0N/A if (!"".equals(locale.getCountry())) {
0N/A try {
0N/A currency = Currency.getInstance(locale);
0N/A } catch (IllegalArgumentException e) {
0N/A // use default values below for compatibility
0N/A }
0N/A }
0N/A if (currency != null) {
0N/A intlCurrencySymbol = currency.getCurrencyCode();
0N/A if (data[1] != null && data[1] == intlCurrencySymbol) {
0N/A currencySymbol = (String) data[2];
0N/A } else {
0N/A currencySymbol = currency.getSymbol(locale);
0N/A data[1] = intlCurrencySymbol;
0N/A data[2] = currencySymbol;
0N/A needCacheUpdate = true;
0N/A }
0N/A } else {
0N/A // default values
0N/A intlCurrencySymbol = "XXX";
0N/A try {
0N/A currency = Currency.getInstance(intlCurrencySymbol);
0N/A } catch (IllegalArgumentException e) {
0N/A }
0N/A currencySymbol = "\u00A4";
0N/A }
0N/A // Currently the monetary decimal separator is the same as the
0N/A // standard decimal separator for all locales that we support.
0N/A // If that changes, add a new entry to NumberElements.
0N/A monetarySeparator = decimalSeparator;
0N/A
0N/A if (needCacheUpdate) {
2712N/A cachedLocaleData.putIfAbsent(locale, data);
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Reads the default serializable fields, provides default values for objects
0N/A * in older serial versions, and initializes non-serializable fields.
0N/A * If <code>serialVersionOnStream</code>
0N/A * is less than 1, initializes <code>monetarySeparator</code> to be
0N/A * the same as <code>decimalSeparator</code> and <code>exponential</code>
0N/A * to be 'E'.
0N/A * If <code>serialVersionOnStream</code> is less than 2,
0N/A * initializes <code>locale</code>to the root locale, and initializes
0N/A * If <code>serialVersionOnStream</code> is less than 3, it initializes
0N/A * <code>exponentialSeparator</code> using <code>exponential</code>.
0N/A * Sets <code>serialVersionOnStream</code> back to the maximum allowed value so that
0N/A * default serialization will work properly if this object is streamed out again.
0N/A * Initializes the currency from the intlCurrencySymbol field.
0N/A *
0N/A * @since JDK 1.1.6
0N/A */
0N/A private void readObject(ObjectInputStream stream)
0N/A throws IOException, ClassNotFoundException {
0N/A stream.defaultReadObject();
0N/A if (serialVersionOnStream < 1) {
0N/A // Didn't have monetarySeparator or exponential field;
0N/A // use defaults.
0N/A monetarySeparator = decimalSeparator;
0N/A exponential = 'E';
0N/A }
0N/A if (serialVersionOnStream < 2) {
0N/A // didn't have locale; use root locale
0N/A locale = Locale.ROOT;
0N/A }
0N/A if (serialVersionOnStream < 3) {
0N/A // didn't have exponentialSeparator. Create one using exponential
0N/A exponentialSeparator = Character.toString(exponential);
0N/A }
0N/A serialVersionOnStream = currentSerialVersion;
0N/A
0N/A if (intlCurrencySymbol != null) {
0N/A try {
0N/A currency = Currency.getInstance(intlCurrencySymbol);
0N/A } catch (IllegalArgumentException e) {
0N/A }
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Character used for zero.
0N/A *
0N/A * @serial
0N/A * @see #getZeroDigit
0N/A */
0N/A private char zeroDigit;
0N/A
0N/A /**
0N/A * Character used for thousands separator.
0N/A *
0N/A * @serial
0N/A * @see #getGroupingSeparator
0N/A */
0N/A private char groupingSeparator;
0N/A
0N/A /**
0N/A * Character used for decimal sign.
0N/A *
0N/A * @serial
0N/A * @see #getDecimalSeparator
0N/A */
0N/A private char decimalSeparator;
0N/A
0N/A /**
0N/A * Character used for per mille sign.
0N/A *
0N/A * @serial
0N/A * @see #getPerMill
0N/A */
0N/A private char perMill;
0N/A
0N/A /**
0N/A * Character used for percent sign.
0N/A * @serial
0N/A * @see #getPercent
0N/A */
0N/A private char percent;
0N/A
0N/A /**
0N/A * Character used for a digit in a pattern.
0N/A *
0N/A * @serial
0N/A * @see #getDigit
0N/A */
0N/A private char digit;
0N/A
0N/A /**
0N/A * Character used to separate positive and negative subpatterns
0N/A * in a pattern.
0N/A *
0N/A * @serial
0N/A * @see #getPatternSeparator
0N/A */
0N/A private char patternSeparator;
0N/A
0N/A /**
0N/A * String used to represent infinity.
0N/A * @serial
0N/A * @see #getInfinity
0N/A */
0N/A private String infinity;
0N/A
0N/A /**
0N/A * String used to represent "not a number".
0N/A * @serial
0N/A * @see #getNaN
0N/A */
0N/A private String NaN;
0N/A
0N/A /**
0N/A * Character used to represent minus sign.
0N/A * @serial
0N/A * @see #getMinusSign
0N/A */
0N/A private char minusSign;
0N/A
0N/A /**
0N/A * String denoting the local currency, e.g. "$".
0N/A * @serial
0N/A * @see #getCurrencySymbol
0N/A */
0N/A private String currencySymbol;
0N/A
0N/A /**
0N/A * ISO 4217 currency code denoting the local currency, e.g. "USD".
0N/A * @serial
0N/A * @see #getInternationalCurrencySymbol
0N/A */
0N/A private String intlCurrencySymbol;
0N/A
0N/A /**
0N/A * The decimal separator used when formatting currency values.
0N/A * @serial
0N/A * @since JDK 1.1.6
0N/A * @see #getMonetaryDecimalSeparator
0N/A */
0N/A private char monetarySeparator; // Field new in JDK 1.1.6
0N/A
0N/A /**
0N/A * The character used to distinguish the exponent in a number formatted
0N/A * in exponential notation, e.g. 'E' for a number such as "1.23E45".
0N/A * <p>
0N/A * Note that the public API provides no way to set this field,
0N/A * even though it is supported by the implementation and the stream format.
0N/A * The intent is that this will be added to the API in the future.
0N/A *
0N/A * @serial
0N/A * @since JDK 1.1.6
0N/A */
0N/A private char exponential; // Field new in JDK 1.1.6
0N/A
0N/A /**
0N/A * The string used to separate the mantissa from the exponent.
0N/A * Examples: "x10^" for 1.23x10^4, "E" for 1.23E4.
0N/A * <p>
0N/A * If both <code>exponential</code> and <code>exponentialSeparator</code>
0N/A * exist, this <code>exponentialSeparator</code> has the precedence.
0N/A *
0N/A * @serial
0N/A * @since 1.6
0N/A */
0N/A private String exponentialSeparator; // Field new in JDK 1.6
0N/A
0N/A /**
0N/A * The locale of these currency format symbols.
0N/A *
0N/A * @serial
0N/A * @since 1.4
0N/A */
0N/A private Locale locale;
0N/A
0N/A // currency; only the ISO code is serialized.
0N/A private transient Currency currency;
0N/A
0N/A // Proclaim JDK 1.1 FCS compatibility
0N/A static final long serialVersionUID = 5772796243397350300L;
0N/A
0N/A // The internal serial version which says which version was written
0N/A // - 0 (default) for version up to JDK 1.1.5
0N/A // - 1 for version from JDK 1.1.6, which includes two new fields:
0N/A // monetarySeparator and exponential.
0N/A // - 2 for version from J2SE 1.4, which includes locale field.
0N/A // - 3 for version from J2SE 1.6, which includes exponentialSeparator field.
0N/A private static final int currentSerialVersion = 3;
0N/A
0N/A /**
0N/A * Describes the version of <code>DecimalFormatSymbols</code> present on the stream.
0N/A * Possible values are:
0N/A * <ul>
0N/A * <li><b>0</b> (or uninitialized): versions prior to JDK 1.1.6.
0N/A *
0N/A * <li><b>1</b>: Versions written by JDK 1.1.6 or later, which include
0N/A * two new fields: <code>monetarySeparator</code> and <code>exponential</code>.
0N/A * <li><b>2</b>: Versions written by J2SE 1.4 or later, which include a
0N/A * new <code>locale</code> field.
0N/A * <li><b>3</b>: Versions written by J2SE 1.6 or later, which include a
0N/A * new <code>exponentialSeparator</code> field.
0N/A * </ul>
0N/A * When streaming out a <code>DecimalFormatSymbols</code>, the most recent format
0N/A * (corresponding to the highest allowable <code>serialVersionOnStream</code>)
0N/A * is always written.
0N/A *
0N/A * @serial
0N/A * @since JDK 1.1.6
0N/A */
0N/A private int serialVersionOnStream = currentSerialVersion;
0N/A
0N/A /**
0N/A * cache to hold the NumberElements and the Currency
0N/A * of a Locale.
0N/A */
2712N/A private static final ConcurrentHashMap<Locale, Object[]> cachedLocaleData = new ConcurrentHashMap<Locale, Object[]>(3);
0N/A
0N/A /**
0N/A * Obtains a DecimalFormatSymbols instance from a DecimalFormatSymbolsProvider
0N/A * implementation.
0N/A */
0N/A private static class DecimalFormatSymbolsGetter
0N/A implements LocaleServiceProviderPool.LocalizedObjectGetter<DecimalFormatSymbolsProvider,
0N/A DecimalFormatSymbols> {
0N/A private static final DecimalFormatSymbolsGetter INSTANCE =
0N/A new DecimalFormatSymbolsGetter();
0N/A
0N/A public DecimalFormatSymbols getObject(
0N/A DecimalFormatSymbolsProvider decimalFormatSymbolsProvider,
0N/A Locale locale,
0N/A String key,
0N/A Object... params) {
0N/A assert params.length == 0;
0N/A return decimalFormatSymbolsProvider.getInstance(locale);
0N/A }
0N/A }
0N/A}