1 /* GENERATED SOURCE. DO NOT MODIFY. */ 2 // © 2017 and later: Unicode, Inc. and others. 3 // License & terms of use: http://www.unicode.org/copyright.html#License 4 package ohos.global.icu.impl.number; 5 6 import ohos.global.icu.impl.StandardPlural; 7 import ohos.global.icu.text.CurrencyPluralInfo; 8 9 /** 10 * @hide exposed on OHOS 11 */ 12 public class CurrencyPluralInfoAffixProvider implements AffixPatternProvider { 13 private final PropertiesAffixPatternProvider[] affixesByPlural; 14 CurrencyPluralInfoAffixProvider(CurrencyPluralInfo cpi, DecimalFormatProperties properties)15 public CurrencyPluralInfoAffixProvider(CurrencyPluralInfo cpi, DecimalFormatProperties properties) { 16 // We need to use a PropertiesAffixPatternProvider, not the simpler version ParsedPatternInfo, 17 // because user-specified affix overrides still need to work. 18 affixesByPlural = new PropertiesAffixPatternProvider[StandardPlural.COUNT]; 19 DecimalFormatProperties pluralProperties = new DecimalFormatProperties(); 20 pluralProperties.copyFrom(properties); 21 for (StandardPlural plural : StandardPlural.VALUES) { 22 String pattern = cpi.getCurrencyPluralPattern(plural.getKeyword()); 23 PatternStringParser.parseToExistingProperties(pattern, pluralProperties); 24 affixesByPlural[plural.ordinal()] = new PropertiesAffixPatternProvider(pluralProperties); 25 } 26 } 27 28 @Override charAt(int flags, int i)29 public char charAt(int flags, int i) { 30 int pluralOrdinal = (flags & Flags.PLURAL_MASK); 31 return affixesByPlural[pluralOrdinal].charAt(flags, i); 32 } 33 34 @Override length(int flags)35 public int length(int flags) { 36 int pluralOrdinal = (flags & Flags.PLURAL_MASK); 37 return affixesByPlural[pluralOrdinal].length(flags); 38 } 39 40 @Override getString(int flags)41 public String getString(int flags) { 42 int pluralOrdinal = (flags & Flags.PLURAL_MASK); 43 return affixesByPlural[pluralOrdinal].getString(flags); 44 } 45 46 @Override positiveHasPlusSign()47 public boolean positiveHasPlusSign() { 48 return affixesByPlural[StandardPlural.OTHER.ordinal()].positiveHasPlusSign(); 49 } 50 51 @Override hasNegativeSubpattern()52 public boolean hasNegativeSubpattern() { 53 return affixesByPlural[StandardPlural.OTHER.ordinal()].hasNegativeSubpattern(); 54 } 55 56 @Override negativeHasMinusSign()57 public boolean negativeHasMinusSign() { 58 return affixesByPlural[StandardPlural.OTHER.ordinal()].negativeHasMinusSign(); 59 } 60 61 @Override hasCurrencySign()62 public boolean hasCurrencySign() { 63 return affixesByPlural[StandardPlural.OTHER.ordinal()].hasCurrencySign(); 64 } 65 66 @Override containsSymbolType(int type)67 public boolean containsSymbolType(int type) { 68 return affixesByPlural[StandardPlural.OTHER.ordinal()].containsSymbolType(type); 69 } 70 71 @Override hasBody()72 public boolean hasBody() { 73 return affixesByPlural[StandardPlural.OTHER.ordinal()].hasBody(); 74 } 75 }