public interface MessageSource
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
REF_KEY_END
"]"
|
static java.lang.String |
REF_KEY_START
"@["
|
| Modifier and Type | Method and Description |
|---|---|
java.util.ResourceBundle |
asResourceBundle()
Offers a view of this
MessageSource as a ResourceBundle. |
java.lang.String |
formatMessage(java.lang.String message,
java.util.List<?> args)
Formats the given message using supplied args to substitute placeholders.
|
java.lang.String |
formatMessage(java.lang.String message,
java.util.Map<java.lang.String,java.lang.Object> args)
Formats the given message using supplied args to substitute placeholders.
|
java.lang.String |
formatMessage(java.lang.String message,
java.lang.Object[] args)
Formats the given message using supplied args to substitute placeholders.
|
java.lang.String |
getMessage(java.lang.String key)
Try to resolve the message.
|
java.lang.String |
getMessage(java.lang.String key,
java.util.List<?> args)
Try to resolve the message.
|
java.lang.String |
getMessage(java.lang.String key,
java.util.List<?> args,
java.util.Locale locale)
Try to resolve the message.
|
java.lang.String |
getMessage(java.lang.String key,
java.util.List<?> args,
java.util.Locale locale,
java.lang.String defaultMessage)
Try to resolve the message.
|
java.lang.String |
getMessage(java.lang.String key,
java.util.List<?> args,
java.lang.String defaultMessage)
Try to resolve the message.
|
java.lang.String |
getMessage(java.lang.String key,
java.util.Locale locale)
Try to resolve the message.
|
java.lang.String |
getMessage(java.lang.String key,
java.util.Locale locale,
java.lang.String defaultMessage)
Try to resolve the message.
|
java.lang.String |
getMessage(java.lang.String key,
java.util.Map<java.lang.String,java.lang.Object> args)
Try to resolve the message.
|
java.lang.String |
getMessage(java.lang.String key,
java.util.Map<java.lang.String,java.lang.Object> args,
java.util.Locale locale)
Try to resolve the message.
|
java.lang.String |
getMessage(java.lang.String key,
java.util.Map<java.lang.String,java.lang.Object> args,
java.util.Locale locale,
java.lang.String defaultMessage)
Try to resolve the message.
|
java.lang.String |
getMessage(java.lang.String key,
java.util.Map<java.lang.String,java.lang.Object> args,
java.lang.String defaultMessage)
Try to resolve the message.
|
java.lang.String |
getMessage(java.lang.String key,
java.lang.Object[] args)
Try to resolve the message.
|
java.lang.String |
getMessage(java.lang.String key,
java.lang.Object[] args,
java.util.Locale locale)
Try to resolve the message.
|
java.lang.String |
getMessage(java.lang.String key,
java.lang.Object[] args,
java.util.Locale locale,
java.lang.String defaultMessage)
Try to resolve the message.
|
java.lang.String |
getMessage(java.lang.String key,
java.lang.Object[] args,
java.lang.String defaultMessage)
Try to resolve the message.
|
java.lang.String |
getMessage(java.lang.String key,
java.lang.String defaultMessage)
Try to resolve the message.
|
java.lang.Object |
resolveMessageValue(java.lang.String key,
java.util.Locale locale)
Resolve a message given a key and a Locale.
|
static final java.lang.String REF_KEY_START
static final java.lang.String REF_KEY_END
@Nonnull
java.lang.String getMessage(@Nonnull
java.lang.String key)
throws NoSuchMessageException
key - Key to lookup, such as 'log4j.appenders.console'NoSuchMessageException - if no message is found@Nonnull
java.lang.String getMessage(@Nonnull
java.lang.String key,
@Nonnull
java.util.Locale locale)
throws NoSuchMessageException
key - Key to lookup, such as 'log4j.appenders.console'locale - Locale in which to lookupNoSuchMessageException - if no message is found@Nonnull
java.lang.String getMessage(@Nonnull
java.lang.String key,
@Nonnull
java.lang.Object[] args)
throws NoSuchMessageException
key - Key to lookup, such as 'log4j.appenders.console'args - Arguments that will be filled in for params within the message (params look like "{0}" within a
message, but this might differ between implementations), or null if none.NoSuchMessageException - if no message is found@Nonnull
java.lang.String getMessage(@Nonnull
java.lang.String key,
@Nonnull
java.lang.Object[] args,
@Nonnull
java.util.Locale locale)
throws NoSuchMessageException
key - Key to lookup, such as 'log4j.appenders.console'args - Arguments that will be filled in for params within the message (params look like "{0}" within a
message, but this might differ between implementations), or null if none.locale - Locale in which to lookupNoSuchMessageException - if no message is found@Nonnull
java.lang.String getMessage(@Nonnull
java.lang.String key,
@Nonnull
java.util.List<?> args)
throws NoSuchMessageException
key - Key to lookup, such as 'log4j.appenders.console'args - Arguments that will be filled in for params within the message (params look like "{0}" within a
message, but this might differ between implementations), or null if none.NoSuchMessageException - if no message is found@Nonnull
java.lang.String getMessage(@Nonnull
java.lang.String key,
@Nonnull
java.util.List<?> args,
@Nonnull
java.util.Locale locale)
throws NoSuchMessageException
key - Key to lookup, such as 'log4j.appenders.console'args - Arguments that will be filled in for params within the message (params look like "{0}" within a
message, but this might differ between implementations), or null if none.locale - Locale in which to lookupNoSuchMessageException - if no message is found@Nullable
java.lang.String getMessage(@Nonnull
java.lang.String key,
@Nullable
java.lang.String defaultMessage)
key - Key to lookup, such as 'log4j.appenders.console'defaultMessage - Message to return if the lookup fails@Nullable
java.lang.String getMessage(@Nonnull
java.lang.String key,
@Nonnull
java.util.Locale locale,
@Nullable
java.lang.String defaultMessage)
key - Key to lookup, such as 'log4j.appenders.console'locale - Locale in which to lookupdefaultMessage - Message to return if the lookup fails@Nullable
java.lang.String getMessage(@Nonnull
java.lang.String key,
@Nonnull
java.lang.Object[] args,
@Nullable
java.lang.String defaultMessage)
key - Key to lookup, such as 'log4j.appenders.console'args - Arguments that will be filled in for params within the message (params look like "{0}"
within a message, but this might differ between implementations), or null if none.defaultMessage - Message to return if the lookup fails@Nullable
java.lang.String getMessage(@Nonnull
java.lang.String key,
@Nonnull
java.lang.Object[] args,
@Nonnull
java.util.Locale locale,
@Nullable
java.lang.String defaultMessage)
key - Key to lookup, such as 'log4j.appenders.console'args - Arguments that will be filled in for params within the message (params look like "{0}"
within a message, but this might differ between implementations), or null if none.locale - Locale in which to lookupdefaultMessage - Message to return if the lookup fails@Nullable
java.lang.String getMessage(@Nonnull
java.lang.String key,
@Nonnull
java.util.List<?> args,
@Nullable
java.lang.String defaultMessage)
key - Key to lookup, such as 'log4j.appenders.console'args - Arguments that will be filled in for params within the message (params look like "{0}"
within a message, but this might differ between implementations), or null if none.defaultMessage - Message to return if the lookup fails@Nullable
java.lang.String getMessage(@Nonnull
java.lang.String key,
@Nonnull
java.util.List<?> args,
@Nonnull
java.util.Locale locale,
@Nullable
java.lang.String defaultMessage)
key - Key to lookup, such as 'log4j.appenders.console'args - Arguments that will be filled in for params within the message (params look like "{0}"
within a message, but this might differ between implementations), or null if none.locale - Locale in which to lookupdefaultMessage - Message to return if the lookup fails@Nonnull
java.lang.String getMessage(@Nonnull
java.lang.String key,
@Nonnull
java.util.Map<java.lang.String,java.lang.Object> args)
throws NoSuchMessageException
key - Key to lookup, such as 'log4j.appenders.console'args - Arguments that will be filled in for params within the message (params look like "{:key}"
within a message, but this might differ between implementations), or null if none.NoSuchMessageException - if no message is found@Nonnull
java.lang.String getMessage(@Nonnull
java.lang.String key,
@Nonnull
java.util.Map<java.lang.String,java.lang.Object> args,
@Nonnull
java.util.Locale locale)
throws NoSuchMessageException
key - Key to lookup, such as 'log4j.appenders.console'args - Arguments that will be filled in for params within the message (params look like "{:key}"
within a message, but this might differ between implementations), or null if none.locale - Locale in which to lookupNoSuchMessageException - if no message is found@Nullable
java.lang.String getMessage(@Nonnull
java.lang.String key,
@Nonnull
java.util.Map<java.lang.String,java.lang.Object> args,
@Nullable
java.lang.String defaultMessage)
key - Key to lookup, such as 'log4j.appenders.console'args - Arguments that will be filled in for params within the message (params look like "{:key}"
within a message, but this might differ between implementations), or null if none.defaultMessage - Message to return if the lookup fails@Nullable
java.lang.String getMessage(@Nonnull
java.lang.String key,
@Nonnull
java.util.Map<java.lang.String,java.lang.Object> args,
@Nonnull
java.util.Locale locale,
@Nullable
java.lang.String defaultMessage)
key - Key to lookup, such as 'log4j.appenders.console'args - Arguments that will be filled in for params within the message (params look like "{:key}"
within a message, but this might differ between implementations), or null if none.locale - Locale in which to lookupdefaultMessage - Message to return if the lookup fails@Nonnull
java.lang.Object resolveMessageValue(@Nonnull
java.lang.String key,
@Nonnull
java.util.Locale locale)
throws NoSuchMessageException
Resolve a message given a key and a Locale.
This method should use the default Locale if the locale argument is null. The key argument may refer to
another key if the resolved value results in a CharSequence that begins with "@[" and ends with "]". In this
case the method will use the enclosed value as the next key to be resolved. For example, given the following key/value
definitions
some.key = Hello {0}
other.key = @[some.key]
Evaluating the keys results in
assert resolveMessageValue('some.key', Locale.default) == 'Hello {0}'
assert resolveMessageValue('other.key', Locale.default) == 'Hello {0}'
key - Key to lookup, such as 'log4j.appenders.console'locale - Locale in which to lookupNoSuchMessageException - if no message is found@Nonnull
java.lang.String formatMessage(@Nonnull
java.lang.String message,
@Nonnull
java.util.List<?> args)
message - The message following a predefined format.args - Arguments that will be filled in for params within the message (params look like "{0}"
within a message, but this might differ between implementations), or null if none.@Nonnull
java.lang.String formatMessage(@Nonnull
java.lang.String message,
@Nonnull
java.lang.Object[] args)
message - The message following a predefined format.args - Arguments that will be filled in for params within the message (params look like "{0}"
within a message, but this might differ between implementations), or null if none.@Nonnull
java.lang.String formatMessage(@Nonnull
java.lang.String message,
@Nonnull
java.util.Map<java.lang.String,java.lang.Object> args)
message - The message following a predefined format.args - Arguments that will be filled in for params within the message (params look like "{:key}"
within a message, but this might differ between implementations), or null if none.@Nonnull java.util.ResourceBundle asResourceBundle()
MessageSource as a ResourceBundle.ResourceBundle containing the keys this MessageSource
can resolve.