decimalformatsymbols.java

来自「This is a resource based on j2me embedde」· Java 代码 · 共 685 行 · 第 1/2 页

JAVA
685
字号
/* *  * @(#)DecimalFormatSymbols.java	1.38 06/10/10 *  * Portions Copyright  2000-2008 Sun Microsystems, Inc. All Rights * Reserved.  Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER *  * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 only, as published by the Free Software Foundation. *  * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License version 2 for more details (a copy is * included at /legal/license.txt). *  * You should have received a copy of the GNU General Public License * version 2 along with this work; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA *  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 or visit www.sun.com if you need additional * information or have any questions. *//* * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved * (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved * *   The original version of this source code and documentation is copyrighted * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These * materials are provided under terms of a License Agreement between Taligent * and Sun. This technology is protected by multiple US and International * patents. This notice and attribution to Taligent may not be removed. *   Taligent is a registered trademark of Taligent, Inc. * */package java.text;import java.io.IOException;import java.io.ObjectInputStream;import java.io.Serializable;import java.util.Currency;import java.util.Hashtable;import java.util.Locale;import java.util.ResourceBundle;import sun.text.resources.LocaleData;/** * This class represents the set of symbols (such as the decimal separator, * the grouping separator, and so on) needed by <code>DecimalFormat</code> * to format numbers. <code>DecimalFormat</code> creates for itself an instance of * <code>DecimalFormatSymbols</code> from its locale data.  If you need to change any * of these symbols, you can get the <code>DecimalFormatSymbols</code> object from * your <code>DecimalFormat</code> and modify it. * * @see          java.util.Locale * @see          DecimalFormat * @version      1.39, 01/23/03 * @author       Mark Davis * @author       Alan Liu */final public class DecimalFormatSymbols implements Cloneable, Serializable {    /**     * Create a DecimalFormatSymbols object for the default locale.     */    public DecimalFormatSymbols() {        initialize( Locale.getDefault() );    }    /**     * Create a DecimalFormatSymbols object for the given locale.     *     * @exception NullPointerException if <code>locale</code> is null     */    public DecimalFormatSymbols( Locale locale ) {        initialize( locale );    }    /**     * Gets the character used for zero. Different for Arabic, etc.     */    public char getZeroDigit() {        return zeroDigit;    }    /**     * Sets the character used for zero. Different for Arabic, etc.     */    public void setZeroDigit(char zeroDigit) {        this.zeroDigit = zeroDigit;    }    /**     * Gets the character used for thousands separator. Different for French, etc.     */    public char getGroupingSeparator() {        return groupingSeparator;    }    /**     * Sets the character used for thousands separator. Different for French, etc.     */    public void setGroupingSeparator(char groupingSeparator) {        this.groupingSeparator = groupingSeparator;    }    /**     * Gets the character used for decimal sign. Different for French, etc.     */    public char getDecimalSeparator() {        return decimalSeparator;    }    /**     * Sets the character used for decimal sign. Different for French, etc.     */    public void setDecimalSeparator(char decimalSeparator) {        this.decimalSeparator = decimalSeparator;    }    /**     * Gets the character used for mille percent sign. Different for Arabic, etc.     */    public char getPerMill() {        return perMill;    }    /**     * Sets the character used for mille percent sign. Different for Arabic, etc.     */    public void setPerMill(char perMill) {        this.perMill = perMill;    }    /**     * Gets the character used for percent sign. Different for Arabic, etc.     */    public char getPercent() {        return percent;    }    /**     * Sets the character used for percent sign. Different for Arabic, etc.     */    public void setPercent(char percent) {        this.percent = percent;    }    /**     * Gets the character used for a digit in a pattern.     */    public char getDigit() {        return digit;    }    /**     * Sets the character used for a digit in a pattern.     */    public void setDigit(char digit) {        this.digit = digit;    }    /**     * Gets the character used to separate positive and negative subpatterns     * in a pattern.     */    public char getPatternSeparator() {        return patternSeparator;    }    /**     * Sets the character used to separate positive and negative subpatterns     * in a pattern.     */    public void setPatternSeparator(char patternSeparator) {        this.patternSeparator = patternSeparator;    }    /**     * Gets the string used to represent infinity. Almost always left     * unchanged.     */    public String getInfinity() {        return infinity;    }    /**     * Sets the string used to represent infinity. Almost always left     * unchanged.     */    public void setInfinity(String infinity) {        this.infinity = infinity;    }    /**     * Gets the string used to represent "not a number". Almost always left     * unchanged.     */    public String getNaN() {        return NaN;    }    /**     * Sets the string used to represent "not a number". Almost always left     * unchanged.     */    public void setNaN(String NaN) {        this.NaN = NaN;    }    /**     * Gets the character used to represent minus sign. If no explicit     * negative format is specified, one is formed by prefixing     * minusSign to the positive format.     */    public char getMinusSign() {        return minusSign;    }    /**     * Sets the character used to represent minus sign. If no explicit     * negative format is specified, one is formed by prefixing     * minusSign to the positive format.     */    public void setMinusSign(char minusSign) {        this.minusSign = minusSign;    }    /**     * Returns the currency symbol for the currency of these     * DecimalFormatSymbols in their locale.     * @since 1.2     */    public String getCurrencySymbol()    {        return currencySymbol;    }    /**     * Sets the currency symbol for the currency of these     * DecimalFormatSymbols in their locale.     * @since 1.2     */    public void setCurrencySymbol(String currency)    {        currencySymbol = currency;    }    /**     * Returns the ISO 4217 currency code of the currency of these     * DecimalFormatSymbols.     * @since 1.2     */    public String getInternationalCurrencySymbol()    {        return intlCurrencySymbol;    }    /**     * Sets the ISO 4217 currency code of the currency of these     * DecimalFormatSymbols.     * If the currency code is valid (as defined by     * {@link java.util.Currency#getInstance(java.lang.String) Currency.getInstance}),     * this also sets the currency attribute to the corresponding Currency     * instance and the currency symbol attribute to the currency's symbol     * in the DecimalFormatSymbols' locale. If the currency code is not valid,     * then the currency attribute is set to null and the currency symbol     * attribute is not modified.     *     * @see #setCurrency     * @see #setCurrencySymbol     * @since 1.2     */    public void setInternationalCurrencySymbol(String currencyCode)    {        intlCurrencySymbol = currencyCode;        currency = null;        if (currencyCode != null) {            try {                currency = Currency.getInstance(currencyCode);                currencySymbol = currency.getSymbol();            } catch (IllegalArgumentException e) {            }        }    }        /**     * Gets the currency of these DecimalFormatSymbols. May be null if the     * currency symbol attribute was previously set to a value that's not     * a valid ISO 4217 currency code.     *     * @return the currency used, or null     * @since 1.4     */    public Currency getCurrency() {        return currency;    }        /**     * Sets the currency of these DecimalFormatSymbols.     * This also sets the currency symbol attribute to the currency's symbol     * in the DecimalFormatSymbols' locale, and the international currency     * symbol attribute to the currency's ISO 4217 currency code.     *     * @param currency the new currency to be used     * @exception NullPointerException if <code>currency</code> is null     * @since 1.4     * @see #setCurrencySymbol     * @see #setInternationalCurrencySymbol     */    public void setCurrency(Currency currency) {        if (currency == null) {            throw new NullPointerException();        }        this.currency = currency;        intlCurrencySymbol = currency.getCurrencyCode();        currencySymbol = currency.getSymbol(locale);    }        /**     * Returns the monetary decimal separator.     * @since 1.2     */    public char getMonetaryDecimalSeparator()    {        return monetarySeparator;    }    /**     * Sets the monetary decimal separator.     * @since 1.2     */    public void setMonetaryDecimalSeparator(char sep)    {        monetarySeparator = sep;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?