Class LocaleMessageProviderRegistry
LocaleMessageProvider. Framework will look up for registered custom provider and use it to get i18n message when parsing XML sources. Providers can be registered (added) just for data sources and/or for any other XML source. Providers may be configured for all sources or for sources with specific prefix or which names match the regex specified during provider registration. Note that the provider implementation is not controlled, so it completely valid to use same instance for different look up configurations.
Providers can be unregistered (removed) using the ID that is returned when provider was registered. Each add method returns an unique ID which later may be used to remove that specific provider. Note that removing provider by unique ID will remove only that specific provider which when added returned this ID.
When framework is looking up for provider it will pick up first provider matching configuration according to the look up order (see below) and providers registration order.
Look up order for data source:
- search data source provider configured with prefix/regex (added via
addDSLocaleMessageProivder(provider, prefix) or addDSLocaleMessageProivder(provider, regex)) check if there's provider configured for all data sources (added via addDSLocaleMessageProvider(provider)) search all source provider configured with prefix/regex (added via addLocaleMessageProivder(provider, prefix) or addLocaleMessageProivder(provider, regex)) check if there's provider configured for all sources (added via addLocaleMessageProvider(provider)) - search all source provider configured with prefix/regex (added via
addLocaleMessageProivder(provider, prefix) or addLocaleMessageProivder(provider, regex)) check if there's provider configured for all sources (added via addLocaleMessageProvider(provider)) -
Method Summary
Modifier and TypeMethodDescriptionstatic intRegistersLocaleMessageProviderfor all data sources.static intaddDSLocaleMessageProvider(LocaleMessageProvider lmp, String prefix) RegistersLocaleMessageProviderfor data sources which names start withprefix.static intaddDSLocaleMessageProvider(LocaleMessageProvider lmp, Pattern regex) RegistersLocaleMessageProviderfor data sources which names match theregex.static intRegistersLocaleMessageProviderfor all sources.static intaddLocaleMessageProvider(LocaleMessageProvider lmp, String prefix) RegistersLocaleMessageProviderfor sources which names start withprefix.static intaddLocaleMessageProvider(LocaleMessageProvider lmp, Pattern regex) RegistersLocaleMessageProviderfor sources which names match theregex.static LocaleMessageProviderLooks upLocaleMessageProviderby data source id.static LocaleMessageProviderLooks upLocaleMessageProviderby source id.static booleanremoveLocaleMessageProvider(int id) UnregistersLocaleMessageProviderby its unique ID.
-
Method Details
-
addLocaleMessageProvider
RegistersLocaleMessageProviderfor all sources.- Parameters:
lmp- provider to register- Returns:
- unique ID
-
addLocaleMessageProvider
RegistersLocaleMessageProviderfor sources which names start withprefix.- Parameters:
lmp- provider to registerprefix- prefix to use- Returns:
- unique ID
-
addLocaleMessageProvider
RegistersLocaleMessageProviderfor sources which names match theregex.- Parameters:
lmp- provider to registerregex- regex to match- Returns:
- unique ID
-
addDSLocaleMessageProvider
RegistersLocaleMessageProviderfor all data sources.- Parameters:
lmp- provider to register- Returns:
- unique ID
-
addDSLocaleMessageProvider
RegistersLocaleMessageProviderfor data sources which names start withprefix.- Parameters:
lmp- provider to registerprefix- prefix to use- Returns:
- unique ID
-
addDSLocaleMessageProvider
RegistersLocaleMessageProviderfor data sources which names match theregex.- Parameters:
lmp- provider to registerregex- regex to match- Returns:
- unique ID
-
removeLocaleMessageProvider
public static boolean removeLocaleMessageProvider(int id) UnregistersLocaleMessageProviderby its unique ID.- Parameters:
id- unique id- Returns:
trueif provider was successfully removed,falseotherwise
-
getLocaleMessageProvider
Looks upLocaleMessageProviderby source id.- Parameters:
id- source id- Returns:
LocaleMessageProviderornullif not found
-
getDSLocaleMessageProvider
Looks upLocaleMessageProviderby data source id.- Parameters:
id- source id- Returns:
LocaleMessageProviderornullif not found
-