Top Inners Fields Constructors Methods
com.ibm.icu.impl

public Class ICULocaleService

extends ICUService
Class Inheritance
Known Direct Subclasses
com.ibm.icu.text.BreakIteratorFactory.BFService, com.ibm.icu.text.CollatorServiceShim.CService, com.ibm.icu.text.NumberFormatServiceShim.NFService, com.ibm.icu.util.CurrencyServiceShim.CFService
Imports
java.util.Collections, .Locale, .Map, .Set, com.ibm.icu.util.ULocale

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ICULocaleService.ICUResourceBundleFactory

A LocaleKeyFactory that creates a service based on the ICU locale data.

public static class
ICULocaleService.LocaleKey

A subclass of Key that implements a locale fallback mechanism.

public abstract static class
ICULocaleService.LocaleKeyFactory

A subclass of Factory that uses LocaleKeys.

public static class
ICULocaleService.SimpleLocaleKeyFactory

A LocaleKeyFactory that just returns a single object for a kind/locale.

Field Summary

Modifier and TypeField and Description
private ULocale
private String
Inherited from com.ibm.icu.impl.ICUService:
name

Constructor Summary

AccessConstructor and Description
public
ICULocaleService()

Construct an ICULocaleService.

public
ICULocaleService(String name)

Construct an ICULocaleService with a name (useful for debugging).

Method Summary

Modifier and TypeMethod and Description
public ICUService.Key
createKey(String id)

Overrides com.ibm.icu.impl.ICUService.createKey.

Create a key from an id. This creates a Key instance.
public ICUService.Key
createKey(String id, int kind)

public ICUService.Key
createKey(ULocale l, int kind)

public Object
get(ULocale locale)

Convenience override for callers using locales.

public Object
get(ULocale locale, int kind)

Convenience override for callers using locales.

public Object
get(ULocale locale, ULocale[] actualReturn)

Convenience override for callers using locales.

public Object
get(ULocale locale, int kind, ULocale[] actualReturn)

Convenience override for callers using locales.

public Locale[]
getAvailableLocales()

Convenience method for callers using locales.

public ULocale[]
getAvailableULocales()

Convenience method for callers using locales.

public ICUService.Factory
registerObject(Object obj, ULocale locale)

Convenience override for callers using locales.

public ICUService.Factory
registerObject(Object obj, ULocale locale, boolean visible)

Convenience override for callers using locales.

public ICUService.Factory
registerObject(Object obj, ULocale locale, int kind)

Convenience function for callers using locales.

public ICUService.Factory
registerObject(Object obj, ULocale locale, int kind, boolean visible)

Convenience function for callers using locales.

public String
validateFallbackLocale()

Return the name of the current fallback locale.

Inherited from com.ibm.icu.impl.ICUService:
acceptsListenerclearCachesclearServiceCachefactoriesgetgetgetDisplayNamegetDisplayNamegetDisplayNamesgetDisplayNamesgetDisplayNamesgetDisplayNamesgetDisplayNamesgetKeygetKeygetKeygetNamegetVisibleIDsgetVisibleIDshandleDefaultisDefaultmarkDefaultnotifyListenerregisterFactoryregisterObjectregisterObjectreInitializeFactoriesresetstatstoStringunregisterFactory

Field Detail

fallbackLocaleback to summary
private ULocale fallbackLocale
fallbackLocaleNameback to summary
private String fallbackLocaleName

Constructor Detail

ICULocaleServiceback to summary
public ICULocaleService()

Construct an ICULocaleService.

ICULocaleServiceback to summary
public ICULocaleService(String name)

Construct an ICULocaleService with a name (useful for debugging).

Method Detail

createKeyback to summary
public ICUService.Key createKey(String id)

Overrides com.ibm.icu.impl.ICUService.createKey.

Doc from com.ibm.icu.impl.ICUService.createKey.

Create a key from an id. This creates a Key instance. Subclasses can override to define more useful keys appropriate to the factories they accept. If id is null, returns null.

Annotations
@Override
createKeyback to summary
public ICUService.Key createKey(String id, int kind)
createKeyback to summary
public ICUService.Key createKey(ULocale l, int kind)
getback to summary
public Object get(ULocale locale)

Convenience override for callers using locales. This calls get(ULocale, int, ULocale[]) with KIND_ANY for kind and null for actualReturn.

getback to summary
public Object get(ULocale locale, int kind)

Convenience override for callers using locales. This calls get(ULocale, int, ULocale[]) with a null actualReturn.

getback to summary
public Object get(ULocale locale, ULocale[] actualReturn)

Convenience override for callers using locales. This calls get(ULocale, int, ULocale[]) with KIND_ANY for kind.

getback to summary
public Object get(ULocale locale, int kind, ULocale[] actualReturn)

Convenience override for callers using locales. This uses createKey(ULocale.toString(), kind) to create a key, calls getKey, and then if actualReturn is not null, returns the actualResult from getKey (stripping any prefix) into a ULocale.

getAvailableLocalesback to summary
public Locale[] getAvailableLocales()

Convenience method for callers using locales. This returns the standard Locale list, built from the Set of visible ids.

getAvailableULocalesback to summary
public ULocale[] getAvailableULocales()

Convenience method for callers using locales. This returns the standard ULocale list, built from the Set of visible ids.

registerObjectback to summary
public ICUService.Factory registerObject(Object obj, ULocale locale)

Convenience override for callers using locales. This calls registerObject(Object, ULocale, int kind, boolean visible) passing KIND_ANY for the kind, and true for the visibility.

registerObjectback to summary
public ICUService.Factory registerObject(Object obj, ULocale locale, boolean visible)

Convenience override for callers using locales. This calls registerObject(Object, ULocale, int kind, boolean visible) passing KIND_ANY for the kind.

registerObjectback to summary
public ICUService.Factory registerObject(Object obj, ULocale locale, int kind)

Convenience function for callers using locales. This calls registerObject(Object, ULocale, int kind, boolean visible) passing true for the visibility.

registerObjectback to summary
public ICUService.Factory registerObject(Object obj, ULocale locale, int kind, boolean visible)

Convenience function for callers using locales. This instantiates a SimpleLocaleKeyFactory, and registers the factory.

validateFallbackLocaleback to summary
public String validateFallbackLocale()

Return the name of the current fallback locale. If it has changed since this was last accessed, the service cache is cleared.

com.ibm.icu.impl back to summary

public Class ICULocaleService.ICUResourceBundleFactory

extends LocaleKeyFactory
Class Inheritance

A LocaleKeyFactory that creates a service based on the ICU locale data. This is a base class for most ICU factories. Subclasses instantiate it with a constructor that takes a bundle name, which determines the supported IDs. Subclasses then override handleCreate to create the actual service object. The default implementation returns a resource bundle.

Field Summary

Modifier and TypeField and Description
protected final String
Inherited from com.ibm.icu.impl.ICULocaleService.LocaleKeyFactory:
INVISIBLEnamevisibleVISIBLE

Constructor Summary

AccessConstructor and Description
public
ICUResourceBundleFactory()

Convenience constructor that uses the main ICU bundle name.

public
ICUResourceBundleFactory(String bundleName)

A service factory based on ICU resource data in resources with the given name.

Method Summary

Modifier and TypeMethod and Description
protected Set<String>
protected Object
protected ClassLoader
public String
public void
Inherited from com.ibm.icu.impl.ICULocaleService.LocaleKeyFactory:
creategetDisplayNamehandlesKeyisSupportedID

Field Detail

bundleNameback to summary
protected final String bundleName

Constructor Detail

ICUResourceBundleFactoryback to summary
public ICUResourceBundleFactory()

Convenience constructor that uses the main ICU bundle name.

ICUResourceBundleFactoryback to summary
public ICUResourceBundleFactory(String bundleName)

A service factory based on ICU resource data in resources with the given name.

Method Detail

getSupportedIDsback to summary
protected Set<String> getSupportedIDs()

Overrides com.ibm.icu.impl.ICULocaleService.LocaleKeyFactory.getSupportedIDs.

Return the supported IDs. This is the set of all locale names for the bundleName.

Annotations
@Override
handleCreateback to summary
protected Object handleCreate(ULocale loc, int kind, ICUService service)

Overrides com.ibm.icu.impl.ICULocaleService.LocaleKeyFactory.handleCreate.

Create the service. The default implementation returns the resource bundle for the locale, ignoring kind, and service.

Annotations
@Override
loaderback to summary
protected ClassLoader loader()
toStringback to summary
public String toString()

Overrides com.ibm.icu.impl.ICULocaleService.LocaleKeyFactory.toString.

Doc from com.ibm.icu.impl.ICULocaleService.LocaleKeyFactory.toString.

For debugging.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.

Annotations
@Override
updateVisibleIDsback to summary
public void updateVisibleIDs(Map<String, ICUService.Factory> result)

Overrides com.ibm.icu.impl.ICULocaleService.LocaleKeyFactory.updateVisibleIDs.

Implements com.ibm.icu.impl.ICUService.Factory.updateVisibleIDs.

Override of superclass method.

Annotations
@Override
com.ibm.icu.impl back to summary

public Class ICULocaleService.LocaleKey

extends Key
Class Inheritance

A subclass of Key that implements a locale fallback mechanism. The first locale to search for is the locale provided by the client, and the fallback locale to search for is the current default locale. If a prefix is present, the currentDescriptor includes it before the locale proper, separated by "/". This is the default key instantiated by ICULocaleService.

Canonicalization adjusts the locale string so that the section before the first understore is in lower case, and the rest is in upper case, with no trailing underscores.

Field Summary

Modifier and TypeField and Description
private String
private String
private int
public static final int
private String
private int

Constructor Summary

AccessConstructor and Description
protected
LocaleKey(String primaryID, String canonicalPrimaryID, String canonicalFallbackID, int kind)

PrimaryID is the user's requested locale string, canonicalPrimaryID is this string in canonical form, fallbackID is the current default locale's string in canonical form.

Method Summary

Modifier and TypeMethod and Description
public String
canonicalID()

Overrides com.ibm.icu.impl.ICUService.Key.canonicalID.

Return the (canonical) original ID.
public ULocale
canonicalLocale()

Convenience method to return the locale corresponding to the (canonical) original ID.

public static ICULocaleService.LocaleKey
createWithCanonical(ULocale locale, String canonicalFallbackID, int kind)

Create a LocaleKey with canonical primary and fallback IDs.

public static ICULocaleService.LocaleKey
createWithCanonicalFallback(String primaryID, String canonicalFallbackID)

Create a LocaleKey with canonical primary and fallback IDs.

public static ICULocaleService.LocaleKey
createWithCanonicalFallback(String primaryID, String canonicalFallbackID, int kind)

Create a LocaleKey with canonical primary and fallback IDs.

public String
currentDescriptor()

Overrides com.ibm.icu.impl.ICUService.Key.currentDescriptor.

Return the (canonical) current descriptor, or null if no current id. Includes the keywords, whereas the ID does not include keywords.
public String
currentID()

Overrides com.ibm.icu.impl.ICUService.Key.currentID.

Return the (canonical) current ID, or null if no current id.
public ULocale
currentLocale()

Convenience method to return the ulocale corresponding to the (canonical) currentID.

public boolean
fallback()

Overrides com.ibm.icu.impl.ICUService.Key.fallback.

If the key has a fallback, modify the key and return true, otherwise return false.
public boolean
isFallbackOf(String id)

Overrides com.ibm.icu.impl.ICUService.Key.isFallbackOf.

If a key created from id would eventually fallback to match the canonical ID of this key, return true.
public int
kind()

Return the kind code associated with this key.

public String
prefix()

Return the prefix associated with the kind, or null if the kind is KIND_ANY.

Inherited from com.ibm.icu.impl.ICUService.Key:
id

Field Detail

currentIDback to summary
private String currentID
fallbackIDback to summary
private String fallbackID
kindback to summary
private int kind
KIND_ANYback to summary
public static final int KIND_ANY
primaryIDback to summary
private String primaryID
varstartback to summary
private int varstart

Constructor Detail

LocaleKeyback to summary
protected LocaleKey(String primaryID, String canonicalPrimaryID, String canonicalFallbackID, int kind)

PrimaryID is the user's requested locale string, canonicalPrimaryID is this string in canonical form, fallbackID is the current default locale's string in canonical form.

Method Detail

canonicalIDback to summary
public String canonicalID()

Overrides com.ibm.icu.impl.ICUService.Key.canonicalID.

Return the (canonical) original ID.

Annotations
@Override
canonicalLocaleback to summary
public ULocale canonicalLocale()

Convenience method to return the locale corresponding to the (canonical) original ID.

createWithCanonicalback to summary
public static ICULocaleService.LocaleKey createWithCanonical(ULocale locale, String canonicalFallbackID, int kind)

Create a LocaleKey with canonical primary and fallback IDs.

createWithCanonicalFallbackback to summary
public static ICULocaleService.LocaleKey createWithCanonicalFallback(String primaryID, String canonicalFallbackID)

Create a LocaleKey with canonical primary and fallback IDs.

createWithCanonicalFallbackback to summary
public static ICULocaleService.LocaleKey createWithCanonicalFallback(String primaryID, String canonicalFallbackID, int kind)

Create a LocaleKey with canonical primary and fallback IDs.

currentDescriptorback to summary
public String currentDescriptor()

Overrides com.ibm.icu.impl.ICUService.Key.currentDescriptor.

Return the (canonical) current descriptor, or null if no current id. Includes the keywords, whereas the ID does not include keywords.

Annotations
@Override
currentIDback to summary
public String currentID()

Overrides com.ibm.icu.impl.ICUService.Key.currentID.

Return the (canonical) current ID, or null if no current id.

Annotations
@Override
currentLocaleback to summary
public ULocale currentLocale()

Convenience method to return the ulocale corresponding to the (canonical) currentID.

fallbackback to summary
public boolean fallback()

Overrides com.ibm.icu.impl.ICUService.Key.fallback.

If the key has a fallback, modify the key and return true, otherwise return false.

First falls back through the primary ID, then through the fallbackID. The final fallback is "" (root) unless the primary id was "" (root), in which case there is no fallback.

Annotations
@Override
isFallbackOfback to summary
public boolean isFallbackOf(String id)

Overrides com.ibm.icu.impl.ICUService.Key.isFallbackOf.

If a key created from id would eventually fallback to match the canonical ID of this key, return true.

Annotations
@Override
kindback to summary
public int kind()

Return the kind code associated with this key.

prefixback to summary
public String prefix()

Return the prefix associated with the kind, or null if the kind is KIND_ANY.

com.ibm.icu.impl back to summary

public abstract Class ICULocaleService.LocaleKeyFactory

extends Object
implements Factory
Class Inheritance
All Implemented Interfaces
com.ibm.icu.impl.ICUService.Factory
Known Direct Subclasses
com.ibm.icu.impl.ICULocaleService.SimpleLocaleKeyFactory, com.ibm.icu.impl.ICULocaleService.ICUResourceBundleFactory, com.ibm.icu.text.NumberFormatServiceShim.NFFactory

A subclass of Factory that uses LocaleKeys. If 'visible' the factory reports its IDs.

Field Summary

Modifier and TypeField and Description
public static final boolean
protected final String
protected final boolean
public static final boolean

Constructor Summary

AccessConstructor and Description
protected
LocaleKeyFactory(boolean visible)

Constructor used by subclasses.

protected
LocaleKeyFactory(boolean visible, String name)

Constructor used by subclasses.

Method Summary

Modifier and TypeMethod and Description
public Object
create(ICUService.Key key, ICUService service)

Implements com.ibm.icu.impl.ICUService.Factory.create.

Implement superclass abstract method.
public String
getDisplayName(String id, ULocale locale)

Implements com.ibm.icu.impl.ICUService.Factory.getDisplayName.

Return a localized name for the locale represented by id.
protected Set<String>
getSupportedIDs()

Return the set of ids that this factory supports (visible or otherwise).

protected Object
handleCreate(ULocale loc, int kind, ICUService service)

Utility method used by create(Key, ICUService).

protected boolean
protected boolean
isSupportedID(String id)

Return true if this id is one the factory supports (visible or otherwise).

public String
toString()

Overrides java.lang.Object.toString.

For debugging.
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

INVISIBLEback to summary
public static final boolean INVISIBLE
nameback to summary
protected final String name
visibleback to summary
protected final boolean visible
VISIBLEback to summary
public static final boolean VISIBLE

Constructor Detail

LocaleKeyFactoryback to summary
protected LocaleKeyFactory(boolean visible)

Constructor used by subclasses.

LocaleKeyFactoryback to summary
protected LocaleKeyFactory(boolean visible, String name)

Constructor used by subclasses.

Method Detail

createback to summary
public Object create(ICUService.Key key, ICUService service)

Implements com.ibm.icu.impl.ICUService.Factory.create.

Implement superclass abstract method. This checks the currentID of the key against the supported IDs, and passes the canonicalLocale and kind off to handleCreate (which subclasses must implement).

Annotations
@Override
getDisplayNameback to summary
public String getDisplayName(String id, ULocale locale)

Implements com.ibm.icu.impl.ICUService.Factory.getDisplayName.

Return a localized name for the locale represented by id.

Annotations
@Override
getSupportedIDsback to summary
protected Set<String> getSupportedIDs()

Return the set of ids that this factory supports (visible or otherwise). This can be called often and might need to be cached if it is expensive to create.

handleCreateback to summary
protected Object handleCreate(ULocale loc, int kind, ICUService service)

Utility method used by create(Key, ICUService). Subclasses can implement this instead of create.

handlesKeyback to summary
protected boolean handlesKey(ICUService.Key key)
isSupportedIDback to summary
protected boolean isSupportedID(String id)

Return true if this id is one the factory supports (visible or otherwise).

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

For debugging.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.

Annotations
@Override
updateVisibleIDsback to summary
public void updateVisibleIDs(Map<String, ICUService.Factory> result)

Implements com.ibm.icu.impl.ICUService.Factory.updateVisibleIDs.

Override of superclass method.

Annotations
@Override
com.ibm.icu.impl back to summary

public Class ICULocaleService.SimpleLocaleKeyFactory

extends LocaleKeyFactory
Class Inheritance

A LocaleKeyFactory that just returns a single object for a kind/locale.

Field Summary

Modifier and TypeField and Description
private final String
private final int
private final Object
Inherited from com.ibm.icu.impl.ICULocaleService.LocaleKeyFactory:
INVISIBLEnamevisibleVISIBLE

Constructor Summary

AccessConstructor and Description
public
SimpleLocaleKeyFactory(Object obj, ULocale locale, int kind, boolean visible)

public
SimpleLocaleKeyFactory(Object obj, ULocale locale, int kind, boolean visible, String name)

Method Summary

Modifier and TypeMethod and Description
public Object
create(ICUService.Key key, ICUService service)

Overrides com.ibm.icu.impl.ICULocaleService.LocaleKeyFactory.create.

Implements com.ibm.icu.impl.ICUService.Factory.create.

Returns the service object if kind/locale match.
protected boolean
isSupportedID(String idToCheck)

Overrides com.ibm.icu.impl.ICULocaleService.LocaleKeyFactory.isSupportedID.

Return true if this id is one the factory supports (visible or otherwise).
public String
public void
Inherited from com.ibm.icu.impl.ICULocaleService.LocaleKeyFactory:
getDisplayNamegetSupportedIDshandleCreatehandlesKey

Field Detail

idback to summary
private final String id
kindback to summary
private final int kind
objback to summary
private final Object obj

Constructor Detail

SimpleLocaleKeyFactoryback to summary
public SimpleLocaleKeyFactory(Object obj, ULocale locale, int kind, boolean visible)
SimpleLocaleKeyFactoryback to summary
public SimpleLocaleKeyFactory(Object obj, ULocale locale, int kind, boolean visible, String name)

Method Detail

createback to summary
public Object create(ICUService.Key key, ICUService service)

Overrides com.ibm.icu.impl.ICULocaleService.LocaleKeyFactory.create.

Implements com.ibm.icu.impl.ICUService.Factory.create.

Returns the service object if kind/locale match. Service is not used.

Annotations
@Override
isSupportedIDback to summary
protected boolean isSupportedID(String idToCheck)

Overrides com.ibm.icu.impl.ICULocaleService.LocaleKeyFactory.isSupportedID.

Doc from com.ibm.icu.impl.ICULocaleService.LocaleKeyFactory.isSupportedID.

Return true if this id is one the factory supports (visible or otherwise).

Annotations
@Override
toStringback to summary
public String toString()

Overrides com.ibm.icu.impl.ICULocaleService.LocaleKeyFactory.toString.

Doc from com.ibm.icu.impl.ICULocaleService.LocaleKeyFactory.toString.

For debugging.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.

Annotations
@Override
updateVisibleIDsback to summary
public void updateVisibleIDs(Map<String, ICUService.Factory> result)

Overrides com.ibm.icu.impl.ICULocaleService.LocaleKeyFactory.updateVisibleIDs.

Implements com.ibm.icu.impl.ICUService.Factory.updateVisibleIDs.

Doc from com.ibm.icu.impl.ICULocaleService.LocaleKeyFactory.updateVisibleIDs.

Override of superclass method.

Annotations
@Override