Package org.apache.commons.text.lookup
Class ResourceBundleStringLookup
- java.lang.Object
-
- org.apache.commons.text.lookup.AbstractStringLookup
-
- org.apache.commons.text.lookup.ResourceBundleStringLookup
-
- All Implemented Interfaces:
StringLookup
final class ResourceBundleStringLookup extends AbstractStringLookup
Looks up keys from resource bundles.Looks up the value for a given key in the format "BundleName:BundleKey".
For example: "com.domain.messages:MyKey".
- Since:
- 1.3
- See Also:
ResourceBundle
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
bundleName
The name of the resource bundle from which to look something up.(package private) static ResourceBundleStringLookup
INSTANCE
Defines the singleton for this class.-
Fields inherited from class org.apache.commons.text.lookup.AbstractStringLookup
SPLIT_CH, SPLIT_STR
-
-
Constructor Summary
Constructors Constructor Description ResourceBundleStringLookup()
Constructs a blank instance.ResourceBundleStringLookup(java.lang.String bundleName)
Constructs an instance that only works for the given bundle.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) java.util.ResourceBundle
getBundle(java.lang.String keyBundleName)
(package private) java.lang.String
getString(java.lang.String keyBundleName, java.lang.String bundleKey)
java.lang.String
lookup(java.lang.String key)
Looks up the value for the key in the format "BundleName:BundleKey".java.lang.String
toString()
-
Methods inherited from class org.apache.commons.text.lookup.AbstractStringLookup
substringAfter, substringAfter, substringAfterLast, toLookupKey, toLookupKey
-
-
-
-
Field Detail
-
INSTANCE
static final ResourceBundleStringLookup INSTANCE
Defines the singleton for this class.
-
bundleName
private final java.lang.String bundleName
The name of the resource bundle from which to look something up.
-
-
Constructor Detail
-
ResourceBundleStringLookup
ResourceBundleStringLookup()
Constructs a blank instance. This ctor is not private to allow Mockito spying.
-
ResourceBundleStringLookup
ResourceBundleStringLookup(java.lang.String bundleName)
Constructs an instance that only works for the given bundle.- Parameters:
bundleName
- the name of the resource bundle from which we will look keys up.- Since:
- 1.5
-
-
Method Detail
-
getBundle
java.util.ResourceBundle getBundle(java.lang.String keyBundleName)
-
getString
java.lang.String getString(java.lang.String keyBundleName, java.lang.String bundleKey)
-
lookup
public java.lang.String lookup(java.lang.String key)
Looks up the value for the key in the format "BundleName:BundleKey". For example: "com.domain.messages:MyKey".- Parameters:
key
- the key to be looked up, may be null- Returns:
- The value associated with the key.
- See Also:
ResourceBundle
,ResourceBundle.getBundle(String)
,ResourceBundle.getString(String)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-