com.bws42.wizard
Class LanguageLoader

java.lang.Object
  extended bycom.bws42.wizard.LanguageLoader

public class LanguageLoader
extends Object

Allows for loading of different languages for the strings of a program.

Version:
1.0, October 4, 2006
Author:
William P. Roberts, IV

Constructor Summary
LanguageLoader(ResourceBundle resource)
          Creates a LanguageLoader for the program.
LanguageLoader(String bundleName, Locale locale)
          Creates a LanguageLoader for the program.
LanguageLoader(String bundleName, String locale)
          Creates a LanguageLoader for the program.
 
Method Summary
 String getString(String key)
          Gets the string for the given key if it exists.
 String getString(String key, Object[] vars)
          Gets the string for the given key if it exists and returns it with any variables replaced by the appropriate string in the Object[].
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LanguageLoader

public LanguageLoader(String bundleName,
                      String locale)
Creates a LanguageLoader for the program.

Parameters:
bundleName - the name of the resource bundle.
locale - language string

LanguageLoader

public LanguageLoader(String bundleName,
                      Locale locale)
Creates a LanguageLoader for the program.

Parameters:
bundleName - the name of the resource bundle.
locale - the desired Locale.

LanguageLoader

public LanguageLoader(ResourceBundle resource)
Creates a LanguageLoader for the program.

Parameters:
resource - the ResourceBundle.
Method Detail

getString

public final String getString(String key)
Gets the string for the given key if it exists.

Parameters:
key - the key to search for.
Returns:
the string corresponding to the key or the key if the key does not exist.

getString

public final String getString(String key,
                              Object[] vars)
Gets the string for the given key if it exists and returns it with any variables replaced by the appropriate string in the Object[]. Variables are denoted by {#} in the text file, and the count starts at 0.

Parameters:
key - the key to search for
vars - the strings to replace the variables with
Returns:
the string corresponding to the key with the replacements or the key if the key does not exist.