예제 #1
0
        /*
         * Copies decimal format symbols from text object to ICU one.
         *
         * @param icu the object which receives the new values. @param dfs the
         * object which contains the new values.
         */
        private void CopySymbols(IBM.ICU.Text.DecimalFormatSymbols icu,
                                 DecimalFormatSymbols dfs)
        {
            Currency currency = dfs.GetCurrency();

            if (currency == null)
            {
                icu.SetCurrency(IBM.ICU.Util.Currency.GetInstance("XXX"));
            }
            else
            {
                icu.SetCurrency(IBM.ICU.Util.Currency.GetInstance(dfs
                                                                  .GetCurrency().GetCurrencyCode()));
            }

            icu.SetCurrencySymbol(dfs.GetCurrencySymbol());
            //icu.SetDecimalSeparator(dfs.NumberDecimalSeparator[0]);
            icu.SetDigit(dfs.GetDigit());
            //icu.SetGroupingSeparator(dfs.NumberGroupSeparator[0]);
            icu.SetInfinity(dfs.GetInfinity());
            icu.SetInternationalCurrencySymbol(dfs.GetInternationalCurrencySymbol());
            icu.SetMinusSign(dfs.GetMinusSign());
            icu.SetMonetaryDecimalSeparator(dfs.GetMonetaryDecimalSeparator());
            icu.SetNaN(dfs.GetNaN());
            icu.SetPatternSeparator(dfs.GetPatternSeparator());
            icu.SetPercent(dfs.GetPercent());
            icu.SetPerMill(dfs.GetPerMill());
            icu.SetZeroDigit(dfs.GetZeroDigit());
        }
예제 #2
0
 /// <summary>
 /// Sets the DecimalFormatSymbols used by this DecimalFormat.
 /// </summary>
 ///
 /// <param name="value">the DecimalFormatSymbols</param>
 public void SetDecimalFormatSymbols(DecimalFormatSymbols value_ren)
 {
     if (value_ren != null)
     {
         symbols    = (DecimalFormatSymbols)value_ren.Clone();
         icuSymbols = dform.GetDecimalFormatSymbols();
         CopySymbols(icuSymbols, symbols);
         dform.SetDecimalFormatSymbols(icuSymbols);
     }
 }
예제 #3
0
        /// <summary>
        /// Constructs a new DecimalFormat for formatting and parsing numbers for the
        /// default Locale.
        /// </summary>
        ///
        public DecimalFormat()
        {
            this.parseBigDecimal       = false;
            this.serialVersionOnStream = 3;
            ILOG.J2CsMapping.Util.Locale locale = ILOG.J2CsMapping.Util.Locale.GetDefault();
            icuSymbols = new IBM.ICU.Text.DecimalFormatSymbols(locale);
            symbols    = new DecimalFormatSymbols(locale);
            dform      = new IBM.ICU.Text.DecimalFormat();

            base.SetMaximumFractionDigits(dform.GetMaximumFractionDigits());
            base.SetMaximumIntegerDigits(dform.GetMaximumIntegerDigits());
            base.SetMinimumFractionDigits(dform.GetMinimumFractionDigits());
            base.SetMinimumIntegerDigits(dform.GetMinimumIntegerDigits());
        }
예제 #4
0
        /// <summary>
        /// Constructs a new DecimalFormat using the specified non-localized pattern
        /// and DecimalFormatSymbols.
        /// </summary>
        ///
        /// <param name="pattern">the non-localized pattern</param>
        /// <param name="value">the DecimalFormatSymbols</param>
        /// <exception cref="IllegalArgumentException">when the pattern cannot be parsed</exception>
        public DecimalFormat(String pattern, DecimalFormatSymbols value_ren)
        {
            this.parseBigDecimal       = false;
            this.serialVersionOnStream = 3;
            symbols = (DecimalFormatSymbols)value_ren.Clone();
            ILOG.J2CsMapping.Util.Locale locale = symbols.GetLocale(); //$NON-NLS-1$
            icuSymbols = new IBM.ICU.Text.DecimalFormatSymbols(locale);
            CopySymbols(icuSymbols, symbols);

            dform = new IBM.ICU.Text.DecimalFormat(pattern, icuSymbols);

            base.SetMaximumFractionDigits(dform.GetMaximumFractionDigits());
            base.SetMaximumIntegerDigits(dform.GetMaximumIntegerDigits());
            base.SetMinimumFractionDigits(dform.GetMinimumFractionDigits());
            base.SetMinimumIntegerDigits(dform.GetMinimumIntegerDigits());
        }
예제 #5
0
 /// <summary>
 /// Constructs a new DecimalFormatSymbols containing the symbols for the
 /// specified Locale.
 /// </summary>
 ///
 /// <param name="locale_0">the Locale</param>
 public DecimalFormatSymbols(ILOG.J2CsMapping.Util.Locale locale_0)
 {
     this.ZeroDigit                = 0;
     this.Digit                    = 1;
     this.DecimalSeparator         = 2;
     this.GroupingSeparator        = 3;
     this.PatternSeparator         = 4;
     this.Percent                  = 5;
     this.PerMill                  = 6;
     this.Exponent                 = 7;
     this.MonetaryDecimalSeparator = 8;
     this.MinusSign                = 9;
     IBM.ICU.Text.DecimalFormatSymbols icuSymbols = new IBM.ICU.Text.DecimalFormatSymbols(
         locale_0);
     infinity           = icuSymbols.GetInfinity();
     NaN                = icuSymbols.GetNaN();
     this.locale        = locale_0;
     currencySymbol     = icuSymbols.GetCurrencySymbol();
     intlCurrencySymbol = icuSymbols.GetInternationalCurrencySymbol();
     if (locale_0.GetCountry().Length == 0)
     {
         currency = Currency.GetInstance("XXX");
     }
     else
     {
         currency = Currency.GetInstance(locale_0);
     }
     patternChars                           = new char[10];
     patternChars[ZeroDigit]                = icuSymbols.GetZeroDigit();
     patternChars[Digit]                    = icuSymbols.GetDigit();
     patternChars[DecimalSeparator]         = icuSymbols.GetDecimalSeparator();
     patternChars[GroupingSeparator]        = icuSymbols.GetGroupingSeparator();
     patternChars[PatternSeparator]         = icuSymbols.GetPatternSeparator();
     patternChars[Percent]                  = icuSymbols.GetPercent();
     patternChars[PerMill]                  = icuSymbols.GetPerMill();
     patternChars[Exponent]                 = icuSymbols.GetExponentSeparator()[0];
     patternChars[MonetaryDecimalSeparator] = icuSymbols
                                              .GetMonetaryDecimalSeparator();
     patternChars[MinusSign] = icuSymbols.GetMinusSign();
 }