public class LocaleMessageProviderRegistry
extends java.lang.Object
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:
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)
) addLocaleMessageProivder(provider, prefix)
or addLocaleMessageProivder(provider, regex)
) check if there's provider configured for all sources (added via addLocaleMessageProvider(provider)
) Modifier and Type | Method and Description |
---|---|
static int | addDSLocaleMessageProvider(LocaleMessageProvider lmp) Registers LocaleMessageProvider for all data sources. |
static int | addDSLocaleMessageProvider(LocaleMessageProvider lmp, java.util.regex.Pattern regex) Registers LocaleMessageProvider for data sources which names match the regex . |
static int | addDSLocaleMessageProvider(LocaleMessageProvider lmp, java.lang.String prefix) Registers LocaleMessageProvider for data sources which names start with prefix . |
static int | addLocaleMessageProvider(LocaleMessageProvider lmp) Registers LocaleMessageProvider for all sources. |
static int | addLocaleMessageProvider(LocaleMessageProvider lmp, java.util.regex.Pattern regex) Registers LocaleMessageProvider for sources which names match the regex . |
static int | addLocaleMessageProvider(LocaleMessageProvider lmp, java.lang.String prefix) Registers LocaleMessageProvider for sources which names start with prefix . |
static LocaleMessageProvider | getDSLocaleMessageProvider(java.lang.String id) Looks up LocaleMessageProvider by data source id. |
static LocaleMessageProvider | getLocaleMessageProvider(java.lang.String id) Looks up LocaleMessageProvider by source id. |
static boolean | removeLocaleMessageProvider(int id) Unregisters LocaleMessageProvider by its unique ID. |
public static int addLocaleMessageProvider(LocaleMessageProvider lmp)
LocaleMessageProvider
for all sources.lmp
- provider to registerpublic static int addLocaleMessageProvider(LocaleMessageProvider lmp, java.lang.String prefix)
LocaleMessageProvider
for sources which names start with prefix
.lmp
- provider to registerprefix
- prefix to usepublic static int addLocaleMessageProvider(LocaleMessageProvider lmp, java.util.regex.Pattern regex)
LocaleMessageProvider
for sources which names match the regex
.lmp
- provider to registerregex
- regex to matchpublic static int addDSLocaleMessageProvider(LocaleMessageProvider lmp)
LocaleMessageProvider
for all data sources.lmp
- provider to registerpublic static int addDSLocaleMessageProvider(LocaleMessageProvider lmp, java.lang.String prefix)
LocaleMessageProvider
for data sources which names start with prefix
.lmp
- provider to registerprefix
- prefix to usepublic static int addDSLocaleMessageProvider(LocaleMessageProvider lmp, java.util.regex.Pattern regex)
LocaleMessageProvider
for data sources which names match the regex
.lmp
- provider to registerregex
- regex to matchpublic static boolean removeLocaleMessageProvider(int id)
LocaleMessageProvider
by its unique ID.id
- unique idtrue
if provider was successfully removed, false
otherwisepublic static LocaleMessageProvider getLocaleMessageProvider(java.lang.String id)
LocaleMessageProvider
by source id.id
- source idLocaleMessageProvider
or null
if not foundpublic static LocaleMessageProvider getDSLocaleMessageProvider(java.lang.String id)
LocaleMessageProvider
by data source id.id
- source idLocaleMessageProvider
or null
if not found