public class PropertyStringResourceLoader extends Object implements ResourceLoader
ResourceLoader that loads string resources
from property files.
This class uses MessageFormat to perform substitutions
within parameterized strings.
MessageFormat| Modifier and Type | Field and Description |
|---|---|
static String |
LCDS_PROPERTY_BUNDLE |
static String |
PROPERTY_BUNDLE |
static String |
VENDORS_BUNDLE |
| Constructor and Description |
|---|
PropertyStringResourceLoader()
Constructs a
PropertyStringResourceLoader using the default
property bundles specified by the PROPERTY_BUNDLE and
LCDS_PROPERTY_BUNDLE fields. |
PropertyStringResourceLoader(String propertyBundle)
Constructs a
PropertyStringResourceLoader that will use the
specified property bundle to use for string lookups. |
PropertyStringResourceLoader(String[] propertyBundles)
Constructs a
PropertyStringResourceLoader that will use the
specified property bundles to use for string lookups. |
| Modifier and Type | Method and Description |
|---|---|
Locale |
getDefaultLocale()
The default locale to be used when locating resources.
|
String |
getString(String key)
Gets a string for the given key.
|
String |
getString(String key,
Locale locale)
Gets a string for the given key and locale.
|
String |
getString(String key,
Locale locale,
Object[] arguments)
Gets a parameterized string for the given key and locale and substitutes the
parameters using the passed array of arguments.
|
String |
getString(String key,
Object[] arguments)
Gets a parameterized string for the given key and substitutes
the parameters using the passed array of arguments.
|
void |
init(Map properties)
Initializes the
ResourceLoader using the specified properties. |
protected InputStream |
loadFile(String filename) |
protected void |
loadProperties(String localeKey,
String propertyBundle) |
protected void |
loadStrings(String localeKey)
Loads localized strings for the specified locale from a property file.
|
void |
setDefaultLocale(Locale locale)
Sets the default locale to be used when locating resources.
|
void |
setDefaultLocale(String locale)
Sets the default locale to be used when locating resources.
|
public static final String PROPERTY_BUNDLE
public static final String VENDORS_BUNDLE
public static final String LCDS_PROPERTY_BUNDLE
public PropertyStringResourceLoader()
PropertyStringResourceLoader using the default
property bundles specified by the PROPERTY_BUNDLE and
LCDS_PROPERTY_BUNDLE fields.public PropertyStringResourceLoader(String propertyBundle)
PropertyStringResourceLoader that will use the
specified property bundle to use for string lookups.propertyBundle - The property bundles to use for lookups.public PropertyStringResourceLoader(String[] propertyBundles)
PropertyStringResourceLoader that will use the
specified property bundles to use for string lookups.propertyBundles - The list of the property bundles to use for lookups.public void init(Map properties)
ResourceLoaderResourceLoader using the specified properties.init in interface ResourceLoaderproperties - The initialization properties.public String getString(String key)
ResourceLoadergetString in interface ResourceLoaderkey - The key for the target string.public String getString(String key, Object[] arguments)
ResourceLoadergetString in interface ResourceLoaderkey - The key for the target string.arguments - The arguments to substitute into the parameterized string.public String getString(String key, Locale locale)
ResourceLoadergetString in interface ResourceLoaderkey - The key for the target string.locale - The target locale for the string.public String getString(String key, Locale locale, Object[] arguments)
ResourceLoadergetString in interface ResourceLoaderkey - The key for the target string.locale - The target locale for the string.arguments - The arguments to substitute into the parameterized string.public void setDefaultLocale(String locale)
setDefaultLocale in interface ResourceLoaderlocale - The default locale to be used.public void setDefaultLocale(Locale locale)
setDefaultLocale in interface ResourceLoaderlocale - The default locale to be used.public Locale getDefaultLocale()
getDefaultLocale in interface ResourceLoaderprotected void loadStrings(String localeKey)
localeKey - The locale to load strings for.protected InputStream loadFile(String filename)
Copyright © 2015 The Apache Software Foundation. All rights reserved.