Package org.silverpeas.core.util
Interface SilverpeasBundle
-
- All Known Implementing Classes:
LocalizationBundle
,SettingBundle
,XmlSettingBundle
,XmlSettingBundle.SettingSection
public interface SilverpeasBundle
A Silverpeas bundle represents a bundle containing data required by the different features of Silverpeas. Each data is defined by a pair of key-value.- Author:
- miguel
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
containsKey(String key)
Is this bundle contains the specified databoolean
exists()
Is this bundle exists?String
getBaseBundleName()
What is the fully qualified name of this bundle.String
getString(String key)
Gets the value as a String of the data identified by the specified key.default SilverpeasBundleList
getStringList(String list, String property)
The resource is a list of objects.default SilverpeasBundleList
getStringList(String list, String property, int max)
The resource is a list of objects.Set<String>
keySet()
Gets a set of all keys defined in this bundle.
-
-
-
Method Detail
-
containsKey
boolean containsKey(String key)
Is this bundle contains the specified data- Parameters:
key
- the name of the data.- Returns:
- true if this bundle has a data with the specified key, false otherwise.
-
getBaseBundleName
String getBaseBundleName()
What is the fully qualified name of this bundle.- Returns:
- the base bundle name (that is to say without the hierarchy path name that is handled
by
org.silverpeas.core.util.ResourceLocator
).
-
getString
String getString(String key)
Gets the value as a String of the data identified by the specified key. The key should exist in the bundle otherwise ajava.util.MissingResourceException
exception is thrown.- Parameters:
key
- the unique name of the data in this bundle.- Returns:
- the value of the data as a string of characters.
- Throws:
MissingResourceException
- if either the bundle doesn't exist or the key isn't defined in the bundle.
-
getStringList
default SilverpeasBundleList getStringList(String list, String property) throws MissingResourceException
The resource is a list of objects. Gets the value(s) of the specified property of one or more objects in the list. The objects in the list are identified by their index in the list (from 1 to n). The key used to find the asked value(s) is composed first by the list identifier, an underscore separator, then by the index of the object in the list, a dot separator, and finally ends with the object's property name.
For example :User_1.Name=firstName
User_2.Name=lastName
- ...
MissingResourceException
exception is thrown (for compatibility reason with Silverpeas versions lesser than 6).- Parameters:
list
- the identifier of the list in the bundle.property
- the object's property for which the value will be fetch. iterated up to find an object whose the property is set. If max is >= 1 then the specified property of the first max objects are read (if the property isn't set for an object, it is set to an empty string).- Returns:
- an array of string with several values. If the property of an object to read exists but isn't set, then an empty string is set in the array.
- Throws:
MissingResourceException
- if the bundle doesn't exist.
-
getStringList
default SilverpeasBundleList getStringList(String list, String property, int max) throws MissingResourceException
The resource is a list of objects. Gets the value(s) of the specified property of one or more objects in the list. The objects in the list are identified by their index in the list (from 1 to n). The key used to find the asked value(s) is composed first by the list identifier, an underscore separator, then by the index of the object in the list, a dot separator, and finally ends with the object's property name.
For example :User_1.Name=firstName
User_2.Name=lastName
- ...
MissingResourceException
exception is thrown (for compatibility reason with Silverpeas versions lesser than 6).- Parameters:
list
- the identifier of the list in the bundle.property
- the object's property for which the value will be fetch.max
- the maximum number of objects to read from 1 to n. If max is -1 then the list is iterated up to find an object whose the property is set. If max is >= 1 then the specified property of the first max objects are read (if the property isn't set for an object, it is set to an empty string).- Returns:
- an array of string with one property value (if max is 1) or with several values (if max = -1 or > 1). If the property of an object to read exists but isn't set, then an empty string is set in the array.
- Throws:
MissingResourceException
- if the bundle doesn't exist.
-
exists
boolean exists()
Is this bundle exists?- Returns:
- true if this bundle exists, false otherwise.
-
-