/** * Duplicates this formatter. * @return A RuleBasedNumberFormat that is equal to this one. * @stable ICU 2.0 */ @Override public Object clone() { return super.clone(); }
/** * Returns a copy of the NumberFormat this object is using. * @return A copy of the NumberFormat. * @stable ICU 53 */ public NumberFormat getNumberFormat() { // This class is thread-safe, yet numberFormat is not. To ensure thread-safety of this // class we must guarantee that only one thread at a time uses our numberFormat. synchronized (numberFormat) { return (NumberFormat) numberFormat.clone(); } }
public synchronized NumberFormat get() { return (NumberFormat) nf.clone(); }
public ImmutableNumberFormat(NumberFormat nf) { this.nf = (NumberFormat) nf.clone(); }
@Override public Object clone() { DateNumberFormat dnfmt = (DateNumberFormat)super.clone(); dnfmt.digits = this.digits.clone(); dnfmt.decimalBuf = new char[DECIMAL_BUF_SIZE]; return dnfmt; } }
/** * {@inheritDoc} */ @Override public Object clone() { CurrencyFormat result = (CurrencyFormat) super.clone(); result.fmt = (NumberFormat) fmt.clone(); return result; }
@Override public Object clone() { NumberFormatJDK other = (NumberFormatJDK)super.clone(); other.fJdkNfmt = (NumberFormat)fJdkNfmt.clone(); return other; }
@Override public Object clone() { NumberFormatICU other = (NumberFormatICU)super.clone(); other.fIcuNfmt = (NumberFormat)fIcuNfmt.clone(); return other; }
/** * @internal * @deprecated This API is ICU internal only. */ @Deprecated @Override public Object clone() { TimeUnitFormat result = (TimeUnitFormat) super.clone(); result.format = (NumberFormat) format.clone(); return result; } // End boilerplate.
private TimeUnitFormat(ULocale locale, int style, NumberFormat numberFormat) { this(locale, style); if (numberFormat != null) { setNumberFormat((NumberFormat) numberFormat.clone()); } }
/** * Sets a number format explicitly. Overrides the general locale settings. * * @param style NF_NUMBER, NF_CURRENCY, NF_PERCENT, NF_SCIENTIFIC, NF_INTEGER * @param format The number format * @return this, for chaining * @draft ICU 3.6 * @provisional This API might change or be removed in a future release. */ public GlobalizationPreferences setNumberFormat(int style, NumberFormat format) { if (isFrozen()) { throw new UnsupportedOperationException("Attempt to modify immutable object"); } if (numberFormats == null) { numberFormats = new NumberFormat[NF_LIMIT]; } numberFormats[style] = (NumberFormat) format.clone(); // for safety return this; }
/** * Gets a number format according to the current settings. If * there is an explicit (non-null) number format set, a copy of * that is returned. Otherwise, the language priority list is * used. * * @param style NF_NUMBER, NF_CURRENCY, NF_PERCENT, NF_SCIENTIFIC, NF_INTEGER * @draft ICU 3.6 * @provisional This API might change or be removed in a future release. */ public NumberFormat getNumberFormat(int style) { if (style < 0 || style >= NF_LIMIT) { throw new IllegalArgumentException("Illegal number format type"); } NumberFormat result = null; if (numberFormats != null) { result = numberFormats[style]; } if (result != null) { result = (NumberFormat) result.clone(); // clone for safety (later optimize) } else { result = guessNumberFormat(style); } return result; }
/** * Overrides clone. * @stable ICU 2.0 */ @Override public Object clone() { DateFormat other = (DateFormat) super.clone(); other.calendar = (Calendar) calendar.clone(); if (numberFormat != null) { other.numberFormat = (NumberFormat) numberFormat.clone(); } return other; }
stockDateFormatter == null ? null : (DateFormat) stockDateFormatter.clone(); other.stockNumberFormatter = stockNumberFormatter == null ? null : (NumberFormat) stockNumberFormatter.clone();
/** * Overrides clone. * @stable ICU 2.0 */ @Override public Object clone() { try { DecimalFormat other = (DecimalFormat) super.clone(); other.symbols = (DecimalFormatSymbols) symbols.clone(); other.digitList = new DigitList(); // fix for JB#5358 if (currencyPluralInfo != null) { other.currencyPluralInfo = (CurrencyPluralInfo) currencyPluralInfo.clone(); } other.attributes = new ArrayList<FieldPosition>(); // #9240 other.currencyUsage = currencyUsage; // TODO: We need to figure out whether we share a single copy of DigitList by // multiple cloned copies. format/subformat are designed to use a single // instance, but parse/subparse implementation is not. return other; } catch (Exception e) { throw new IllegalStateException(); } }
NumberFormat createInstance(ULocale desiredLocale, int choice) { // use service cache // if (service.isDefault()) { // return NumberFormat.createInstance(desiredLocale, choice); // } ULocale[] actualLoc = new ULocale[1]; NumberFormat fmt = (NumberFormat)service.get(desiredLocale, choice, actualLoc); if (fmt == null) { throw new MissingResourceException("Unable to construct NumberFormat", "", ""); } fmt = (NumberFormat)fmt.clone(); // If we are creating a currency type formatter, then we may have to set the currency // explicitly, since the actualLoc may be different than the desiredLocale if ( choice == NumberFormat.CURRENCYSTYLE || choice == NumberFormat.ISOCURRENCYSTYLE || choice == NumberFormat.PLURALCURRENCYSTYLE) { fmt.setCurrency(Currency.getInstance(desiredLocale)); } ULocale uloc = actualLoc[0]; fmt.setLocale(uloc, uloc); // services make no distinction between actual & valid return fmt; }
nf = NumberFormat.getInstance(locale); } else { nf = (NumberFormat) nf.clone();