Package com.saperion.util.configuration
Class ConfigurationUtil
- java.lang.Object
-
- com.saperion.util.configuration.ConfigurationUtil
-
public final class ConfigurationUtil extends java.lang.ObjectThis utility offers convenient configuration file usage.- Author:
- sts
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringBASE_PATHThe internal base path to the configuration files.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcheckConfigFiles(java.util.List<ConfigFileDescriptor> configs)Checks if all required configurations files are existing.static java.lang.StringgetAbsolutePath(ConfigFileDescriptor configFile)Returns the absolute path of the given configuration file.static java.lang.StringgetAbsolutePath(ConfigurationFileHolder holder)Returns the absolute path of the given configuration file holder.static java.lang.StringgetPath(ConfigFileDescriptor config)Returns the path of the given config file.static java.lang.StringgetPath(ConfigurationFileHolder holder)Returns the path of the given config file holder.static java.util.PropertiesgetProperties(ConfigFileDescriptor config)Returns Properties object by the given config file.static java.util.PropertiesgetProperties(ConfigurationFileHolder holder)Returns Properties object by the given config file holder.static java.util.PropertiesgetProperties(java.lang.String config)Returns Properties object by the given path.static voidsetBasePath(java.lang.String basepath)Sets the base path of all configurations files handled by this util.
-
-
-
Method Detail
-
setBasePath
public static void setBasePath(java.lang.String basepath)
Sets the base path of all configurations files handled by this util.- Parameters:
basepath- the base path of all configuration files.
-
checkConfigFiles
public static void checkConfigFiles(java.util.List<ConfigFileDescriptor> configs) throws java.lang.Exception
Checks if all required configurations files are existing.- Parameters:
configs- The required configurations.- Throws:
java.lang.Exception- one of the required files is missing.
-
getPath
public static java.lang.String getPath(ConfigFileDescriptor config)
Returns the path of the given config file.- Parameters:
config- The config file to get the path of.- Returns:
- The config file's path.
-
getPath
public static java.lang.String getPath(ConfigurationFileHolder holder)
Returns the path of the given config file holder.- Parameters:
holder- The config file holder to get the path of.- Returns:
- The config file's path.
-
getProperties
public static java.util.Properties getProperties(ConfigFileDescriptor config)
Returns Properties object by the given config file.- Parameters:
config- The config file to build the Properties of.- Returns:
- The built Properties object.
-
getProperties
public static java.util.Properties getProperties(ConfigurationFileHolder holder)
Returns Properties object by the given config file holder.- Parameters:
holder- The config file holder to build the Properties of.- Returns:
- The built Properties object.
-
getProperties
public static java.util.Properties getProperties(java.lang.String config)
Returns Properties object by the given path. Tries to load the properties files as XML and flat file.- Parameters:
config- The config path to the config file to build the Properties of.- Returns:
- The built Properties object.
-
getAbsolutePath
public static java.lang.String getAbsolutePath(ConfigFileDescriptor configFile)
Returns the absolute path of the given configuration file.- Parameters:
configFile- The configuration file in question.- Returns:
- the absolute path of the given configuration file if found.
-
getAbsolutePath
public static java.lang.String getAbsolutePath(ConfigurationFileHolder holder)
Returns the absolute path of the given configuration file holder.- Parameters:
holder- The configuration file in question.- Returns:
- the absolute path of the given configuration file if found.
-
-