Package com.jgoodies.common.internal
Class ResourceBundleAccessor
- java.lang.Object
-
- com.jgoodies.common.internal.ResourceBundleAccessor
-
- All Implemented Interfaces:
IconResourceAccessor
,StringAndIconResourceAccessor
,StringResourceAccessor
public final class ResourceBundleAccessor extends java.lang.Object implements StringAndIconResourceAccessor
Turns a ResourceBundle into aStringAndIconResourceAccessor
.Note: This class is not part of the public JGoodies Common API. It's intended for implementation purposes only. The class's API may change at any time.
- Since:
- 1.8
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.ResourceBundle
bundle
-
Constructor Summary
Constructors Constructor Description ResourceBundleAccessor(java.util.ResourceBundle bundle)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.swing.Icon
getIcon(java.lang.String key)
Returns the Icon resource associated with the given key.java.lang.String
getString(java.lang.String key, java.lang.Object... args)
Looks up and returns a String associated with the given resource key.
-
-
-
Method Detail
-
getIcon
public javax.swing.Icon getIcon(java.lang.String key)
Description copied from interface:IconResourceAccessor
Returns the Icon resource associated with the given key.- Specified by:
getIcon
in interfaceIconResourceAccessor
- Parameters:
key
- the key used to look up the Icon- Returns:
- the Icon
-
getString
public java.lang.String getString(java.lang.String key, java.lang.Object... args)
Looks up and returns a String associated with the given resource key. If no arguments are provided, the plain String is returned. Otherwise the string will be formatted usingString.format
with the given arguments.In case the resource key is missing in the bundle, this implementation returns the key itself.
- Specified by:
getString
in interfaceStringResourceAccessor
- Parameters:
key
- the key in the resource bundleargs
- optional format arguments forwarded toString#format
- Returns:
- the String value found for the given resource key, formatted with the optional arguments - if any, or - if the key is missing in the bundle - the resource key itself
- See Also:
String.format(String, Object...)
-
-