public class MultiPropertyResourceBundle
extends java.util.ResourceBundle
ResourceBundle
with 2 new capabilities. The first is to store the path where the properties file used to create the
InputStream
is located and the second is to allow additional ResourceBundle
properties to be merged into an instance.
To allow a SystemOfUnits
to locate and merge extension module properties files.
Modifier and Type | Field and Description |
---|---|
private java.lang.StringBuilder |
mergedBundlePaths
A
StringBuilder instance containing all the paths of the ResourceBundle instances that have been merged into this instance. |
private java.lang.String |
resourcePath
The location of the properties file that was used to instantiate the
MultiPropertyResourceBundle instance. |
private java.util.Map<java.lang.String,java.lang.Object> |
resources
A
Map containing all the properties that have been merged from multiple ResourceBundle instances. |
Constructor and Description |
---|
MultiPropertyResourceBundle(java.io.InputStream stream,
java.lang.String resourcePath)
Instantiates a new
MultiPropertyResourceBundle . |
MultiPropertyResourceBundle(java.util.ResourceBundle baseBundle,
java.lang.String resourcePath)
Constructor for instantiating from an existing
ResourceBundle . |
Modifier and Type | Method and Description |
---|---|
boolean |
containsKey(java.lang.String key)
Overrides the super class implementation to check the existence of a key across all merged bundles
|
java.util.Enumeration<java.lang.String> |
getKeys()
Overrides the super class implementation to return an enumeration of keys from all the merged bundles
|
java.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 bundles
|
protected java.util.Set<java.lang.String> |
handleKeySet()
Overrides the super class implementation to return the
Set of keys from all merged bundles |
java.util.Set<java.lang.String> |
keySet()
Overrides the super class implementation to return the
Set of keys from all merged bundles |
void |
merge(java.util.ResourceBundle resourceBundle,
java.lang.String resourcePath)
Merges the properties of a
ResourceBundle into the current MultiPropertyResourceBundle instance. |
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.
private final java.util.Map<java.lang.String,java.lang.Object> resources
A Map
containing all the properties that have been merged from multiple ResourceBundle
instances.
private final java.lang.StringBuilder mergedBundlePaths
A StringBuilder
instance containing all the paths of the ResourceBundle
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 the AbstractWebScript
class.
public MultiPropertyResourceBundle(java.io.InputStream stream, java.lang.String resourcePath) throws java.io.IOException
Instantiates a new MultiPropertyResourceBundle
.
stream
- The InputStream
passed on to the super class constructor.resourcePath
- The location of the properties file used to create the InputStream
java.io.IOException
public MultiPropertyResourceBundle(java.util.ResourceBundle baseBundle, java.lang.String resourcePath)
Constructor for instantiating from an existing ResourceBundle
. This calls the merge
method to copy the properties from the
bundle into the resources
map.
baseBundle
- resourcePath
- public java.lang.String getResourcePath()
MultiPropertyResourceBundle
instance.public java.lang.StringBuilder getMergedBundlePaths()
StringBuilder
instance containing the paths of all the ResourceBundle
instances that have been merged into
this instance.public void merge(java.util.ResourceBundle resourceBundle, java.lang.String resourcePath)
Merges the properties of a ResourceBundle
into the current MultiPropertyResourceBundle
instance. This will override any
values mapped to duplicate keys in the current merged properties.
resourceBundle
- The ResourceBundle
to merge the properties of.resourcePath
- public java.lang.Object handleGetObject(java.lang.String key)
Overrides the super class implementation to return an object located in the merged bundles
handleGetObject
in class java.util.ResourceBundle
Object
from the merged bundlespublic java.util.Enumeration<java.lang.String> getKeys()
Overrides the super class implementation to return an enumeration of keys from all the merged bundles
getKeys
in class java.util.ResourceBundle
Enumeration
of the keys across all the merged bundles.protected java.util.Set<java.lang.String> handleKeySet()
Overrides the super class implementation to return the Set
of keys from all merged bundles
handleKeySet
in class java.util.ResourceBundle
Set
of keys obtained from all merged bundlespublic boolean containsKey(java.lang.String key)
Overrides the super class implementation to check the existence of a key across all merged bundles
containsKey
in class java.util.ResourceBundle
true
if the key is present and false
otherwise.public java.util.Set<java.lang.String> keySet()
Overrides the super class implementation to return the Set
of keys from all merged bundles
keySet
in class java.util.ResourceBundle
Set
of keys obtained from all merged bundles