Class SettingBundle
- All Implemented Interfaces:
SilverpeasBundle
It uses a java.util.ResourceBundle behind the scene to access the settings defined under
a fully qualified name (the resource bundle base name), so the lifecycle of the bundle is then
managed by the java.util.ResourceBundle implementation (with expiration time, cache
handling, ...). The java.util.ResourceBundle is loaded on demand, when a property is
asked. So, by default, if no such bundle exists or if the property isn't defined in the bundle
then a java.util.MissingResourceException exception is thrown. In the case a default
value is specified (whatever its value), no java.util.MissingResourceException
exception is thrown when the property doesn't exist.
- Author:
- mmoquillon
- See Also:
- API Note:
- A general resource bundle is expected at
GENERAL_BUNDLE_NAME
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe Silverpeas settings bundle for general configuration properties. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSettingBundle(String name, Function<String, ResourceBundle> loader) -
Method Summary
Modifier and TypeMethodDescriptionGets this setting bundle as a simplyPropertiesinstance.Gets this setting bundle as a simplyResourceBundleinstance.booleancontainsKey(String key) Is this bundle contains the specified databooleanexists()Is this bundle exists?What is the fully qualified name of this bundle.booleangetBoolean(String key) booleangetBoolean(String key, boolean defaultValue) floatfloatintgetInteger(String key) intgetInteger(String key, int defaultValue) String[]Gets the value as an array of String instances of the data identified by the specified key.String[]Gets the value as an array of String instances of the data identified by the specified key.String[]Gets the value as an array of String instances of the data identified by the specified key.String[]Gets the value as an array of String instances of the data identified by the specified key.longlongIf you expect the data can be not defined in this bundle, then useorg.silverpeas.core.util.SettingBundle#getStringmethod instead of this.Gets the value as a String of the data identified by the specified key.keySet()Gets a set of all keys defined in this bundle.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.silverpeas.kernel.bundle.SilverpeasBundle
getStringList, getStringList
-
Field Details
-
GENERAL_BUNDLE_NAME
The Silverpeas settings bundle for general configuration properties. It is both the default and base bundle that has to be provided and available for Silverpeas.- See Also:
-
-
Constructor Details
-
SettingBundle
-
-
Method Details
-
exists
public boolean exists()Is this bundle exists?- Specified by:
existsin interfaceSilverpeasBundle- Returns:
- true if this bundle exists, false otherwise.
-
keySet
Description copied from interface:SilverpeasBundleGets a set of all keys defined in this bundle.- Specified by:
keySetin interfaceSilverpeasBundle- Returns:
- a set of keys.
-
containsKey
Description copied from interface:SilverpeasBundleIs this bundle contains the specified data- Specified by:
containsKeyin interfaceSilverpeasBundle- Parameters:
key- the name of the data.- Returns:
- true if this bundle has a data with the specified key, false otherwise.
-
getBaseBundleName
Description copied from interface:SilverpeasBundleWhat is the fully qualified name of this bundle.- Specified by:
getBaseBundleNamein interfaceSilverpeasBundle- Returns:
- the base bundle name (that is to say without the hierarchy path name that is handled
by
org.silverpeas.core.util.ResourceLocator).
-
getString
If you expect the data can be not defined in this bundle, then useorg.silverpeas.core.util.SettingBundle#getStringmethod instead of this.- Specified by:
getStringin interfaceSilverpeasBundle- Parameters:
key- the unique name of the data in this bundle.- Returns:
- the value of the data as a string of characters.
- See Also:
-
getString
Gets the value as a String of the data identified by the specified key. If the data isn't valued or if it doesn't exist, then the default value is returned.If you expect the data can be not defined in this bundle, then use this method instead of
org.silverpeas.core.util.SettingBundle#getStringmethod and use the default value to test afterward the data is or not defined.- Parameters:
key- the unique name of the data in this bundle.defaultValue- the default value to use if the setting isn't valued or if it isn't defined in the bundle.- Returns:
- the value of the data as a string of characters.
- Throws:
MissingResourceException- if the bundle doesn't exist.
-
getList
Gets the value as an array of String instances of the data identified by the specified key. The value of the property in the bundle is considered to be a text encoding a list of comma-separated items. These items will be the elements of the returned array. Any blank items are skipped.- Parameters:
key- the unique name of the data in this bundle.- Returns:
- an array with the items of the list that values the given property key.
-
getList
Gets the value as an array of String instances of the data identified by the specified key. The value of the property in the bundle is considered to be a text encoding a list of items separated from each other by the given separator. These items will be the elements of the returned array. Any blank items are skipped.- Parameters:
key- the unique name of the data in this bundle.separator- the separator used to separate each item of property value.- Returns:
- an array with the items of the list that values the given property key.
-
getList
Gets the value as an array of String instances of the data identified by the specified key. The value of the property in the bundle is considered to be a text encoding a list of comma-separated items. These items will be the elements of the returned array. Any blank items are skipped.If you expect the data can be not defined in this bundle, then use this method instead of
org.silverpeas.core.util.SettingBundle#getListmethod and use the default value to test afterward the data is or not defined.- Parameters:
key- the unique name of the data in this bundle.defaultValue- the default value to use if the setting isn't valued or if it isn't defined in the bundle.- Returns:
- an array with the items of the list that values the given property key.
-
getList
Gets the value as an array of String instances of the data identified by the specified key. The value of the property in the bundle is considered to be a text encoding a list of items separated from each other by the given separator. These items will be the elements of the returned array. Any blank items are skipped.If you expect the data can be not defined in this bundle, then use this method instead of
org.silverpeas.core.util.SettingBundle#getListmethod and use the default value to test afterward the data is or not defined.- Parameters:
key- the unique name of the data in this bundle.defaultValue- the default value to use if the setting isn't valued or if it isn't defined in the bundle.separator- the separator used to separate each item of property value.- Returns:
- an array with the items of the list that values the given property key.
-
getBoolean
-
getBoolean
-
getLong
-
getLong
-
getFloat
-
getFloat
-
getInteger
-
getInteger
-
asResourceBundle
Gets this setting bundle as a simplyResourceBundleinstance. This can be useful when aResourceBundleis expected in some codes.- Returns:
- a
ResourceBundlerepresentation of this setting bundle.
-
asProperties
Gets this setting bundle as a simplyPropertiesinstance. This can be useful when aPropertiesis expected in some codes.- Returns:
- a
Propertiesrepresentation of this setting bundle.
-