LEFT | RIGHT |
1 // © 2016 and later: Unicode, Inc. and others. | 1 // © 2016 and later: Unicode, Inc. and others. |
2 // License & terms of use: http://www.unicode.org/copyright.html#License | 2 // License & terms of use: http://www.unicode.org/copyright.html#License |
3 /* | 3 /* |
4 ********************************************************************** | 4 ********************************************************************** |
5 * Copyright (c) 2004-2014, International Business Machines | 5 * Copyright (c) 2004-2014, International Business Machines |
6 * Corporation and others. All Rights Reserved. | 6 * Corporation and others. All Rights Reserved. |
7 ********************************************************************** | 7 ********************************************************************** |
8 * Author: Alan Liu | 8 * Author: Alan Liu |
9 * Created: April 20, 2004 | 9 * Created: April 20, 2004 |
10 * Since: ICU 3.0 | 10 * Since: ICU 3.0 |
11 ********************************************************************** | 11 ********************************************************************** |
12 */ | 12 */ |
13 package com.ibm.icu.text; | 13 package com.ibm.icu.text; |
14 | 14 |
| 15 import java.io.ObjectStreamException; |
15 import java.text.FieldPosition; | 16 import java.text.FieldPosition; |
16 import java.text.ParsePosition; | 17 import java.text.ParsePosition; |
17 | 18 |
18 import com.ibm.icu.util.CurrencyAmount; | 19 import com.ibm.icu.util.CurrencyAmount; |
19 import com.ibm.icu.util.ULocale; | 20 import com.ibm.icu.util.ULocale; |
20 | 21 |
21 /** | 22 /** |
22 * Temporary internal concrete subclass of MeasureFormat implementing | 23 * Temporary internal concrete subclass of MeasureFormat implementing parsing an
d formatting of |
23 * parsing and formatting of CurrencyAmount objects. This class is | 24 * CurrencyAmount objects. This class is likely to be redesigned and rewritten i
n the near future. |
24 * likely to be redesigned and rewritten in the near future. | |
25 * | 25 * |
26 * <p>This class currently delegates to DecimalFormat for parsing and | 26 * <p> |
27 * formatting. | 27 * This class currently delegates to DecimalFormat for parsing and formatting. |
28 * | 28 * |
29 * @see com.ibm.icu.text.UFormat | 29 * @see com.ibm.icu.text.UFormat |
30 * @see com.ibm.icu.text.DecimalFormat | 30 * @see com.ibm.icu.text.DecimalFormat |
31 * @author Alan Liu | 31 * @author Alan Liu |
32 */ | 32 */ |
33 class CurrencyFormat extends MeasureFormat { | 33 class CurrencyFormat extends MeasureFormat { |
34 // Generated by serialver from JDK 1.4.1_01 | 34 // Generated by serialver from JDK 1.4.1_01 |
35 static final long serialVersionUID = -931679363692504634L; | 35 static final long serialVersionUID = -931679363692504634L; |
36 | 36 |
37 public CurrencyFormat(ULocale locale) { | 37 public CurrencyFormat(ULocale locale) { |
38 super(locale, FormatWidth.DEFAULT_CURRENCY); | 38 super(locale, FormatWidth.DEFAULT_CURRENCY); |
39 } | 39 } |
40 | 40 |
41 /** | 41 /** |
42 * Override Format.format(). | 42 * Override Format.format(). |
| 43 * |
43 * @see java.text.Format#format(java.lang.Object, java.lang.StringBuffer, ja
va.text.FieldPosition) | 44 * @see java.text.Format#format(java.lang.Object, java.lang.StringBuffer, ja
va.text.FieldPosition) |
44 */ | 45 */ |
45 @Override | 46 @Override |
46 public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPositio
n pos) { | 47 public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPositio
n pos) { |
47 if (!(obj instanceof CurrencyAmount)) { | 48 if (!(obj instanceof CurrencyAmount)) { |
48 throw new IllegalArgumentException("Invalid type: " + obj.getClass()
.getName()); | 49 throw new IllegalArgumentException("Invalid type: " + obj.getClass()
.getName()); |
49 } | 50 } |
50 return super.format(obj, toAppendTo, pos); | 51 return super.format(obj, toAppendTo, pos); |
51 } | 52 } |
52 | 53 |
53 /** | 54 /** |
54 * Override Format.parseObject(). | 55 * Override Format.parseObject(). |
| 56 * |
55 * @see java.text.Format#parseObject(java.lang.String, java.text.ParsePositi
on) | 57 * @see java.text.Format#parseObject(java.lang.String, java.text.ParsePositi
on) |
56 */ | 58 */ |
57 @Override | 59 @Override |
58 public CurrencyAmount parseObject(String source, ParsePosition pos) { | 60 public CurrencyAmount parseObject(String source, ParsePosition pos) { |
59 return getNumberFormat().parseCurrency(source, pos); | 61 return getNumberFormat().parseCurrency(source, pos); |
60 } | 62 } |
| 63 |
| 64 // Serialization |
| 65 |
| 66 private Object writeReplace() throws ObjectStreamException { |
| 67 return toCurrencyProxy(); |
| 68 } |
| 69 |
| 70 // Preserve backward serialize backward compatibility. |
| 71 private Object readResolve() throws ObjectStreamException { |
| 72 return new CurrencyFormat(getLocale(ULocale.ACTUAL_LOCALE)); |
| 73 } |
61 } | 74 } |
LEFT | RIGHT |