Class PropertyLookup

    • Method Detail

      • create

        public static PropertyLookup create​(java.util.Properties props)
      • create

        public static PropertyLookup create​(java.io.File propFile)
        Parameters:
        propFile - File where proeprty data is contained
        Returns:
        Factory method to create a property lookup object
      • createDeferred

        public static PropertyLookup createDeferred​(java.io.File propFile)
        Parameters:
        propFile - File where proeprty data is contained
        Returns:
        Factory method to create a property lookup object
      • create

        public static PropertyLookup create​(java.io.File propfile,
                                            IPropertyLookup defaultsLookup)
        Calls base constructor with data from IPropertyLookup paramater as defaults. Defaults data is read via the IPropertyLookup.getPropertiesMap() method.
        Parameters:
        propfile - File containing property data
        defaultsLookup - IPropertyLookup of default properties
        Returns:
        lookup
      • create

        public static PropertyLookup create​(java.util.Properties data,
                                            IPropertyLookup defaultsLookup)
        Parameters:
        data - Properties data
        defaultsLookup - IPropertyLookup of default properties
        Returns:
        lookup
      • create

        public static PropertyLookup create​(java.io.File propfile,
                                            java.util.Map defaults,
                                            IPropertyLookup defaultsLookup)
        Calls base constructor feeding defaults from Map and IPropertyLookup params
        Parameters:
        propfile - File containing property data
        defaults - Map of default properties
        defaultsLookup - IPropertyLookup of default properties
        Returns:
        lookup
      • getProperty

        public java.lang.String getProperty​(java.lang.String key)
        Get the property per specified key
        Specified by:
        getProperty in interface IPropertyLookup
        Specified by:
        getProperty in interface PropertyRetriever
        Parameters:
        key - name of the property
        Returns:
        Value of the property, or null
      • hasProperty

        public boolean hasProperty​(java.lang.String key)
        Check if property exists in file
        Specified by:
        hasProperty in interface IPropertyLookup
        Parameters:
        key - Name of the property
        Returns:
        true if it exists; false otherwise
      • fetchProperties

        public static java.util.Properties fetchProperties​(java.io.File propFile)
        given a file reads in its properties
        Parameters:
        propFile - File to read
        Returns:
        a Properties object with data filled from propFile
        Throws:
        PropertyLookupException - thrown if error loading property file
      • difference

        protected java.util.Properties difference​(java.util.Map map)
        Reads map of input properties and returns a collection of those that are unique to that input set.
        Parameters:
        map - Map of key/value pairs
        Returns:
        Properties unique to map
      • countProperties

        protected int countProperties()
        Counts number of properties currently in this object.
        Returns:
        number of properties
      • hasProperty

        public static boolean hasProperty​(java.lang.String propKey,
                                          java.io.File propFile)
        Reads propFile and then checks if specified key exists.
        Parameters:
        propKey - property name
        propFile - property file
        Returns:
        file if a property with that name exists. If an exception occurs while reading the file, false is returned.