Top Description Inners Fields Constructors Methods
com.dlsc.gemsfx.util

public Class ResourceBundleManager

extends Object
Class Inheritance
Imports
java.util.Locale, .Map, .MissingResourceException, .ResourceBundle, java.util.concurrent.ConcurrentHashMap, java.util.logging.Level, .Logger

This class provides a centralized mechanism to retrieve localized strings from property files based on the current locale settings. It caches the resource bundles to avoid repetitive and unnecessary loading of the properties files.

Usage involves retrieving strings via base names of the resource bundles or by using predefined types which represent specific views or components in the application.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Field Summary

Modifier and TypeField and Description
private static final Map<String, ResourceBundle>
private static Locale
private static final Logger

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ResourceBundle

Returns:

the requested resource bundle.
getBundle
(String
the base name of the resource bundle.
baseName
)

Retrieves the resource bundle for the specified base name and the current application locale.

public static String

Returns:

the localized string.
getString
(String
the base name of the resource bundle.
baseName
,
String
the key for the desired string in the bundle.
key
)

Retrieves a localized string from the resource bundle specified by the base name.

public static String

Returns:

the localized string.
getString
(ResourceBundleManager.Type
the type of the resource bundle.
type
,
String
the key for the desired string in the bundle.
key
)

Retrieves a localized string from the resource bundle associated with a given type.

private static String
key(String baseName, Locale locale)

Generates a unique key based on the base name and locale for caching purposes.

public static void
setLocale(Locale
the new locale to set as the current.
locale
)

Sets the current locale of the application.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BUNDLESback to summary
private static final Map<String, ResourceBundle> BUNDLES
currentLocaleback to summary
private static Locale currentLocale
LOGback to summary
private static final Logger LOG

Constructor Detail

ResourceBundleManagerback to summary
private ResourceBundleManager()

Method Detail

getBundleback to summary
public static ResourceBundle getBundle(String baseName)

Retrieves the resource bundle for the specified base name and the current application locale. This method will return a cached bundle if it exists, or load a new bundle if it does not.

Parameters
baseName:String

the base name of the resource bundle.

Returns:ResourceBundle

the requested resource bundle.

getStringback to summary
public static String getString(String baseName, String key)

Retrieves a localized string from the resource bundle specified by the base name. If the key is not found, it logs a warning and returns the key itself.

Parameters
baseName:String

the base name of the resource bundle.

key:String

the key for the desired string in the bundle.

Returns:String

the localized string.

getStringback to summary
public static String getString(ResourceBundleManager.Type type, String key)

Retrieves a localized string from the resource bundle associated with a given type.

Parameters
type:ResourceBundleManager.Type

the type of the resource bundle.

key:String

the key for the desired string in the bundle.

Returns:String

the localized string.

keyback to summary
private static String key(String baseName, Locale locale)

Generates a unique key based on the base name and locale for caching purposes.

setLocaleback to summary
public static void setLocale(Locale locale)

Sets the current locale of the application. If the locale is changed, the method clears the cache of loaded resource bundles.

Parameters
locale:Locale

the new locale to set as the current.

com.dlsc.gemsfx.util back to summary

public final Enum ResourceBundleManager.Type

extends Enum<ResourceBundleManager.Type>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final String
public static final ResourceBundleManager.Type
public static final ResourceBundleManager.Type

Constructor Summary

AccessConstructor and Description
private
Type(String baseName)

Method Summary

Modifier and TypeMethod and Description
public String
public static ResourceBundleManager.Type
public static ResourceBundleManager.Type[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

baseNameback to summary
private final String baseName
INFO_CENTER_VIEWback to summary
public static final ResourceBundleManager.Type INFO_CENTER_VIEW
NOTIFICATION_VIEWback to summary
public static final ResourceBundleManager.Type NOTIFICATION_VIEW

Constructor Detail

Typeback to summary
private Type(String baseName)

Method Detail

getBaseNameback to summary
public String getBaseName()
valueOfback to summary
public static ResourceBundleManager.Type valueOf(String name)
valuesback to summary
public static ResourceBundleManager.Type[] values()