Sky View Café - Java

org.shetline.util
Interface ResourceProvider

All Known Implementing Classes:
BundleResourceProvider, KApplet

public interface ResourceProvider


Method Summary
 void addChoicesFromResource(JComboBox comboBox, String key)
          Fill in selections choices for a JComboBox using a delimited (as per getStrings(String) resource string.
 String format(String patternKey, Object... args)
          Return a formatted string, filled in using a specified list of arguments, as per ExtendedMessageFormat.format(String, Object...), where the pattern argument is a resource string matching the specified patternKey.
 int getInt(String key)
          Return an integer value for the given key.
 int getInt(String key, int errorValue)
          Return an integer value for the given key.
 String getString(String key)
          Return a resource string for the given key.
 String getString(String key, String defaultValue)
          Return a resource string for the given key.
 String getString(String key, String defaultValue, boolean failQuietly)
          Return a resource string for the given key.
 String[] getStrings(String key)
          Return an array of strings parsed from the resource string for the given key.
 String[] getStrings(String key, char delimiter)
          Return an array of strings parsed from the resource string for the given key.
 String[] getStrings(String key, char delimiter, char escapeChar)
          Return an array of strings parsed from the resource string for the given key.
 

Method Detail

getString

String getString(String key)
Return a resource string for the given key.

Parameters:
key - Resource key.
Returns:
Matching string resource, or "<<key>>" if no match is found.

getString

String getString(String key,
                 String defaultValue)
Return a resource string for the given key.

Parameters:
key - Resource key.
defaultValue - Default return value if resource not found.
Returns:
Matching string resource, or defaultValue if no match is found.

getString

String getString(String key,
                 String defaultValue,
                 boolean failQuietly)
Return a resource string for the given key.

Parameters:
key - Resource key.
defaultValue - Default return value if resource not found.
failQuietly - If true, log no error for unmatched resource key.
Returns:
Matching string resource, or defaultValue if no match is found.

getStrings

String[] getStrings(String key)

Return an array of strings parsed from the resource string for the given key.

The delimiters used to separate multiple string items will be automatically determined as follows, in this order of evaluation:

  1. If the resource contains any new line characters (\n), use new line as the item separator.
  2. If the resource contains any tab characters (\t), use tab as the item separator.
  3. If the resource contains any semicolons (;), use semicolon as the item separator, use backslash (\) as an escape character for literally-intended semicolons, and double backslash for single literally-intended backslashes
  4. If the resource contains any commas (,), use comma as the item separator, use backslash (\) as an escape character for literally-intended commas, and double backslash for single literally-intended backslashes

If none of the above delimiters are found, the resource will be treated as a single string.

Parameters:
key - Resource key.
Returns:
Matching string resource parsed into an array of strings, or a single-item array containing "<<key>>" if no matching resource is found.

getStrings

String[] getStrings(String key,
                    char delimiter)
Return an array of strings parsed from the resource string for the given key.

Parameters:
key - Resource key.
delimiter - The delimiter character used to separate individual string items. If the delimiter is either semicolon (;) or comma (,) backslash (\) is used as an escape character.
Returns:
Matching string resource parsed into an array of strings, or a single-item array containing "<<key>>" if no matching resource is found.

getStrings

String[] getStrings(String key,
                    char delimiter,
                    char escapeChar)
Return an array of strings parsed from the resource string for the given key.

Parameters:
key - Resource key.
delimiter - The delimiter character used to separate individual string items.
escapeChar - An escape character. If the null character (\0) is specified, no escaping is performed.
Returns:
Matching string resource parsed into an array of strings, or a single-item array containing "<<key>>" if no matching resource is found.

getInt

int getInt(String key)
Return an integer value for the given key.

Parameters:
key - Resource key.
Returns:
Integer value of matching string resource, 0 if no match is found or if the matching resource does not parse as a proper integer.

getInt

int getInt(String key,
           int errorValue)
Return an integer value for the given key.

Parameters:
key - Resource key.
errorValue - Value to return for missing or invalid resources.
Returns:
Integer value of matching string resource, errorValue if no match is found or if the matching resource does not parse as a proper integer.

format

String format(String patternKey,
              Object... args)

Return a formatted string, filled in using a specified list of arguments, as per ExtendedMessageFormat.format(String, Object...), where the pattern argument is a resource string matching the specified patternKey.

Parameters:
patternKey - Resource key for a formatting pattern.
args - Values to be applied to the formatting pattern.
Returns:
A formatted string based on the supplied pattern and values.
See Also:
MessageFormat.format(String, Object...)

addChoicesFromResource

void addChoicesFromResource(JComboBox comboBox,
                            String key)
Fill in selections choices for a JComboBox using a delimited (as per getStrings(String) resource string.

Parameters:
comboBox - Target JComboBox.
key - Resource key of delimited list of choices.

Sky View Café - Java