java.lang.Object
i2p.susi.util.Config
Static configuration manager. Warning: Not suitable for multiple applications or prefixes.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static PropertiesValues the user has set.private static StringPrefix naming this component's properties.private static PropertiesDefaults shipped with the webmail.Constructor Summary
ConstructorsMethod Summary
All MethodsModifier and TypeMethodDescriptionstatic PropertiesReturns the properties, sorted, WITHOUT the prefix.static StringgetProperty(String name) Get a property by name, checking system properties first, then the config file, then the default properties.static intgetProperty(String name, int defaultValue) Get a property as an integer with a default value.static StringgetProperty(String name, String defaultValue) Get a property by name with a default value.static booleanDon't bother showing a reload config button if this returns false.static voidReload the configuration from the properties resource and the susimail.config file in the config directory.static voidsaveConfiguration(Properties newProps) Saves the properties.static voidSet the configuration key prefix.
Field Details
properties
Defaults shipped with the webmail.config
Values the user has set.configPrefix
Prefix naming this component's properties.
Constructor Details
Config
public Config()Creates an empty config.
Method Details
getProperty
hasConfigFile
public static boolean hasConfigFile()Don't bother showing a reload config button if this returns false.- Returns:
- true if the config file exists
reloadConfiguration
public static void reloadConfiguration()Reload the configuration from the properties resource and the susimail.config file in the config directory.getProperties
Returns the properties, sorted, WITHOUT the prefix.- Returns:
- the sorted properties, with the config prefix stripped
saveConfiguration
Saves the properties. A property not in newProps will be removed but will not override the default in the resource.- Parameters:
newProps- non-null WITHOUT the prefix- Throws:
IOException- if the save fails
getProperty
getProperty
Get a property as an integer with a default value.- Parameters:
name- the property namedefaultValue- the value to return if the property is not found or not a valid integer- Returns:
- the property value as an integer, or defaultValue
setPrefix
Set the configuration key prefix. All property lookups will be prefixed with this string followed by a dot (if not already present). Static! Not for use by multiple applications!- Parameters:
prefix- the prefix to prepend to property names