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 booleancontainsKey(String key)Gets whether thisMessagescontains the designated key.LocalegetActualLocale()Gets the actual locale of this messages.StringgetFormattedString(String key, Object... args)Gets the string for the designated key formatted usingFormat.format(Object).LocalegetLocale()Gets the intended locale of the messages which is also used forMessageFormat.StringgetString(String key, Object... args)Gets the string for the designated key formatted usingString.format(String, Object...).default MessagessubMessages(String prefix)Gets a newMessagesfor the designated prefix, that are all messages of thisMessageof 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 thisMessagescontains the designated key.- Parameters:
key- The key to check whether it exists in thisMessages.- Returns:
- Whether this
Messagescontains 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 isnullor 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 newMessagesfor the designated prefix, that are all messages of thisMessageof which the keys start with the designated prefix.- Parameters:
prefix- The prefix used for all keys requested from thisMessagesinstance. This need not end with ".".- Returns:
- Messages of which all the keys have the designated prefix. This may be empty.
-
-