|
Sky View Café - Java | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.shetline.util.BundleResourceProvider
public class BundleResourceProvider
A basic implementation of ResourceProvider
which relies on one or more .properties files
to provide string resources.
Field Summary | |
---|---|
protected Vector<ResourceBundle> |
bundles
|
protected static String |
defaultEncoding
|
protected static PropertiesControl.LocaleMode |
defaultLocaleMode
|
protected static Locale |
defaultRootLocale
|
Constructor Summary | |
---|---|
BundleResourceProvider(Class classInPackage,
String baseName)
Constructor specifying a class and a base name for a .properties file located in the package directory of the specified class. |
|
BundleResourceProvider(Class classInPackage,
String baseName,
Locale locale)
Constructor specifying a class and a base name for a .properties file located in the package directory of the specified class matching the specified locale. |
|
BundleResourceProvider(String baseName)
Constructor specifying one base name, or a comma-delimited list of base names, for one or more .properties resource files. |
|
BundleResourceProvider(String[] baseNames)
Constructor specifying an array of base names for one or more .properties resource files. |
|
BundleResourceProvider(String[] baseNames,
Locale locale)
Constructor specifying an array of base names for one or more .properties resource files matching the specified locale. |
|
BundleResourceProvider(String[] baseNames,
Locale locale,
String encoding,
PropertiesControl.LocaleMode localeMode,
Locale rootLocale)
Constructor specifying an array of base names for one or more .properties resource files matching the specified locale. |
|
BundleResourceProvider(String baseName,
Locale locale)
Constructor specifying one base name, or a comma-delimited list of base names, for one or more .properties resource files matching the specified locale. |
Method Summary | |
---|---|
void |
addChoicesFromResource(JComboBox comboBox,
String key)
Fill in selections choices for a JComboBox using a delimited (as per ResourceProvider.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 . |
ResourceBundle[] |
getBundles()
|
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. |
static void |
setPropertiesDefaults(String encoding,
PropertiesControl.LocaleMode localeMode,
Locale rootLocale)
Sets the default characteristics for resource bundles used by BundleResourceProvider instances. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Vector<ResourceBundle> bundles
protected static String defaultEncoding
protected static PropertiesControl.LocaleMode defaultLocaleMode
protected static Locale defaultRootLocale
Constructor Detail |
---|
public BundleResourceProvider(String baseName)
baseName
- Base name of a .properties resource file, or comma-delimited list of base names.public BundleResourceProvider(String baseName, Locale locale)
baseName
- Base name of a .properties resource file, or comma-delimited list of base names.locale
- Locale for .properties files search.public BundleResourceProvider(Class classInPackage, String baseName)
classInPackage
- Any class in the same package where the .properties file is located.baseName
- Base name of a .properties resource file.public BundleResourceProvider(Class classInPackage, String baseName, Locale locale)
classInPackage
- Any class in the same package where the .properties file is located.baseName
- Base name of a .properties resource file.locale
- Locale for .properties file search.public BundleResourceProvider(String[] baseNames)
baseNames
- Base name of a .properties resource file.public BundleResourceProvider(String[] baseNames, Locale locale)
baseNames
- Base names of .properties resource files.locale
- Locale for .properties file search.public BundleResourceProvider(String[] baseNames, Locale locale, String encoding, PropertiesControl.LocaleMode localeMode, Locale rootLocale)
baseNames
- Base names of .properties resource files.locale
- Locale for .properties file search.encoding
- Encoding of .properties file.localeMode
- Determines if country and/or variant of locale matter.rootLocale
- Locale of root .properties file.Method Detail |
---|
public static void setPropertiesDefaults(String encoding, PropertiesControl.LocaleMode localeMode, Locale rootLocale)
encoding
- Encoding of .properties file.localeMode
- Determines if country and/or variant of locale matter.rootLocale
- Locale of root .properties file.public String getString(String key)
ResourceProvider
getString
in interface ResourceProvider
key
- Resource key.
public String getString(String key, String defaultValue)
ResourceProvider
getString
in interface ResourceProvider
key
- Resource key.defaultValue
- Default return value if resource not found.
defaultValue
if no match is found.public String getString(String key, String defaultValue, boolean failQuietly)
ResourceProvider
getString
in interface ResourceProvider
key
- Resource key.defaultValue
- Default return value if resource not found.failQuietly
- If true, log no error for unmatched resource key.
defaultValue
if no match is found.public String[] getStrings(String key)
ResourceProvider
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:
If none of the above delimiters are found, the resource will be treated as a single string.
getStrings
in interface ResourceProvider
key
- Resource key.
public String[] getStrings(String key, char delimiter)
ResourceProvider
getStrings
in interface ResourceProvider
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.
public String[] getStrings(String key, char delimiter, char escapeChar)
ResourceProvider
getStrings
in interface ResourceProvider
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.
public int getInt(String key)
ResourceProvider
getInt
in interface ResourceProvider
key
- Resource key.
public int getInt(String key, int errorValue)
ResourceProvider
getInt
in interface ResourceProvider
key
- Resource key.errorValue
- Value to return for missing or invalid resources.
errorValue
if no match is found
or if the matching resource does not parse as a proper integer.public String format(String patternKey, Object... args)
ResourceProvider
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
.
format
in interface ResourceProvider
patternKey
- Resource key for a formatting pattern.args
- Values to be applied to the formatting pattern.
MessageFormat.format(String, Object...)
public void addChoicesFromResource(JComboBox comboBox, String key)
ResourceProvider
ResourceProvider.getStrings(String)
resource string.
addChoicesFromResource
in interface ResourceProvider
comboBox
- Target JComboBox.key
- Resource key of delimited list of choices.public ResourceBundle[] getBundles()
|
Sky View Café - Java | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |