Package org.sqlproc.engine.util
Class PropertiesLoader
- java.lang.Object
-
- org.sqlproc.engine.util.PropertiesLoader
-
public class PropertiesLoader extends Object
The helper class for the property file loading. The property file can be located on the classpath, in the root directory or in the user's home directory.For more info please see the Tutorials.
- Author:
- Vladimir Hudec
-
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.Logger
logger
The internal slf4j logger.private Properties
properties
Properties from the property file.
-
Constructor Summary
Constructors Constructor Description PropertiesLoader(String fileName, Class<?> loaderClass)
Reads the property file and creates a new PropertiesLoader instance.PropertiesLoader(List<String> fileNames, Class<?> loaderClass)
Reads the property files and creates a new PropertiesLoader instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
get(String name)
Returns the named property value from the property file.Properties
getProperties()
Returns all properties.static Properties
getProperties(Class<?> loaderClass, String fileName)
Reads the property file and creates a new PropertiesLoader instance.static Properties
getProperties(Class<?> loaderClass, String... fileNames)
Reads the property files and creates a new PropertiesLoader instance.private Properties
load(String fileName, Class<?> loaderClass)
Reads the property file and creates a new Properties instance.
-
-
-
Field Detail
-
logger
protected final org.slf4j.Logger logger
The internal slf4j logger.
-
properties
private Properties properties
Properties from the property file.
-
-
Method Detail
-
getProperties
public static Properties getProperties(Class<?> loaderClass, String fileName)
Reads the property file and creates a new PropertiesLoader instance.- Parameters:
fileName
- The name of the file to be read.loaderClass
- Class used to detect the correct classloader.- Returns:
- all properties from the specified file(s)
-
getProperties
public static Properties getProperties(Class<?> loaderClass, String... fileNames)
Reads the property files and creates a new PropertiesLoader instance.- Parameters:
fileNames
- The names of the files to be read.loaderClass
- Class used to detect the correct classloader.- Returns:
- all properties from the specified file(s)
-
load
private Properties load(String fileName, Class<?> loaderClass)
Reads the property file and creates a new Properties instance.- Parameters:
fileName
- The name of the file to be read.loaderClass
- Class used to detect the correct classloader.- Returns:
- all properties from the specified file
-
get
public String get(String name)
Returns the named property value from the property file.- Parameters:
name
- the name (=key in the property file)- Returns:
- the value of the property
-
getProperties
public Properties getProperties()
Returns all properties.- Returns:
- all properties
-
-