Package com.linkare.commons.utils
Class PropertiesManager
- java.lang.Object
-
- com.linkare.commons.utils.PropertiesManager
-
public final class PropertiesManager extends Object
Utility class to help loading and looking for any property in a Java Properties map.- Since:
- 0.0.1
- Author:
- Paulo Zenida - Linkare TI
-
-
Field Summary
Fields Modifier and Type Field Description private static StringDEFAULT_BUILD_PROPERTIESprivate static PropertiesManagerINSTANCEprivate static PropertiesPROPERTIES
-
Constructor Summary
Constructors Modifier Constructor Description privatePropertiesManager()Hiding constructor so that this utility class cannot be instantiated from outside.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleangetBooleanProperty(String key)static IntegergetIntegerProperty(String key)static StringgetProperty(String key)static voidloadProperties(String fileName)It loads the properties in a file namedfileNameinto the internalPROPERTIESmap.static voidloadProperties(Properties properties, String fileName)It loads the properties in a file namedfileNameinto thepropertiesmap.static voidsetProperty(String key, String value)
-
-
-
Field Detail
-
DEFAULT_BUILD_PROPERTIES
private static final String DEFAULT_BUILD_PROPERTIES
- See Also:
- Constant Field Values
-
INSTANCE
private static final PropertiesManager INSTANCE
-
PROPERTIES
private static final Properties PROPERTIES
-
-
Method Detail
-
loadProperties
public static void loadProperties(Properties properties, String fileName) throws IOException
It loads the properties in a file namedfileNameinto thepropertiesmap.- Parameters:
properties- the properties file to which the the properties in the filefileNameshould be loaded to.fileName- the name of the file from which there are properties to be loaded- Throws:
IOException- if the input stream for the filefileNameis null.
-
loadProperties
public static void loadProperties(String fileName) throws IOException
It loads the properties in a file namedfileNameinto the internalPROPERTIESmap.- Parameters:
fileName- the name of the file from which there are properties to be loaded- Throws:
IOException- if the input stream for the filefileNameis null.
-
getProperty
public static String getProperty(String key)
- Parameters:
key- the key to be looked into thePROPERTIESmap of this class.- Returns:
- the value for the
keyprovided, if found. Returns null otherwise.
-
getBooleanProperty
public static boolean getBooleanProperty(String key)
- Parameters:
key- the key to be looked into thePROPERTIESmap of this class.- Returns:
- the boolean value for the
keyprovided, if found. Returns false when not found or the value is not a boolean type.
-
getIntegerProperty
public static Integer getIntegerProperty(String key)
- Parameters:
key- the key to be looked into thePROPERTIESmap of this class.- Returns:
- the int value for the
keyprovided, if found. - Throws:
NumberFormatException- if the found value is not a parseable number.
-
-