Class CompositeResourceBundle
java.lang.Object
java.util.ResourceBundle
de.hybris.platform.servicelayer.i18n.impl.CompositeResourceBundle
A
This implementation of a
ResourceBundle which is a composition of two or more decorated bundles. Generally a ResourceBundle
already can manage an internal parent bundle. In that case whenever a PropertyResourceBundle is
created the parent bundle is set according specified language, country etc. However disadvantage is that fallback
options can't be specified and parent bundles can't be set manually.This implementation of a
ResourceBundle allows free choice of parent bundles as well as control over events,
when the fallback bundle shall be used (e.g. when key exists but value is empty).-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.ResourceBundle
ResourceBundle.Control -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intFields inherited from class java.util.ResourceBundle
parent -
Constructor Summary
ConstructorsConstructorDescriptionCompositeResourceBundle(Collection<ResourceBundle> bundles) Constructor.CompositeResourceBundle(Collection<ResourceBundle> bundles, int fallback) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic ResourceBundleSimilar toResourceBundle.getBundle(String, Locale)except that multiple Locales can be given to enable fallback strategies.static ResourceBundlegetBundle(String baseName, Locale[] locales, ClassLoader loader) Similar toResourceBundle.getBundle(String, Locale, ClassLoader)except that multiple Locales can be given to enable fallback strategies.static ResourceBundlegetBundle(Collection<ResourceBundle> bundles) protected Collection<ResourceBundle>getKeys()protected ObjecthandleGetObject(String key) Internal.
Processes fallback strategies.booleanReturns whether key fallback is enabled.booleanReturns whether key fallback is enabled.Methods inherited from class java.util.ResourceBundle
clearCache, clearCache, containsKey, getBaseBundleName, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getLocale, getObject, getString, getStringArray, handleKeySet, keySet, setParent
-
Field Details
-
KEY_FALLBACK
public static final int KEY_FALLBACK- See Also:
-
VALUE_FALLBACK
public static final int VALUE_FALLBACK- See Also:
-
KEY_VALUE_FALLBACK
public static final int KEY_VALUE_FALLBACK- See Also:
-
-
Constructor Details
-
CompositeResourceBundle
Constructor. Creates a composition of bundles and sets a default fallback behavior with KEY_FALLBACK.- Parameters:
bundles- collection ofResourceBundlewhich are used to compose this bundle
-
CompositeResourceBundle
Constructor. Creates a composition of bundles.- Parameters:
bundles- collection ofResourceBundlewhich are used to compose this bundlefallback- fallback options
-
-
Method Details
-
isKeyFallbackEnabled
public boolean isKeyFallbackEnabled()Returns whether key fallback is enabled. When true the next bundle is used in case the requested key doesn't exist.- Returns:
- true when enabled
-
isValueFallbackEnabled
public boolean isValueFallbackEnabled()Returns whether key fallback is enabled. When true the next bundle is used in case a value is empty.- Returns:
- true when enabled
-
getBundlesInternal
- Returns:
- the bundles
-
getKeys
- Specified by:
getKeysin classResourceBundle
-
handleGetObject
Internal.
Processes fallback strategies.- Specified by:
handleGetObjectin classResourceBundle- Parameters:
key- ressourcebundle key
-
getBundle
Similar toResourceBundle.getBundle(String, Locale)except that multiple Locales can be given to enable fallback strategies.- Parameters:
baseName-locales-- Returns:
ResourceBundle
-
getBundle
Similar toResourceBundle.getBundle(String, Locale, ClassLoader)except that multiple Locales can be given to enable fallback strategies.- Parameters:
baseName-locales-loader-
-
getBundle
- Parameters:
bundles- the collection of bundles. Fallback strategies are provided via order of these resource bundles.- Returns:
ResourceBundle
-