Package de.aristaflow.adept2.util.i18n
Interface Messages
-
- All Known Implementing Classes:
ResBundleMessages
,SubMessages
public interface Messages extends Iterable<String>
Interface for providing messages (and other strings) for a specific locale.The locale may actually differ from the language of the messages depending on which resource bundles are available and the fallback mechanism of a resource bundle.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
containsKey(String key)
Gets whether thisMessages
contains the designated key.Locale
getActualLocale()
Gets the actual locale of this messages.String
getFormattedString(String key, Object... args)
Gets the string for the designated key formatted usingFormat.format(Object)
.Locale
getLocale()
Gets the intended locale of the messages which is also used forMessageFormat
.String
getString(String key, Object... args)
Gets the string for the designated key formatted usingString.format(String, Object...)
.default Messages
subMessages(String prefix)
Gets a newMessages
for the designated prefix, that are all messages of thisMessage
of which the keys start with the designated prefix.-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
-
-
-
Method Detail
-
getLocale
Locale getLocale()
Gets the intended locale of the messages which is also used forMessageFormat
.- Returns:
- The intended locale of the messages .
-
getActualLocale
Locale getActualLocale()
Gets the actual locale of this messages. This may be a fallback of the intended locale.- Returns:
- The actual locale of the messages .
-
containsKey
boolean containsKey(String key)
Gets whether thisMessages
contains the designated key.- Parameters:
key
- The key to check whether it exists in thisMessages
.- Returns:
- Whether this
Messages
contains the designated key.
-
getString
String getString(String key, Object... args)
Gets the string for the designated key formatted usingString.format(String, Object...)
. If the key is not known, the key itself will be returned instead of throwing aMissingResoucreException
.- Parameters:
key
- The key of the localised string.args
- The arguments forString.format(String, Object...)
. If this isnull
or an empty array, formatting will be skipped.- Returns:
- The formatted string message for the designated key.
-
getFormattedString
String getFormattedString(String key, Object... args)
Gets the string for the designated key formatted usingFormat.format(Object)
. If the key is not known, the key itself will be returned instead of throwing aMissingResoucreException
.- Parameters:
key
- The key of the localised string.args
- The arguments forFormat.format(Object)
.- Returns:
- The formatted string message for the designated key.
-
subMessages
default Messages subMessages(String prefix)
Gets a newMessages
for the designated prefix, that are all messages of thisMessage
of which the keys start with the designated prefix.- Parameters:
prefix
- The prefix used for all keys requested from thisMessages
instance. This need not end with ".".- Returns:
- Messages of which all the keys have the designated prefix. This may be empty.
-
-