Class MultiPropertyResourceBundle
- java.lang.Object
-
- java.util.ResourceBundle
-
- tech.units.indriya.internal.format.l10n.MultiPropertyResourceBundle
-
public class MultiPropertyResourceBundle extends java.util.ResourceBundle
ExtendsResourceBundle
with 2 new capabilities. The first is to store the path where the properties file used to create theInputStream
is located and the second is to allow additionalResourceBundle
properties to be merged into an instance.To allow a
SystemOfUnits
to locate and merge extension module properties files.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringBuilder
mergedBundlePaths
AStringBuilder
instance containing all the paths of theResourceBundle
instances that have been merged into this instance.private java.lang.String
resourcePath
The location of the properties file that was used to instantiate theMultiPropertyResourceBundle
instance.private java.util.Map<java.lang.String,java.lang.Object>
resources
AMap
containing all the properties that have been merged from multipleResourceBundle
instances.
-
Constructor Summary
Constructors Constructor Description MultiPropertyResourceBundle(java.io.InputStream stream, java.lang.String resourcePath)
Instantiates a newMultiPropertyResourceBundle
.MultiPropertyResourceBundle(java.util.ResourceBundle baseBundle, java.lang.String resourcePath)
Constructor for instantiating from an existingResourceBundle
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsKey(java.lang.String key)
Overrides the super class implementation to check the existence of a key across all merged bundlesjava.util.Enumeration<java.lang.String>
getKeys()
Overrides the super class implementation to return an enumeration of keys from all the merged bundlesjava.lang.StringBuilder
getMergedBundlePaths()
java.lang.String
getResourcePath()
java.lang.Object
handleGetObject(java.lang.String key)
Overrides the super class implementation to return an object located in the merged bundlesprotected java.util.Set<java.lang.String>
handleKeySet()
Overrides the super class implementation to return theSet
of keys from all merged bundlesjava.util.Set<java.lang.String>
keySet()
Overrides the super class implementation to return theSet
of keys from all merged bundlesvoid
merge(java.util.ResourceBundle resourceBundle, java.lang.String resourcePath)
Merges the properties of aResourceBundle
into the currentMultiPropertyResourceBundle
instance.
-
-
-
Field Detail
-
resourcePath
private java.lang.String resourcePath
The location of the properties file that was used to instantiate the
MultiPropertyResourceBundle
instance. This field is set by the constructor.
-
resources
private final java.util.Map<java.lang.String,java.lang.Object> resources
A
Map
containing all the properties that have been merged from multipleResourceBundle
instances.
-
mergedBundlePaths
private final java.lang.StringBuilder mergedBundlePaths
A
StringBuilder
instance containing all the paths of theResourceBundle
instances that have been merged into this instance. This value is intended to be use to help generate a key for caching JSON formatted resource output in theAbstractWebScript
class.
-
-
Constructor Detail
-
MultiPropertyResourceBundle
public MultiPropertyResourceBundle(java.io.InputStream stream, java.lang.String resourcePath) throws java.io.IOException
Instantiates a new
MultiPropertyResourceBundle
.- Parameters:
stream
- TheInputStream
passed on to the super class constructor.resourcePath
- The location of the properties file used to create theInputStream
- Throws:
java.io.IOException
-
MultiPropertyResourceBundle
public MultiPropertyResourceBundle(java.util.ResourceBundle baseBundle, java.lang.String resourcePath)
Constructor for instantiating from an existing
ResourceBundle
. This calls themerge
method to copy the properties from the bundle into theresources
map.- Parameters:
baseBundle
-resourcePath
-
-
-
Method Detail
-
getResourcePath
public java.lang.String getResourcePath()
- Returns:
- The location of the properties file that was used to instantiate the
MultiPropertyResourceBundle
instance.
-
getMergedBundlePaths
public java.lang.StringBuilder getMergedBundlePaths()
- Returns:
- Returns the
StringBuilder
instance containing the paths of all theResourceBundle
instances that have been merged into this instance.
-
merge
public void merge(java.util.ResourceBundle resourceBundle, java.lang.String resourcePath)
Merges the properties of a
ResourceBundle
into the currentMultiPropertyResourceBundle
instance. This will override any values mapped to duplicate keys in the current merged properties.- Parameters:
resourceBundle
- TheResourceBundle
to merge the properties of.resourcePath
-
-
handleGetObject
public java.lang.Object handleGetObject(java.lang.String key)
Overrides the super class implementation to return an object located in the merged bundles
- Specified by:
handleGetObject
in classjava.util.ResourceBundle
- Returns:
- An
Object
from the merged bundles
-
getKeys
public java.util.Enumeration<java.lang.String> getKeys()
Overrides the super class implementation to return an enumeration of keys from all the merged bundles
- Specified by:
getKeys
in classjava.util.ResourceBundle
- Returns:
- An
Enumeration
of the keys across all the merged bundles.
-
handleKeySet
protected java.util.Set<java.lang.String> handleKeySet()
Overrides the super class implementation to return the
Set
of keys from all merged bundles- Overrides:
handleKeySet
in classjava.util.ResourceBundle
- Returns:
- A
Set
of keys obtained from all merged bundles
-
containsKey
public boolean containsKey(java.lang.String key)
Overrides the super class implementation to check the existence of a key across all merged bundles
- Overrides:
containsKey
in classjava.util.ResourceBundle
- Returns:
true
if the key is present andfalse
otherwise.
-
keySet
public java.util.Set<java.lang.String> keySet()
Overrides the super class implementation to return the
Set
of keys from all merged bundles- Overrides:
keySet
in classjava.util.ResourceBundle
- Returns:
- A
Set
of keys obtained from all merged bundles
-
-