|
Rule Execution Server API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ilog.rules.util.prefs.IlrPropertyManager
public abstract class IlrPropertyManager
A manager of property files.
A IlrPropertyManager
manages a
hierarchy of IlrPropertyBundle
. Each property
bundle corresponds to a directory and a set of files under this directory.
Each file is structured as a list of key=value
couples.
The name of the files is given by the pattern:
<slashedPrefix>/<slashedFullname>/<baseClassname>_<suffix>.properties
.
<slashedPrefix>
is one of the prefix returned by the
getPrefixes()
method but with the "." character replaced by the
"/" character. The two default prefixes are
"ilog.rules"
and ""
.<slashedFullname>
is the fully qualified name of the property bundle
with the "/" character used as name separator.
For instance, if a property bundle "b2" has for parent the property bundle
"b1" and if "b1" has for parent the root bundle called "", then the full
name of "b2" will be "b1.b2". "b1" will b<baseClassname>
is specific of the property manager instances and
is given by getBaseClassName()
method. The base class name of the
messages manager is "messages" while the base class name of the preferences
manager is "preferences".<suffix>
is one
of the suffix returned by the getSuffixes()
method.
The default only suffix is "".
A property bundle loads the property files using the
java.util.property.getBundle(String, Locale, ClassLoader)
method in the order given by the double sorting criteria: suffixes order + prefix order.
The content of each file is
added to a common table. The properties of a file loaded later replace the
same properties of a file loaded earlier.
For instance, if we set the prefixes and the suffixes of a property manager to
{"ilog.rules", "appli", ""}
and {"", "dev"}
respectively,
the loading of the
b1.b2
preferences bundle will load the associated files in the following order:
ilog/rules/b1/b2/preferences.properties
appli/b1/b2/preferences.properties
b1/b2/preferences.properties
ilog/rules/b1/b2/preferences_dev.properties
appli/b1/b2/preferences_dev.properties
b1/b2/preferences_dev.properties
When there is more than one suffix, a file with the first suffix must be found before carrying on with the other suffixes.
Once loaded, the property bundle contains a set of key and their associated value. A property key is composed of a list of name separated by the "." character. To retrieve the value associated to a key, the property manager queries the property bundles starting from the root bundle and following the path given by the name list of the key. For instance, if the key is "b1.b2.key", the search will be:
The search stops as soon as the key is found. By default, the depth of the search is limited to the bundles of depth 2.
The modification of the property manager properties (prefixes, suffixes,
class loader, locale, maximum search depth
) will reset the property manager:
the cache will be cleared and the property bundles will be reloaded on demand.
Constructor Summary | |
---|---|
protected |
IlrPropertyManager()
Sole constructor |
Method Summary | |
---|---|
void |
addPrefix(String prefix)
Add the specified prefix at the end of the prefix list. |
void |
addSuffix(String suffix)
Add the specified suffix at the end of the prefix list. |
IlrPropertyBundle |
findPropertyBundle(String key)
Return the property bundle that contains the key name . |
IlrPropertyBundle |
findPropertyBundle(String key,
Locale locale)
Return the property bundle that contains the key name . |
protected abstract String |
getBaseClassName()
Returns the resource bundle base class name. |
ClassLoader |
getClassLoader()
Returns the class loader used to load the java.util.ResourceBundle instances |
Locale |
getLocale()
Returns the locale used to load the java.util.ResourceBundle instances |
int |
getMaximumDepth()
Returns the maximum key search depth. |
String[] |
getPrefixes()
Returns an array containing all the prefixes in their order of use. |
IlrPropertyBundle |
getPropertyBundle(String bundleName)
Returns the property bundle named name . |
IlrPropertyBundle |
getPropertyBundle(String bundleName,
Locale locale)
Returns the property bundle named name . |
String[] |
getSuffixes()
Returns an array containing all the suffixes in their order of use. |
String |
getValue(String key)
Return the String associated to the key key
or nullValue if the key is not found |
String |
getValue(String key,
Locale locale)
Return the String associated to the key key
or nullValue if the key is not found |
String |
getValue(String key,
String defaultValue)
Return the String associated to the key key
or defaultValue if the key is not found |
String |
getValue(String key,
String defaultValue,
Locale locale)
Return the String associated to the key key
or defaultValue if the key is not found |
void |
insertPrefixAt(String prefix,
int index)
Insert the specified prefix to the specified position. |
void |
insertSuffixAt(String suffix,
int index)
Insert the specified suffix to the specified position. |
void |
removePrefixAt(int index)
Remove the prefix at the specified position in the prefix list. |
void |
removeSuffixAt(int index)
Remove the suffix at the specified position in the suffix list. |
void |
setClassLoader(ClassLoader cl)
Sets the class loader to load the java.util.ResourceBundle instances. |
void |
setLocale(Locale locale)
Sets the locale to use to load the ResourceBundle . |
void |
setMaximumDepth(int maxDepth)
Sets the maximum key search depth. |
void |
setPrefixes(String[] prefixes)
Set the prefixes to use. |
void |
setSuffixes(String[] suffixes)
Set the suffixes to use. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected IlrPropertyManager()
Method Detail |
---|
public String[] getPrefixes()
public void setPrefixes(String[] prefixes)
prefixes
- An sorted array containing the prefixes to use.public void insertPrefixAt(String prefix, int index)
prefix
- Prefix to be inserted.index
- Index at which the specified prefix is to be inserted.public void addPrefix(String prefix)
prefix
- Prefix to be added.public void removePrefixAt(int index)
index
- The index of the prefix to be removed.public String[] getSuffixes()
public void setSuffixes(String[] suffixes)
suffixes
- An sorted array containing the suffixes to use.public void insertSuffixAt(String suffix, int index)
suffix
- Suffix to be inserted.index
- Index at which the specified suffix is to be inserted.public void addSuffix(String suffix)
suffix
- Suffix to be added.public void removeSuffixAt(int index)
index
- The index of the suffix to be removed.public int getMaximumDepth()
public void setMaximumDepth(int maxDepth)
maxDepth
- The maximum depth to set.public Locale getLocale()
public void setLocale(Locale locale)
ResourceBundle
.
locale
- The new locale.protected abstract String getBaseClassName()
public ClassLoader getClassLoader()
public void setClassLoader(ClassLoader cl)
java.util.ResourceBundle
instances.
cl
- The new class loader.public IlrPropertyBundle getPropertyBundle(String bundleName)
name
.
public IlrPropertyBundle getPropertyBundle(String bundleName, Locale locale)
name
.
public IlrPropertyBundle findPropertyBundle(String key)
name
.
public IlrPropertyBundle findPropertyBundle(String key, Locale locale)
name
.
public String getValue(String key, String defaultValue)
key
or defaultValue
if the key is not found
public String getValue(String key, String defaultValue, Locale locale)
key
or defaultValue
if the key is not found
public String getValue(String key)
key
or nullValue
if the key is not found
public String getValue(String key, Locale locale)
key
or nullValue
if the key is not found
|
Rule Execution Server API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |