Package com.jk.core.locale
Class JKMessage
java.lang.Object
com.jk.core.locale.JKMessage
This class provides methods needed to interact and get the labels and their
properties of the
JKMessage
objects.- Version:
- 1.0
- Author:
- Dr. Jalal H. Kiswani
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Represents The default path of the labels properties file. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
This method constructs a newJKMessage
with default configurations. -
Method Summary
Modifier and TypeMethodDescriptionvoid
This method adds labels according to the locale specified and the file name provided.void
addLables
(JKLocale locale, Properties lables) This method adds the labels using the provided locale and properties.void
addLables
(Properties readPropertiesFile) This method adds the labels using the default locale as well as the provided properties.void
clear()
This method clears the labels map, the map will be empty after this call.This method fixes the label value to a custom format.static String
This method retrieves a localized label by its key, with optional parameter formatting.static JKMessage
This method gets the instance ofJKMessage
.This method retrieves a localized label or message by its key, with optional parameter formatting.This method returns the label associated with the provided caption, and edit it by capitalizing the first letter of the label if needed.This method gets the label associated with the provided key.This method gets the label property value that is linked with the specified locale in the labels map.protected void
This method loads up the default configuration to theJKMessage
objects.protected void
setProperty
(JKLocale locale, String propName, String value) This method replaces the value linked with the specified properties key in the labels map to the provided value, while considering the provided locale.
-
Field Details
-
DEFAULT_LABLES_FILE_NAME
Represents The default path of the labels properties file.- See Also:
-
-
Constructor Details
-
JKMessage
protected JKMessage()This method constructs a newJKMessage
with default configurations.- See Also:
-
-
Method Details
-
loadDefaultConfigurations
protected void loadDefaultConfigurations()This method loads up the default configuration to theJKMessage
objects. -
addLables
This method adds the labels using the default locale as well as the provided properties.- Parameters:
readPropertiesFile
- Specifies the labels properties.
-
getInstance
This method gets the instance ofJKMessage
.- Returns:
- the instance of
JKMessage
.
-
get
This method retrieves a localized label by its key, with optional parameter formatting.- Parameters:
key
- Specifies the unique identifier for the localized label.params
- Specifies the optional parameters used for formatting the label.- Returns:
- the localized label as a formatted string.
-
addLables
This method adds the labels using the provided locale and properties.- Parameters:
locale
- Specifies the labels locale.lables
- Specifies the labels properties.
-
setProperty
This method replaces the value linked with the specified properties key in the labels map to the provided value, while considering the provided locale.- Parameters:
locale
- Specifies the label locale.propName
- Specifies the property to change key.value
- Specifies the new value of the property.
-
getLables
This method gets the label property value that is linked with the specified locale in the labels map.- Parameters:
locale
- Specifies the label locale whose property is requested.- Returns:
- the label property.
-
fixValue
This method fixes the label value to a custom format.- Parameters:
value
- Specifies the current label value.- Returns:
- the new value after fixing.
-
clear
public void clear()This method clears the labels map, the map will be empty after this call.- See Also:
-
getLabel
This method returns the label associated with the provided caption, and edit it by capitalizing the first letter of the label if needed.- Parameters:
caption
- Specifies the label key in the labels map.captizliseFirstLetter
- Specifies whether to capitalize the first letter of the label or not.- Returns:
- the requested label.
-
getLabel
This method gets the label associated with the provided key.- Parameters:
key
- Specifies the key associated with the label to get.params
- Specifies optional parameters used for formatting the label.- Returns:
- the label associated with the provided key.
-
getLabel
This method retrieves a localized label or message by its key, with optional parameter formatting.- Parameters:
locale
- Specifies the label locale.key
- Specifies the key associated with the label.params
- Specifies optional parameters used for formating the label.- Returns:
- the localized label as a formatted string or empty
-
addLables
This method adds labels according to the locale specified and the file name provided.- Parameters:
locale
- Specifies the label locale.fileName
- Specifies the file name for the label properties file.
-