public class SparkseeProperties
extends java.lang.Object
This class is implemented as a singleton, so all public methods are static.
It allows for getting the property values stored in a properties file. A properties file is a file where there is one line per property. A property is defined by a key and a value as follows: key=value
By default, this loads properties from the file './sparksee.cfg'. The user may choose to load a different file by calling the method Load().
If the default properties file or the one loaded by the user do not exist, then this behaves as loading an empty properties file.
Modifier and Type | Method and Description |
---|---|
static void |
clear()
Remove all the properties.
|
static java.lang.String |
get(java.lang.String key,
java.lang.String def)
Gets a property.
|
static boolean |
getBoolean(java.lang.String key,
boolean def)
Gets a property as a boolean.
|
static int |
getInteger(java.lang.String key,
int def)
Gets a property as an integer.
|
static long |
getTimeUnit(java.lang.String key,
long def)
Gets a property as a time unit.
|
static void |
load(java.lang.String path)
Loads properties from the given file path.
|
static void |
setHI(java.lang.String value)
YOU SHOULD NOT USE THIS METHOD.
|
public static void clear()
public static java.lang.String get(java.lang.String key, java.lang.String def)
key
- [in] The name of the property to lookup.def
- [in] Default value to be returned in case there is no property with the name key.public static int getInteger(java.lang.String key, int def)
key
- [in] The name of the property to lookup.def
- [in] Default value to be returned in case there is no property with the name key.public static void setHI(java.lang.String value)
This method exists only for a specific service.
value
- nullpublic static void load(java.lang.String path)
path
- [in] File path to load properties from.public static long getTimeUnit(java.lang.String key, long def)
A time unit is a string representation of a time duration with a time unit such as '10s' or '3H'.
Valid format for the string representation: Blanks at the begining or at the end are ignored. No blanks are allowed between the time duration and the unit time.
Allowed time units: 'D' for days, 'H' for hours, 'M' for minutes, 'S' o 's' for seconds, 'm' for milliseconds and 'u' for microseconds.
There is a special case: If no time unit is given, seconds is the default. So, '10' means 10 seconds.
key
- [in] The name of the property to lookup.def
- [in] The default value (in microseconds) to be returned in case there is no property with the name key.public static boolean getBoolean(java.lang.String key, boolean def)
key
- [in] The name of the property to lookup.def
- [in] Default value to be returned in case there is no property with the name key.