public final class PropertiesBundle extends Object
This is the class you will use if you want to load a legay ResourceBundle (using legacyResourceBundle(String)). However, if
you are starting a new bundle, it is recommended to use the other methods.
The generic method is forPath(String, Charset, long, TimeUnit).
You can therefore specify the character set and timeout. When no character
set is specified, the default is UTF-8, except for legacyResourceBundle(String) which will read property files as ResourceBundle does: in ISO-8859-1.
All constructors have a resourcePath argument; in the same vein
as ResourceBundle, the following inputs are allowed:
org/foobar/message.properties;org/foobar/message;/org/foobar/message.properties;/org/foobar/message.| Modifier and Type | Method and Description |
|---|---|
static MessageBundle |
forPath(String resourcePath)
Create a message bundle from a set of property files, using the UTF-8
character set
|
static MessageBundle |
forPath(String resourcePath,
Charset charset,
long duration,
TimeUnit unit)
Create a message bundle from a set of property files, with a defined
charset and expiry time
|
static MessageBundle |
forPath(String resourcePath,
long duration,
TimeUnit timeUnit)
Create a message bundle from a set of property files, using the UTF-8
character set, and an expiry delay
|
static MessageBundle |
legacyResourceBundle(String resourcePath)
Create a message bundle mimicking a
ResourceBundle |
public static MessageBundle forPath(String resourcePath)
resourcePath - the resource pathMessageBundleNullPointerException - resource path is nullpublic static MessageBundle forPath(String resourcePath, long duration, TimeUnit timeUnit)
resourcePath - the resource pathduration - expiry durationtimeUnit - expiry time unitMessageBundleNullPointerException - resource path or duration is nullIllegalArgumentException - duration is 0 or lessLoadingMessageSourceProviderpublic static MessageBundle forPath(String resourcePath, Charset charset, long duration, TimeUnit unit)
resourcePath - the resource pathcharset - the character setduration - expiry durationunit - expiry time unitMessageBundleNullPointerException - resource path, charset or duration is nullIllegalArgumentException - duration is 0 or lessLoadingMessageSourceProviderpublic static MessageBundle legacyResourceBundle(String resourcePath)
ResourceBundle
Using this method will provide a MessageBundle with the
following characteristics:
This method is only there for legacy reasons. Ultimately, you should choose to use a more modern (ie, UTF-8) message bundle instead.
resourcePath - the resource pathPropertiesMessageSource.fromResource(String, Charset)