1 7 8 package com.ibm.icu.util; 9 10 import java.util.Locale ; 11 12 import com.ibm.icu.impl.ICUResourceBundle; 13 import com.ibm.icu.impl.ICUService; 14 import com.ibm.icu.impl.ICUService.Factory; 15 import com.ibm.icu.impl.ICULocaleService; 16 17 23 final class CurrencyServiceShim extends Currency.ServiceShim { 24 25 Locale [] getAvailableLocales() { 26 if (service.isDefault()) { 27 return ICUResourceBundle.getAvailableLocales(ICUResourceBundle.ICU_BASE_NAME); 28 } 29 return service.getAvailableLocales(); 30 } 31 32 ULocale[] getAvailableULocales() { 33 if (service.isDefault()) { 34 return ICUResourceBundle.getAvailableULocales(ICUResourceBundle.ICU_BASE_NAME); 35 } 36 return service.getAvailableULocales(); 37 } 38 39 Currency createInstance(ULocale loc) { 40 42 if (service.isDefault()) { 43 return Currency.createCurrency(loc); 44 } 45 ULocale[] actualLoc = new ULocale[1]; 46 Currency curr = (Currency)service.get(loc, actualLoc); 47 ULocale uloc = actualLoc[0]; 48 curr.setLocale(uloc, uloc); 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 service) { 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 | Popular Tags |