com.ibm.dbb.build

Class BuildProperties

  • java.lang.Object
    • com.ibm.dbb.build.BuildProperties
  • All Implemented Interfaces:
    java.util.Map<java.lang.String,java.lang.String>


    public class BuildProperties
    extends java.lang.Object
    implements java.util.Map<java.lang.String,java.lang.String>
    The BuildProperties class represents a persistent set of properties similar to java.util.Properties. The main differences are:
    1. BuildProperties are stored in static tables and use static getters and setters allowing them to be available to the entire application.
    2. In addition to normal (String key,String value) properties, BuildProperties also introduce file properties which are properties that are associated to specific files via a list of file path patterns.
    File property path patterns are used to determine if a property has been associated to a file (represented as a relative path in a String variable). Both glob and regex patterns are supported by preprending 'glob:' or 'regex:' to the pattern. If neither is prepended to a pattern, glob is assumed. Ex.
    **/cobol_cics/*.cbl
    glob:**/copybook/*.cpy
    regex:.*/HAL30SAM\.COB$

    The getFileProperty(key, file) method first checks the file property table to see if a property exists that matches the key. If so it then does a pattern match search of the file for all of the file path patterns listed for the key. If no pattern matches the file, it will then check the basic properties table to see if the key exists there. If so, it will return the value as the "default" value for the file property.

    The load(...) methods support the following file properties format:
    1. key1 = value1
    2. key2 = value2 :: filePattern,filePattern
    3. key3 = value2 :: filePattern,filePattern \
      filePattern
    The '::' separator can be used in a property file property value by escaping it '\::'
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K,V>
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      static void addFilePattern(java.lang.String key, java.lang.String value, java.lang.String filePattern)
      Appends a file pattern to the list of associated file patterns for the property
      static void addFilePatterns(java.lang.String key, java.lang.String value, java.util.List<java.lang.String> filePatterns)
      Appends a list of file patterns to the list of associated file patterns for the property
      static java.util.Set<java.lang.String> basicPropertyKeySet()
      Returns a set of keys used as basic properties
      void clear() 
      static void clearFileProperties()
      Removes all file properties
      static void clearProperties()
      Removes all basic properties
      boolean containsKey(java.lang.Object arg0) 
      boolean containsValue(java.lang.Object arg0) 
      java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.String>> entrySet() 
      static java.util.Map<java.lang.String,java.util.Set<java.lang.String>> filePropertyValueKeySet()
      Returns a Map containing the file properties key set.
      java.lang.String get(java.lang.Object arg0) 
      static java.lang.String getFileProperty(java.lang.String key, java.lang.String file)
      Searches for the file property for the given key that is associated to the file.
      static java.util.List<java.lang.String> getFilePropertyPatterns(java.lang.String key, java.lang.String value)
      Returns the list of file patterns associated with a file property
      static BuildProperties getInstance()
      Returns a singleton instance of BuildProperties.
      static java.lang.String getProperty(java.lang.String key)
      Returns the basic property value
      boolean isEmpty() 
      java.util.Set<java.lang.String> keySet() 
      static java.lang.String list()
      Returns a list of all the basic and file properties
      static void load(java.io.File file)
      Loads a list of file properties from an external properties file
      static void load(java.io.File file, java.lang.String encoding)
      Loads a list of file properties from an external properties file
      static void load(java.lang.String sourceDir, java.lang.String file)
      Loads a list of file properties from an external properties file
      static void load(java.lang.String sourceDir, java.lang.String file, java.lang.String encoding)
      Loads a list of file properties from an external properties file
      java.lang.String put(java.lang.String arg0, java.lang.String arg1) 
      void putAll(java.util.Map<? extends java.lang.String,? extends java.lang.String> arg0) 
      java.lang.String remove(java.lang.Object arg0) 
      static void removeFileProperty(java.lang.String key)
      Removes all file properties for the key given
      static void removeProperty(java.lang.String key)
      Removes the basic property for the key given
      static void setFileProperty(java.lang.String key, java.lang.String value, java.util.List<java.lang.String> filePatterns)
      Sets a name value property with a list of associated file patterns in the file properties table.
      static void setFileProperty(java.lang.String key, java.lang.String value, java.lang.String filePattern)
      Sets a name value property associated to a file pattern in the file properties table.
      static void setProperty(java.lang.String key, java.lang.String value)
      Sets a basic property
      int size() 
      static void staticReset() 
      java.util.Collection<java.lang.String> values() 
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
    • Field Detail

      • METADATA_STORE_TYPE

        public static final java.lang.String METADATA_STORE_TYPE
        See Also:
        Constant Field Values
      • METADATA_STORE_TYPE_FILE

        public static final java.lang.String METADATA_STORE_TYPE_FILE
        See Also:
        Constant Field Values
      • METADATA_STORE_TYPE_DB2

        public static final java.lang.String METADATA_STORE_TYPE_DB2
        See Also:
        Constant Field Values
      • METADATA_STORE_USERID

        public static final java.lang.String METADATA_STORE_USERID
        See Also:
        Constant Field Values
      • METADATA_STORE_URL

        public static final java.lang.String METADATA_STORE_URL
        See Also:
        Constant Field Values
      • METADATA_STORE_PASSWORD

        public static final java.lang.String METADATA_STORE_PASSWORD
        See Also:
        Constant Field Values
      • METADATA_STORE_SCHEMA

        public static final java.lang.String METADATA_STORE_SCHEMA
        See Also:
        Constant Field Values
      • BUILD_REPORT_ONLY

        public static final java.lang.String BUILD_REPORT_ONLY
        See Also:
        Constant Field Values
    • Method Detail

      • getInstance

        public static BuildProperties getInstance()
        Returns a singleton instance of BuildProperties. Though all methods are static, an instance of the class is useful in some scripting languages.
        Returns:
        a singleton instance of BuildProperties
      • load

        public static void load(java.lang.String sourceDir,
                                java.lang.String file)
                         throws java.io.IOException
        Loads a list of file properties from an external properties file
        Parameters:
        sourceDir - The absolute directory that contains the properties file
        file - The relative path of the properties file
        Throws:
        java.io.IOException - If an error occurred in loading the files.
      • load

        public static void load(java.lang.String sourceDir,
                                java.lang.String file,
                                java.lang.String encoding)
                         throws java.io.IOException
        Loads a list of file properties from an external properties file
        Parameters:
        sourceDir - The absolute directory that contains the properties file
        file - The relative path of the properties file
        encoding - The encoding of the properties file
        Throws:
        java.io.IOException - If an error occurred in loading the files.
      • load

        public static void load(java.io.File file)
                         throws java.io.IOException
        Loads a list of file properties from an external properties file
        Parameters:
        file - The properties file to load
        Throws:
        java.io.IOException - If an error occurred in loading the files.
      • load

        public static void load(java.io.File file,
                                java.lang.String encoding)
                         throws java.io.IOException
        Loads a list of file properties from an external properties file
        Parameters:
        file - The properties file to load
        encoding - The encoding of the properties file
        Throws:
        java.io.IOException - If an error occurred in loading the files.
      • getFileProperty

        public static java.lang.String getFileProperty(java.lang.String key,
                                                       java.lang.String file)
        Searches for the file property for the given key that is associated to the file. If the property is not found for the file, then a search for a basic property with that key is performed. If no property is found, then NULL is returned.
        Parameters:
        key - The key of the file property to be searched.
        file - The relative path of the file to search for.
        Returns:
        The value of the property search or NULL if no property is found.
      • getProperty

        public static java.lang.String getProperty(java.lang.String key)
        Returns the basic property value
        Parameters:
        key - The name of the property to be set
        Returns:
        The property value or NULL if it does not exist
      • setFileProperty

        public static void setFileProperty(java.lang.String key,
                                           java.lang.String value,
                                           java.lang.String filePattern)
        Sets a name value property associated to a file pattern in the file properties table. If the name value property already exists in the table, the file patterns are replaced with the new file patterns.
        Parameters:
        key - The name of the property to be set
        value - The value of the property to be set
        filePattern - The file pattern to associate the property to property.
      • setFileProperty

        public static void setFileProperty(java.lang.String key,
                                           java.lang.String value,
                                           java.util.List<java.lang.String> filePatterns)
        Sets a name value property with a list of associated file patterns in the file properties table. If the name value property already exists in the table, the file patterns are replaced with the new file patterns.
        Parameters:
        key - The name of the property to be set
        value - The value of the property to be set
        filePatterns - The list of file patterns to associate the property to property.
      • setProperty

        public static void setProperty(java.lang.String key,
                                       java.lang.String value)
        Sets a basic property
        Parameters:
        key - The name of the property to be set
        value - The value of the property to be set
      • removeProperty

        public static void removeProperty(java.lang.String key)
        Removes the basic property for the key given
        Parameters:
        key - The key of the property to remove
      • removeFileProperty

        public static void removeFileProperty(java.lang.String key)
        Removes all file properties for the key given
        Parameters:
        key - - The key of the properties to remove
      • clearProperties

        public static void clearProperties()
        Removes all basic properties
      • clearFileProperties

        public static void clearFileProperties()
        Removes all file properties
      • basicPropertyKeySet

        public static java.util.Set<java.lang.String> basicPropertyKeySet()
        Returns a set of keys used as basic properties
        Returns:
        The set of keys in us
      • filePropertyValueKeySet

        public static java.util.Map<java.lang.String,java.util.Set<java.lang.String>> filePropertyValueKeySet()
        Returns a Map containing the file properties key set. The format of the Map is <values>
        Returns:
        Map containing the file properties key set
      • getFilePropertyPatterns

        public static java.util.List<java.lang.String> getFilePropertyPatterns(java.lang.String key,
                                                                               java.lang.String value)
        Returns the list of file patterns associated with a file property
        Parameters:
        key - The name of the file property to retrieve
        value - The value of the property to retrieve
        Returns:
        The list of file patterns associated with a file property
      • addFilePattern

        public static void addFilePattern(java.lang.String key,
                                          java.lang.String value,
                                          java.lang.String filePattern)
        Appends a file pattern to the list of associated file patterns for the property
        Parameters:
        key - The name of the file property
        value - The value of the file property
        filePattern - The file pattern to add to the file property
      • addFilePatterns

        public static void addFilePatterns(java.lang.String key,
                                           java.lang.String value,
                                           java.util.List<java.lang.String> filePatterns)
        Appends a list of file patterns to the list of associated file patterns for the property
        Parameters:
        key - The name of the file property
        value - The value of the file property
        filePatterns - The list of file patterns to add to the file property
      • list

        public static java.lang.String list()
        Returns a list of all the basic and file properties
        Returns:
        List of all properties
      • staticReset

        public static void staticReset()
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Map<java.lang.String,java.lang.String>
      • containsKey

        public boolean containsKey(java.lang.Object arg0)
        Specified by:
        containsKey in interface java.util.Map<java.lang.String,java.lang.String>
      • containsValue

        public boolean containsValue(java.lang.Object arg0)
        Specified by:
        containsValue in interface java.util.Map<java.lang.String,java.lang.String>
      • entrySet

        public java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.String>> entrySet()
        Specified by:
        entrySet in interface java.util.Map<java.lang.String,java.lang.String>
      • get

        public java.lang.String get(java.lang.Object arg0)
        Specified by:
        get in interface java.util.Map<java.lang.String,java.lang.String>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Map<java.lang.String,java.lang.String>
      • keySet

        public java.util.Set<java.lang.String> keySet()
        Specified by:
        keySet in interface java.util.Map<java.lang.String,java.lang.String>
      • put

        public java.lang.String put(java.lang.String arg0,
                                    java.lang.String arg1)
        Specified by:
        put in interface java.util.Map<java.lang.String,java.lang.String>
      • putAll

        public void putAll(java.util.Map<? extends java.lang.String,? extends java.lang.String> arg0)
        Specified by:
        putAll in interface java.util.Map<java.lang.String,java.lang.String>
      • remove

        public java.lang.String remove(java.lang.Object arg0)
        Specified by:
        remove in interface java.util.Map<java.lang.String,java.lang.String>
      • size

        public int size()
        Specified by:
        size in interface java.util.Map<java.lang.String,java.lang.String>
      • values

        public java.util.Collection<java.lang.String> values()
        Specified by:
        values in interface java.util.Map<java.lang.String,java.lang.String>

<IBM Copyright © 2018 IBM Corp. All Rights Reserved.