• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4  *******************************************************************************
5  * Copyright (C) 2008-2012, International Business Machines Corporation and    *
6  * others. All Rights Reserved.                                                *
7  *******************************************************************************
8  */
9 package com.ibm.icu.impl.javaspi.util;
10 
11 import java.util.Locale;
12 import java.util.spi.CurrencyNameProvider;
13 
14 import com.ibm.icu.impl.javaspi.ICULocaleServiceProvider;
15 import com.ibm.icu.text.CurrencyDisplayNames;
16 
17 public class CurrencyNameProviderICU extends CurrencyNameProvider {
18 
19     @Override
getSymbol(String currencyCode, Locale locale)20     public String getSymbol(String currencyCode, Locale locale) {
21         CurrencyDisplayNames curDispNames = CurrencyDisplayNames.getInstance(ICULocaleServiceProvider.toULocaleNoSpecialVariant(locale));
22         String sym = curDispNames.getSymbol(currencyCode);
23         if (sym == null || sym.equals(currencyCode)) {
24             return null;
25         }
26         return sym;
27     }
28 
29     @Override
getDisplayName(String currencyCode, Locale locale)30     public String getDisplayName(String currencyCode, Locale locale) {
31         CurrencyDisplayNames curDispNames = CurrencyDisplayNames.getInstance(ICULocaleServiceProvider.toULocaleNoSpecialVariant(locale));
32         String name = curDispNames.getName(currencyCode);
33         if (name == null || name.equals(currencyCode)) {
34             return null;
35         }
36         return name;
37     }
38 
39     @Override
getAvailableLocales()40     public Locale[] getAvailableLocales() {
41         return ICULocaleServiceProvider.getAvailableLocales();
42     }
43 
44 }
45