Interface MessageSource
Strategy interface for resolving messages, with support for the parameterization and internationalization of such messages.
Inspired/Copied from: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/MessageSource.html
-
Method Summary
Modifier and TypeMethodDescriptiongetMessage
(String code, Object... args) Same asgetMessage(java.lang.String, java.lang.Object[], java.lang.String, java.util.Locale)
withLocale.getDefault()
and null default.getMessage
(String code, Object[] args, String defaultMessage, Locale locale) Try to resolve the message.getMessage
(String code, Object[] args, Locale locale) Same asgetMessage(java.lang.String, java.lang.Object[], java.lang.String, java.util.Locale)
with null default.getMessage
(MessageKey resolvable) getMessage
(MessageKey resolvable, Locale locale) Try to resolve the resolvable, returningMessageKey.getDefaultMessage()
if lookup fails.<T extends MessageFactory>
TgetMessageFactory
(Class<T> factory, Locale locale) Returns an implementation of the given factory class that resolves messages against the given locale and message source.
-
Method Details
-
getMessage
- Parameters:
resolvable
-- Returns:
- String
-
getMessage
Try to resolve the resolvable, returning
MessageKey.getDefaultMessage()
if lookup fails.All of the codes returned by
MessageKey.getCode()
are attempted in order until either: - one resolves to a message with is returned - none resolve to a message in which case the default is returned.- Parameters:
resolvable
-locale
-- Returns:
- the resolved message or default if lookup fails
-
getMessage
Same as
getMessage(java.lang.String, java.lang.Object[], java.lang.String, java.util.Locale)
withLocale.getDefault()
and null default.- Parameters:
code
-args
-- Returns:
- the resolved message or null if lookup fails
-
getMessage
Same as
getMessage(java.lang.String, java.lang.Object[], java.lang.String, java.util.Locale)
with null default.- Parameters:
code
-args
-locale
-- Returns:
- the resolved message or null if lookup fails
-
getMessage
Try to resolve the message. Return default message if no message was found.
- Parameters:
code
- identifying messageargs
- an array of arguments forMessageFormat
replacementsdefaultMessage
- a default message to return if lookup failslocale
- the locale in which do to the lookup- Returns:
- the resolved message or default if lookup fails
-
getMessageFactory
Returns an implementation of the given factory class that resolves messages against the given locale and message source.
-