Package rs.baselib.configuration
Class ConfigurationUtils
java.lang.Object
rs.baselib.configuration.ConfigurationUtils
public class ConfigurationUtils
extends java.lang.Object
Useful methods for configuration issues.
- Author:
- ralph
-
Constructor Summary
Constructors Constructor Description ConfigurationUtils() -
Method Summary
Modifier and Type Method Description static voidconfigure(IConfigurable configurable, org.apache.commons.configuration.Configuration config)Configure the object accordingly.static java.lang.StringgetParam(org.apache.commons.configuration.SubnodeConfiguration config, java.lang.String name)Returns the config parameter with given value for attribute name.static <T> Tload(java.lang.Class<T> clazz, org.apache.commons.configuration.Configuration config, boolean configure)Loads an object from a configuration.static java.lang.Objectload(java.lang.String className, org.apache.commons.configuration.Configuration config, boolean configure)Loads an object from a configuration.static java.lang.Objectload(org.apache.commons.configuration.Configuration config, boolean configure)Loads an object from a configuration.
-
Constructor Details
-
ConfigurationUtils
public ConfigurationUtils()
-
-
Method Details
-
load
public static java.lang.Object load(org.apache.commons.configuration.Configuration config, boolean configure)Loads an object from a configuration. The object is configured if it is an instance ofIConfigurable. The class will be taken from attribute[@class].- Parameters:
config- the configuration to applyconfigure- whether the object shall be configured (if it is aIConfigurable).- Returns:
- the object
-
load
public static java.lang.Object load(java.lang.String className, org.apache.commons.configuration.Configuration config, boolean configure)Loads an object from a configuration. The object is configured if it is an instance ofIConfigurable.- Parameters:
className- the name of class to be instantiatedconfig- the configuration to applyconfigure- whether the object shall be configured (if it is aIConfigurable).- Returns:
- the object
-
load
public static <T> T load(java.lang.Class<T> clazz, org.apache.commons.configuration.Configuration config, boolean configure)Loads an object from a configuration. The object is configured if it is an instance ofIConfigurable.- Type Parameters:
T- the type of the object to be instantiated- Parameters:
clazz- the class to be instantiatedconfig- the configuration to applyconfigure- whether the object shall be configured (if it is aIConfigurable).- Returns:
- the object
-
configure
public static void configure(IConfigurable configurable, org.apache.commons.configuration.Configuration config) throws org.apache.commons.configuration.ConfigurationExceptionConfigure the object accordingly.- Parameters:
configurable- the object to be configuredconfig- the configuration to apply- Throws:
org.apache.commons.configuration.ConfigurationException- when a problem occurs
-
getParam
public static java.lang.String getParam(org.apache.commons.configuration.SubnodeConfiguration config, java.lang.String name)Returns the config parameter with given value for attribute name.- Parameters:
config- configname- name of param- Returns:
- value of param
-