Esempio n. 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());
        }
Esempio n. 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);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Answers a new DecimalFormatSymbols with the same symbols as this
 /// DecimalFormatSymbols.
 /// </summary>
 ///
 /// <returns>a shallow copy of this DecimalFormatSymbols</returns>
 /// <seealso cref="T:System.ICloneable"/>
 public Object Clone()
 {
     try {
         DecimalFormatSymbols symbols = (DecimalFormatSymbols)base.MemberwiseClone();
         symbols.patternChars = (char[])patternChars.Clone();
         return(symbols);
     } catch (Exception e) {
         return(null);
     }
 }
Esempio n. 4
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());
        }
Esempio n. 5
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());
        }
Esempio n. 6
0
        /// <summary>
        /// Compares the specified object to this DecimalFormatSymbols and answer if
        /// they are equal. The object must be an instance of DecimalFormatSymbols
        /// with the same symbols.
        /// </summary>
        ///
        /// <param name="object">the object to compare with this object</param>
        /// <returns>true if the specified object is equal to this
        /// DecimalFormatSymbols, false otherwise</returns>
        /// <seealso cref="M:System.Globalization.NumberFormatInfo.HashCode"/>
        public override bool Equals(Object obj0)
        {
            if ((Object)this == obj0)
            {
                return(true);
            }
            if (!(obj0   is  NumberFormatInfo))
            {
                return(false);
            }
            DecimalFormatSymbols obj = (DecimalFormatSymbols)obj0;

            return(ILOG.J2CsMapping.Collections.Arrays.Equals(patternChars, obj.patternChars) &&
                   infinity.Equals(obj.infinity) && NaN.Equals(obj.NaN) &&
                   currencySymbol.Equals(obj.currencySymbol) &&
                   intlCurrencySymbol.Equals(obj.intlCurrencySymbol));
        }