com.ibm.icu.util.CurrencyServiceShim Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vaadin-client-compiler-deps Show documentation
Show all versions of vaadin-client-compiler-deps Show documentation
Vaadin is a web application framework for Rich Internet Applications (RIA).
Vaadin enables easy development and maintenance of fast and
secure rich web
applications with a stunning look and feel and a wide browser support.
It features a server-side architecture with the majority of the logic
running
on the server. Ajax technology is used at the browser-side to ensure a
rich
and interactive user experience.
/**
*******************************************************************************
* Copyright (C) 2001-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.util;
import java.util.Locale;
import com.ibm.icu.impl.ICULocaleService;
import com.ibm.icu.impl.ICUResourceBundle;
import com.ibm.icu.impl.ICUService;
import com.ibm.icu.impl.ICUService.Factory;
/**
* This is a package-access implementation of registration for
* currency. The shim is instantiated by reflection in Currency, all
* dependencies on ICUService are located in this file. This structure
* is to allow ICU4J to be built without service registration support.
*/
final class CurrencyServiceShim extends Currency.ServiceShim {
Locale[] getAvailableLocales() {
if (service.isDefault()) {
return ICUResourceBundle.getAvailableLocales();
}
return service.getAvailableLocales();
}
ULocale[] getAvailableULocales() {
if (service.isDefault()) {
return ICUResourceBundle.getAvailableULocales();
}
return service.getAvailableULocales();
}
Currency createInstance(ULocale loc) {
// TODO: convert to ULocale when service switches over
if (service.isDefault()) {
return Currency.createCurrency(loc);
}
Currency curr = (Currency)service.get(loc);
return curr;
}
Object registerInstance(Currency currency, ULocale locale) {
return service.registerObject(currency, locale);
}
boolean unregister(Object registryKey) {
return service.unregisterFactory((Factory)registryKey);
}
private static class CFService extends ICULocaleService {
CFService() {
super("Currency");
class CurrencyFactory extends ICUResourceBundleFactory {
protected Object handleCreate(ULocale loc, int kind, ICUService srvc) {
return Currency.createCurrency(loc);
}
}
registerFactory(new CurrencyFactory());
markDefault();
}
}
static final ICULocaleService service = new CFService();
}