Class 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
    • Constructor Detail

      • PropertiesManager

        private PropertiesManager()
        Hiding constructor so that this utility class cannot be instantiated from outside.
    • Method Detail

      • loadProperties

        public static void loadProperties​(Properties properties,
                                          String fileName)
                                   throws IOException
        It loads the properties in a file named fileName into the properties map.
        Parameters:
        properties - the properties file to which the the properties in the file fileName should 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 file fileName is null.
      • loadProperties

        public static void loadProperties​(String fileName)
                                   throws IOException
        It loads the properties in a file named fileName into the internal PROPERTIES map.
        Parameters:
        fileName - the name of the file from which there are properties to be loaded
        Throws:
        IOException - if the input stream for the file fileName is null.
      • getProperty

        public static String getProperty​(String key)
        Parameters:
        key - the key to be looked into the PROPERTIES map of this class.
        Returns:
        the value for the key provided, if found. Returns null otherwise.
      • getBooleanProperty

        public static boolean getBooleanProperty​(String key)
        Parameters:
        key - the key to be looked into the PROPERTIES map of this class.
        Returns:
        the boolean value for the key provided, 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 the PROPERTIES map of this class.
        Returns:
        the int value for the key provided, if found.
        Throws:
        NumberFormatException - if the found value is not a parseable number.
      • setProperty

        public static void setProperty​(String key,
                                       String value)
        Parameters:
        key - the key to be set into the PROPERTIES map of this class.
        value - the value to be set into the PROPERTIES map of this class, associated to the key specified.