// A very slow but safe implementation.
return getWidth() == rhs.getWidth()
&& getLocale().equals(rhs.getLocale())
- && getNumberFormat().equals(rhs.getNumberFormat());
+ && getNumberFormatInternal().equals(rhs.getNumberFormatInternal());
}
/**
@Override
public final int hashCode() {
// A very slow but safe implementation.
- return (getLocale().hashCode() * 31 + getNumberFormat().hashCode()) * 31 + getWidth().hashCode();
+ return (getLocale().hashCode() * 31 + getNumberFormatInternal().hashCode()) * 31 + getWidth().hashCode();
}
/**
return (NumberFormat) numberFormat.clone();
}
+ /**
+ * Get a copy of the number format without cloning. Internal method.
+ */
+ NumberFormat getNumberFormatInternal() {
+ return numberFormat;
+ }
+
/**
* Return a formatter for CurrencyAmount objects in the given locale.
*
}
Object toTimeUnitProxy() {
- return new MeasureProxy(getLocale(), formatWidth, getNumberFormat(), TIME_UNIT_FORMAT);
+ return new MeasureProxy(getLocale(), formatWidth, getNumberFormatInternal(), TIME_UNIT_FORMAT);
}
Object toCurrencyProxy() {
- return new MeasureProxy(getLocale(), formatWidth, getNumberFormat(), CURRENCY_FORMAT);
+ return new MeasureProxy(getLocale(), formatWidth, getNumberFormatInternal(), CURRENCY_FORMAT);
}
private Object writeReplace() throws ObjectStreamException {
- return new MeasureProxy(getLocale(), formatWidth, getNumberFormat(), MEASURE_FORMAT);
+ return new MeasureProxy(getLocale(), formatWidth, getNumberFormatInternal(), MEASURE_FORMAT);
}
static class MeasureProxy implements Externalizable {
@Deprecated
public TimeUnitFormat(ULocale locale, int style) {
super(locale, style == FULL_NAME ? FormatWidth.WIDE : FormatWidth.SHORT);
- format = super.getNumberFormat();
+ format = super.getNumberFormatInternal();
if (style < FULL_NAME || style >= TOTAL_STYLES) {
throw new IllegalArgumentException("style should be either FULL_NAME or ABBREVIATED_NAME style");
}
@Override
public NumberFormat getNumberFormat() {
+ return (NumberFormat) format.clone();
+ }
+
+ @Override
+ NumberFormat getNumberFormatInternal() {
return format;
}