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