mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-14 17:24:01 +00:00
ICU-10268 Restored Currency serialization backward compatibility support for now. Also fixed a bunch of compiler warnings (both Eclipse compiler and JDK) introduced by unit/measure format work.
X-SVN-Rev: 34132
This commit is contained in:
parent
3188fd4a62
commit
bc031bb637
5 changed files with 25 additions and 14 deletions
|
@ -31,8 +31,8 @@ import com.ibm.icu.util.FormatWidth;
|
|||
import com.ibm.icu.util.Measure;
|
||||
import com.ibm.icu.util.MeasureUnit;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
import com.ibm.icu.util.UResourceBundle;
|
||||
import com.ibm.icu.util.ULocale.Category;
|
||||
import com.ibm.icu.util.UResourceBundle;
|
||||
|
||||
/**
|
||||
* Mutable class for formatting GeneralMeasures, or sequences of them.
|
||||
|
@ -536,6 +536,8 @@ public class GeneralMeasureFormat extends MeasureFormat {
|
|||
}
|
||||
|
||||
static class GeneralMeasureProxy implements Externalizable {
|
||||
private static final long serialVersionUID = -6033308329886716770L;
|
||||
|
||||
private ULocale locale;
|
||||
private FormatWidth length;
|
||||
private NumberFormat numberFormat;
|
||||
|
@ -559,7 +561,7 @@ public class GeneralMeasureFormat extends MeasureFormat {
|
|||
}
|
||||
|
||||
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
|
||||
byte version = in.readByte(); // version
|
||||
/* byte version = */ in.readByte(); // version
|
||||
locale = (ULocale) in.readObject();
|
||||
length = (FormatWidth) in.readObject();
|
||||
numberFormat = (NumberFormat) in.readObject();
|
||||
|
|
|
@ -781,6 +781,10 @@ public class Currency extends MeasureUnit implements Serializable {
|
|||
*/
|
||||
protected Currency(String theISOCode) {
|
||||
super("currency", theISOCode);
|
||||
|
||||
// isoCode is kept for readResolve() and Currency class no longer
|
||||
// use it. So this statement actually does not have any effect.
|
||||
isoCode = code;
|
||||
}
|
||||
|
||||
// POW10[i] = 10^i
|
||||
|
@ -902,5 +906,15 @@ public class Currency extends MeasureUnit implements Serializable {
|
|||
private Object writeReplace() throws ObjectStreamException {
|
||||
return new MeasureUnitProxy(type, code);
|
||||
}
|
||||
|
||||
// For backward compatibility only
|
||||
/**
|
||||
* ISO 4217 3-letter code.
|
||||
*/
|
||||
private final String isoCode;
|
||||
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
return Currency.getInstance(isoCode);
|
||||
}
|
||||
}
|
||||
//eof
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2004-2013, Google Inc, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
* Copyright (C) 2004-2013, Google Inc, International Business Machines *
|
||||
* Corporation and others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.util;
|
||||
|
@ -14,7 +14,6 @@ import java.io.ObjectStreamException;
|
|||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -399,6 +398,8 @@ public class MeasureUnit implements Comparable<MeasureUnit>, Serializable {
|
|||
}
|
||||
|
||||
static final class MeasureUnitProxy implements Externalizable {
|
||||
private static final long serialVersionUID = -3910681415330989598L;
|
||||
|
||||
private String type;
|
||||
private String code;
|
||||
|
||||
|
|
|
@ -21,11 +21,9 @@ import java.util.TreeSet;
|
|||
|
||||
import com.ibm.icu.dev.test.TestFmwk;
|
||||
import com.ibm.icu.dev.test.serializable.SerializableTest;
|
||||
import com.ibm.icu.impl.CurrencyData.CurrencyFormatInfo;
|
||||
import com.ibm.icu.impl.Utility;
|
||||
import com.ibm.icu.text.DecimalFormat;
|
||||
import com.ibm.icu.text.GeneralMeasureFormat;
|
||||
import com.ibm.icu.text.MeasureFormat;
|
||||
import com.ibm.icu.text.NumberFormat;
|
||||
import com.ibm.icu.util.Currency;
|
||||
import com.ibm.icu.util.FormatWidth;
|
||||
|
|
|
@ -122,7 +122,7 @@ public class CompatibilityTest extends TestFmwk
|
|||
}
|
||||
|
||||
private static final String[][] SKIP_CASES = {
|
||||
// ICU 52 PluralRules/PluralFormat/CurrencyPluralInfo are not
|
||||
// ICU 52+ PluralRules/PluralFormat/CurrencyPluralInfo are not
|
||||
// serialization-compatible with previous versions.
|
||||
{"ICU_50.1", "com.ibm.icu.text.CurrencyPluralInfo.dat"},
|
||||
{"ICU_51.1", "com.ibm.icu.text.CurrencyPluralInfo.dat"},
|
||||
|
@ -133,14 +133,10 @@ public class CompatibilityTest extends TestFmwk
|
|||
{"ICU_50.1", "com.ibm.icu.text.PluralRules.dat"},
|
||||
{"ICU_51.1", "com.ibm.icu.text.PluralRules.dat"},
|
||||
|
||||
// Currency format changed in 52
|
||||
{"ICU_3.6", "com.ibm.icu.util.Currency.dat"},
|
||||
{"ICU_50.1", "com.ibm.icu.util.Currency.dat"},
|
||||
{"ICU_51.1", "com.ibm.icu.util.Currency.dat"},
|
||||
|
||||
// RuleBasedNumberFormat
|
||||
{"ICU_3.6", "com.ibm.icu.text.RuleBasedNumberFormat.dat"},
|
||||
|
||||
// ICU 4.8 MessageFormat is not serialization-compatible with previous versions.
|
||||
// ICU 4.8+ MessageFormat is not serialization-compatible with previous versions.
|
||||
{"ICU_3.6", "com.ibm.icu.text.MessageFormat.dat"},
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue