Class ResourceBundleAccessor

java.lang.Object
com.jgoodies.common.internal.ResourceBundleAccessor
All Implemented Interfaces:
IconResourceAccessor, StringAndIconResourceAccessor, StringResourceAccessor

public final class ResourceBundleAccessor extends Object implements StringAndIconResourceAccessor
Turns a ResourceBundle into a StringAndIconResourceAccessor.

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 Details

  • Constructor Details

    • ResourceBundleAccessor

      public ResourceBundleAccessor(ResourceBundle bundle)
  • Method Details

    • getIcon

      public Icon getIcon(String key)
      Description copied from interface: IconResourceAccessor
      Returns the Icon resource associated with the given key.
      Specified by:
      getIcon in interface IconResourceAccessor
      Parameters:
      key - the key used to look up the Icon
      Returns:
      the Icon
    • getString

      public String getString(String key, 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 using String.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 interface StringResourceAccessor
      Parameters:
      key - the key in the resource bundle
      args - optional format arguments forwarded to String#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: