ResourceBundleAccessor (JGoodies Common 1.8 API)
Date: 2015-01-03

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 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
  Author:
    Karsten Lentzsch

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ResourceBundleAccessor(ResourceBundle bundle)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Icon` | `getIcon(String key)` Returns the Icon resource associated with the given key.
    `String` | `getString(String key, Object... args)` Looks up and returns a String associated with the given resource key.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ResourceBundleAccessor

          public ResourceBundleAccessor(ResourceBundle bundle)

  - ### Method Detail

    - #### 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:
        `String.format(String, Object...)`

Copyright © 2009-2014 JGoodies Software GmbH. All Rights Reserved.