public final class MainConfig
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.util.Properties |
configFileProperties
The local object which represents the main properties file as
Properties . |
private static SimpleXMLConfigFile |
configFileXML
The local object which represents the main xml configuration file as
SimpleXMLConfigFile . |
private static java.lang.String |
SYSTEM_CONF_PATH_PROPERTIES
The path to to main properties file (These properties will be editable by the user interface).
|
private static java.lang.String |
SYSTEM_CONFIG_PATH
The path to to main configuration xml file (These properties are system variables which shall not be edited by
the user at runtime).
|
Modifier | Constructor and Description |
---|---|
private |
MainConfig()
No instances of this utility class.
|
Modifier and Type | Method and Description |
---|---|
private static void |
checkLoad()
Ensures that the configuration files where at least tried to load once.
|
static java.lang.Boolean |
exists()
Determines if at least one of the configuration files exist.
|
static java.lang.String |
get(java.lang.String config)
Returns the
String value of the requested configuration parameter if defined, otherwise
null . |
static <T> T |
get(java.lang.String config,
java.lang.Class<T> clazz)
Returns the value of the requested configuration parameter if defined as certain object type defined by the
second parameter clazz, otherwise
null . |
static java.util.Properties |
getChangeableProperties()
Returns all by user interface changeable system properties.
|
static void |
refresh()
Reloads and caches the configuration from the local XML and properties configuration file.
|
static void |
setProperty(java.lang.String key,
java.lang.String value)
Changes the value of a certain property or defines a new one with a
String value. |
static <T> void |
setProperty(java.lang.String key,
T value)
Changes the value of a certain property or defines a new on with a somewhat random value type.
|
static void |
updateProperties(java.util.Properties props)
Updates the changeable system properties by using the current user defined settings.
|
private static final java.lang.String SYSTEM_CONFIG_PATH
private static final java.lang.String SYSTEM_CONF_PATH_PROPERTIES
private static SimpleXMLConfigFile configFileXML
SimpleXMLConfigFile
.private static java.util.Properties configFileProperties
Properties
.public static java.lang.String get(java.lang.String config)
String
value of the requested configuration parameter if defined, otherwise
null
. This method uses get(String, Class)
with class String
, which looks up
dynamically defined properties from the set of configuration variables changeable by the user at runtime at first
and static defined properties from the developers xml configuration file afterwards. Due to this, it won't be
necessary to specify the target configuration set.config
- The name of the requested configuration variable as String
.String
value of the configuration variable if defined, otherwise null
.public static <T> T get(java.lang.String config, java.lang.Class<T> clazz)
null
. This method looks up dynamically defined properties
from the set of configuration variables changeable by the user at runtime at first and static defined properties
from the developers xml configuration file afterwards. Due to this, it won't be necessary to specify the target
configuration set. The utility method ProjectUtil.convertString(String, Class)
will be used for
conversion. For supported object types read the description of ProjectUtil.convertString(String, Class)
.T
- The object type as which the value shall be returned.config
- The name of the requested configuration variable as String
.clazz
- The object type class as which the value shall be returned.null
.private static void checkLoad()
public static void refresh()
public static java.lang.Boolean exists()
true
if at least one configuration file exists, otherwise false
.public static java.util.Properties getChangeableProperties()
Properties
object.public static void updateProperties(java.util.Properties props)
props
- The properties as Properties
object which are representing the current user settings.public static void setProperty(java.lang.String key, java.lang.String value)
String
value.key
- The name of the property as String
.value
- The (new) value of the property as String
.public static <T> void setProperty(java.lang.String key, T value)
Object.toString()
method.T
- The values object class type.key
- The key of the property as String
.value
- The (new) value of the property.