Package com.apgar.common.lib.properties
Class RefResourceBundle
java.lang.Object
com.apgar.common.lib.properties.RefResourceBundle
This class provides access to localized resource files. It allows loading properties files and retrieving values based on keys.
Key functionalities include:
- Loading properties files for different locales.
- Retrieving values associated with keys.
- Formatting strings with dynamic parameters.
- Author:
- APGAR Consulting
-
Constructor Summary
ConstructorsConstructorDescriptionRefResourceBundle(String pName, String pMasterDataRefITP) Loads a specific properties file.RefResourceBundle(String pName, Locale pLocale) Loads the global properties file.RefResourceBundle(String pName, Locale pLocale, String pMasterData) Loads a specific localized properties file. -
Method Summary
Modifier and TypeMethodDescriptionstatic RefResourceBundleRetrieves the default error message resource bundle.static RefResourceBundlegetErrorMessageBundle(Locale pLocale) Retrieves the error message resource bundle based on the specified locale.getKeys()Retrieves all keys in the resource bundle.static LocaleReturns a complete Locale object based on the specified language.Returns the value corresponding to the specified key.Returns a formatted string corresponding to the specified key, replacing the placeholder with the provided single parameter.Returns a formatted string corresponding to the specified key, replacing placeholders with provided parameters.getStringWithDefault(String pKey, String pDefaultValue) Returns the value associated with the specified key, or a default value if the key is not found.static RefResourceBundleRetrieves the default text resource bundle for display.static RefResourceBundlegetTextBundle(Locale pLocale) Retrieves the text resource bundle for display based on the specified locale.static RefResourceBundlegetTextBundle(Locale pLocale, String pMasterData) Retrieves the text resource bundle for display based on the specified locale and master data.
-
Constructor Details
-
RefResourceBundle
Loads the global properties file.- Parameters:
pName- the name of the properties file (without the file extension).pLocale- the locale for which the properties are loaded.
-
RefResourceBundle
Loads a specific properties file.- Parameters:
pName- the name of the properties file (without the file extension)pMasterDataRefITP- the path to the master data directory
-
RefResourceBundle
Loads a specific localized properties file.- Parameters:
pName- the name of the properties file (without the file extension)pLocale- the locale for which the properties are loadedpMasterData- the path to the master data directory
-
-
Method Details
-
getKeys
Retrieves all keys in the resource bundle.- Returns:
- an enumeration of all keys in the resource bundle
-
getString
Returns the value corresponding to the specified key. If the key is not found, the method returns the key itself.- Parameters:
pKey- the properties key to look up- Returns:
- the value associated with the specified key, or the key if not found
-
getString
Returns a formatted string corresponding to the specified key, replacing placeholders with provided parameters.- Parameters:
pString- the key of the properties to look uppParams- an array of strings to replace placeholders in the value- Returns:
- the formatted string with parameters replaced
-
getString
Returns a formatted string corresponding to the specified key, replacing the placeholder with the provided single parameter.- Parameters:
pString- the key of the properties to look uppParam- the string to replace the placeholder in the value- Returns:
- the formatted string with the parameter replaced
-
getStringWithDefault
Returns the value associated with the specified key, or a default value if the key is not found.- Parameters:
pKey- the properties key to look uppDefaultValue- the value to return if the key is not found- Returns:
- the value associated with the specified key, or the default value
-
getErrorMessageBundle
Retrieves the error message resource bundle based on the specified locale.- Parameters:
pLocale- the locale for which to load the error messages- Returns:
- a RefResourceBundle containing error messages for the specified locale
-
getErrorMessageBundle
Retrieves the default error message resource bundle.- Returns:
- a RefResourceBundle containing default error messages
-
getTextBundle
Retrieves the text resource bundle for display based on the specified locale and master data.- Parameters:
pLocale- the locale for which to load the display textspMasterData- the path to the master data directory- Returns:
- a RefResourceBundle containing display texts for the specified locale
-
getTextBundle
Retrieves the text resource bundle for display based on the specified locale.- Parameters:
pLocale- the locale for which to load the display texts- Returns:
- a RefResourceBundle containing display texts for the specified locale
-
getTextBundle
Retrieves the default text resource bundle for display.- Returns:
- a RefResourceBundle containing default display texts
-
getLocale
Returns a complete Locale object based on the specified language.Limitations: Limitations: This method only supports English ("en") and French ("fr").
- Parameters:
language- the language code (e.g., "en" for English)- Returns:
- a Locale object corresponding to the specified language; if the input is null or an unsupported language, the default Locale (French) is returned.
-