|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.openbp.common.setting.SettingUtil
public final class SettingUtil
The setting util class provides utility methods for access to setting using the SettingResolver mechanism.
It also keeps a standard setting resolver.
Note that the application is resonsible for setting up the standard resolver!
Setting values may be strings, booleans and integers.
Settings can be retrieved using one of the methods
getStringSetting(String)
getBooleanSetting(String, boolean)
getIntSetting(String, int)
In order to store a setting value, call
setStringSetting(String, String)
setBooleanSetting(String, boolean)
setIntSetting(String, int)
For each method, there is a version that allows to specify the setting resolver and a version that
delegates to the standard resolver.
Some setting providers may save the settings automatically if one of the set methods is called,
whereas others may cache the settings and save them to the persistent storage after the
saveSettings() method has been called.
| Field Summary | |
|---|---|
static char |
PROVIDER_SEPARATOR
Provider separator |
| Method Summary | |
|---|---|
static java.util.Properties |
expandProperties(java.util.Properties props)
Performs expandVariables on all values of the given properties. |
static java.lang.String |
expandVariables(java.lang.String s,
boolean mandatory)
Substitutes variables in the given string using the standard setting resolver. |
static java.lang.String |
expandVariables(java.lang.String s,
boolean mandatory,
SettingResolver resolver)
Substitutes variables in the given string using the supplied setting resolver. |
static boolean |
getBooleanSetting(java.lang.String name,
boolean dflt)
Gets a boolean setting value or the default using the standard setting resolver. |
static boolean |
getBooleanSetting(java.lang.String name,
boolean dflt,
SettingResolver resolver)
Gets a boolean setting value or the default using the supplied setting resolver. |
static int |
getIntSetting(java.lang.String name,
int dflt)
Gets an integer setting value or the default using the standard setting resolver. |
static int |
getIntSetting(java.lang.String name,
int dflt,
SettingResolver resolver)
Gets an integer setting value or the default using the supplied setting resolver. |
static boolean |
getMandatoryBooleanSetting(java.lang.String name)
Gets a mandatory boolean setting value or the default using the standard setting resolver. |
static int |
getMandatoryIntSetting(java.lang.String name)
Gets a mandatory integer setting value or the default using the standard setting resolver. |
static java.lang.String |
getMandatoryStringSetting(java.lang.String name)
Gets a mandatory string setting value using the standard setting resolver. |
static SettingResolver |
getStandardResolver()
Gets the standard resolver. |
static java.lang.String |
getStringSetting(java.lang.String name)
Gets a string setting value using the standard setting resolver. |
static java.lang.String |
getStringSetting(java.lang.String name,
java.lang.String dflt)
Gets a string setting value or the default using the standard setting resolver. |
static java.lang.String |
getStringSetting(java.lang.String name,
java.lang.String dflt,
SettingResolver resolver)
Gets a string setting value or the default using the supplied setting resolver. |
static java.util.Properties |
overwriteProperties(java.util.Properties props)
Performs a overwrite support for all properties keys of the given properties. |
static boolean |
saveSettings()
Saves the current setting values of the setting provider of the standard setting resolver. |
static boolean |
saveSettings(SettingResolver resolver)
Saves the current setting values of the setting provider of the specified setting resolver. |
static SettingProvider |
setBooleanSetting(java.lang.String name,
boolean value)
Sets a boolean setting value using the standard setting resolver. |
static SettingProvider |
setBooleanSetting(java.lang.String name,
boolean value,
SettingResolver resolver)
Sets a boolean setting value using the supplied setting resolver. |
static SettingProvider |
setIntSetting(java.lang.String name,
int value)
Sets an integer setting value using the standard setting resolver. |
static SettingProvider |
setIntSetting(java.lang.String name,
int value,
SettingResolver resolver)
Sets an integer setting value using the supplied setting resolver. |
static void |
setStandardResolver(SettingResolver standardResolverArg)
Sets the standard resolver. |
static SettingProvider |
setStringSetting(java.lang.String name,
java.lang.String value)
Sets a string setting value using the standard setting resolver. |
static SettingProvider |
setStringSetting(java.lang.String name,
java.lang.String value,
SettingResolver resolver)
Sets a string setting value using the supplied setting resolver. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final char PROVIDER_SEPARATOR
| Method Detail |
|---|
public static SettingResolver getStandardResolver()
public static void setStandardResolver(SettingResolver standardResolverArg)
public static java.lang.String getStringSetting(java.lang.String name,
java.lang.String dflt,
SettingResolver resolver)
name - Name of the settingdflt - Default value of the settingresolver - Resolver to use
public static boolean getBooleanSetting(java.lang.String name,
boolean dflt,
SettingResolver resolver)
name - Name of the settingdflt - Default value of the settingresolver - Resolver to use
public static SettingProvider setStringSetting(java.lang.String name,
java.lang.String value,
SettingResolver resolver)
name - Name of the settingvalue - value of the settingresolver - Resolver to use
public static int getIntSetting(java.lang.String name,
int dflt,
SettingResolver resolver)
name - Name of the settingdflt - Default value of the settingresolver - Resolver to use
public static SettingProvider setBooleanSetting(java.lang.String name,
boolean value,
SettingResolver resolver)
name - Name of the settingvalue - value of the settingresolver - Resolver to use
public static SettingProvider setIntSetting(java.lang.String name,
int value,
SettingResolver resolver)
name - Name of the settingvalue - value of the settingresolver - Resolver to use
public static java.lang.String expandVariables(java.lang.String s,
boolean mandatory,
SettingResolver resolver)
s - String to processmandatory - true If an unknown variable should result in an exception.resolver - Resolver to use
java.lang.RuntimeException - On an unknown mandatory variablepublic static boolean saveSettings(SettingResolver resolver)
resolver - Resolver to use
public static java.util.Properties expandProperties(java.util.Properties props)
props - Props to check
public static java.util.Properties overwriteProperties(java.util.Properties props)
props - Props to check
public static java.lang.String getStringSetting(java.lang.String name)
name - Name of the setting
public static java.lang.String getStringSetting(java.lang.String name,
java.lang.String dflt)
name - Name of the settingdflt - Default value of the setting
public static boolean getBooleanSetting(java.lang.String name,
boolean dflt)
name - Name of the settingdflt - Default value of the setting
public static SettingProvider setStringSetting(java.lang.String name,
java.lang.String value)
name - Name of the settingvalue - value of the setting
public static int getIntSetting(java.lang.String name,
int dflt)
name - Name of the settingdflt - Default value of the setting
public static SettingProvider setBooleanSetting(java.lang.String name,
boolean value)
name - Name of the settingvalue - value of the setting
public static SettingProvider setIntSetting(java.lang.String name,
int value)
name - Name of the settingvalue - value of the setting
public static java.lang.String getMandatoryStringSetting(java.lang.String name)
name - Name of the setting
java.lang.RuntimeException - If the setting is not presentpublic static boolean getMandatoryBooleanSetting(java.lang.String name)
name - Name of the setting
java.lang.RuntimeException - If the setting is not presentpublic static int getMandatoryIntSetting(java.lang.String name)
name - Name of the setting
java.lang.RuntimeException - If the setting is not present
public static java.lang.String expandVariables(java.lang.String s,
boolean mandatory)
s - String to processmandatory - true If an unknown variable should result in an exception.NestedRuntimeException - On an unknown mandatory variablepublic static boolean saveSettings()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||