Package com.networknt.schema.i18n
Class ResourceBundleMessageSource
- java.lang.Object
-
- com.networknt.schema.i18n.ResourceBundleMessageSource
-
- All Implemented Interfaces:
MessageSource
public class ResourceBundleMessageSource extends Object implements MessageSource
MessageSource
that retrieves messages from aResourceBundle
.
-
-
Constructor Summary
Constructors Constructor Description ResourceBundleMessageSource(String... baseName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getMessage(String key, Supplier<String> defaultMessage, Locale locale, Object... arguments)
Gets the message.protected MessageFormat
getMessageFormat(Locale locale, String message)
protected String
getMessageFromCache(Locale locale, String key)
Gets the message from cache or the resource bundles.protected Map<Locale,ResourceBundle>
getResourceBundle(String baseName)
protected ResourceBundle
getResourceBundle(String baseName, Locale locale)
protected String
resolveMessage(Locale locale, String key)
Gets the message from the resource bundles.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.networknt.schema.i18n.MessageSource
getMessage, getMessage
-
-
-
-
Constructor Detail
-
ResourceBundleMessageSource
public ResourceBundleMessageSource(String... baseName)
-
-
Method Detail
-
getMessage
public String getMessage(String key, Supplier<String> defaultMessage, Locale locale, Object... arguments)
Description copied from interface:MessageSource
Gets the message.- Specified by:
getMessage
in interfaceMessageSource
- Parameters:
key
- to look up the messagedefaultMessage
- the default messagelocale
- the locale to usearguments
- the message arguments- Returns:
- the message
-
getMessageFormat
protected MessageFormat getMessageFormat(Locale locale, String message)
-
getMessageFromCache
protected String getMessageFromCache(Locale locale, String key)
Gets the message from cache or the resource bundles. Returns an empty string if not found.- Parameters:
locale
- the localekey
- the message key- Returns:
- the message
-
resolveMessage
protected String resolveMessage(Locale locale, String key)
Gets the message from the resource bundles. Returns an empty string if not found.- Parameters:
locale
- the localekey
- the message key- Returns:
- the message
-
getResourceBundle
protected Map<Locale,ResourceBundle> getResourceBundle(String baseName)
-
getResourceBundle
protected ResourceBundle getResourceBundle(String baseName, Locale locale)
-
-