Home | History | Annotate | Download | only in util
      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) 2001-2011, International Business Machines Corporation and    *
      7  * others. All Rights Reserved.                                                *
      8  *******************************************************************************
      9  */
     10 
     11 package android.icu.util;
     12 
     13 import java.util.Locale;
     14 
     15 import android.icu.impl.ICULocaleService;
     16 import android.icu.impl.ICUResourceBundle;
     17 import android.icu.impl.ICUService;
     18 import android.icu.impl.ICUService.Factory;
     19 
     20 /**
     21  * This is a package-access implementation of registration for
     22  * currency.  The shim is instantiated by reflection in Currency, all
     23  * dependencies on ICUService are located in this file. This structure
     24  * is to allow ICU4J to be built without service registration support.
     25  */
     26 final class CurrencyServiceShim extends Currency.ServiceShim {
     27 
     28     Locale[] getAvailableLocales() {
     29         if (service.isDefault()) {
     30             return ICUResourceBundle.getAvailableLocales();
     31         }
     32         return service.getAvailableLocales();
     33     }
     34 
     35     ULocale[] getAvailableULocales() {
     36         if (service.isDefault()) {
     37             return ICUResourceBundle.getAvailableULocales();
     38         }
     39         return service.getAvailableULocales();
     40     }
     41 
     42     Currency createInstance(ULocale loc) {
     43         // TODO: convert to ULocale when service switches over
     44 
     45         if (service.isDefault()) {
     46             return Currency.createCurrency(loc);
     47         }
     48         Currency curr = (Currency)service.get(loc);
     49         return curr;
     50     }
     51 
     52     Object registerInstance(Currency currency, ULocale locale) {
     53         return service.registerObject(currency, locale);
     54     }
     55 
     56     boolean unregister(Object registryKey) {
     57         return service.unregisterFactory((Factory)registryKey);
     58     }
     59 
     60     private static class CFService extends ICULocaleService {
     61         CFService() {
     62             super("Currency");
     63 
     64             class CurrencyFactory extends ICUResourceBundleFactory {
     65                 protected Object handleCreate(ULocale loc, int kind, ICUService srvc) {
     66                     return Currency.createCurrency(loc);
     67                 }
     68             }
     69 
     70             registerFactory(new CurrencyFactory());
     71             markDefault();
     72         }
     73     }
     74     static final ICULocaleService service = new CFService();
     75 }
     76