Class TaskVariables

    • Constructor Detail

      • TaskVariables

        public TaskVariables()
        Initializes a TaskVariables object. shouldFileGetsDefault defaults to false.
        See Also:
        #Constructor(boolean)
      • TaskVariables

        public TaskVariables​(boolean shouldFileGetsDefault)
        Initializes a TaskVariables object. buildContext defaults to null.
        Parameters:
        shouldFileGetsDefault - boolean true if #getFileVariable calls should default to getVariable.
        See Also:
        #Constructor(boolean, BuildContext)
      • TaskVariables

        public TaskVariables​(boolean shouldFileGetsDefault,
                             BuildContext buildContext)
        Initializes a TaskVariables object.
        Parameters:
        shouldFileGetsDefault - boolean true if #getFileVariable calls should default to getVariable.
        buildContext - the context variables object to associate with this object. Used in the default getter for replacing references: getDefaultGetter().
      • TaskVariables

        public TaskVariables​(com.ibm.dbb.task.variables.internal.VariableGroup... variables)
                      throws java.lang.IllegalArgumentException
        shouldFileGetsDefault defaults to false.
        Throws:
        java.lang.IllegalArgumentException
        See Also:
        #Constructor(boolean, VariableGroup...)
      • TaskVariables

        public TaskVariables​(boolean shouldFileGetsDefault,
                             com.ibm.dbb.task.variables.internal.VariableGroup... variables)
                      throws java.lang.IllegalArgumentException
        hasWriteLayer defaults to false.
        Throws:
        java.lang.IllegalArgumentException
        See Also:
        #Constructor(boolean, boolean, VariableGroup...)
      • TaskVariables

        public TaskVariables​(boolean shouldFileGetsDefault,
                             boolean hasWriteLayer,
                             com.ibm.dbb.task.variables.internal.VariableGroup... variables)
                      throws java.lang.IllegalArgumentException
        buildContext defaults to null.
        Throws:
        java.lang.IllegalArgumentException
        See Also:
        #Constructor(boolean, boolean, BuildContext, VariableGroup...)
      • TaskVariables

        public TaskVariables​(boolean shouldFileGetsDefault,
                             boolean hasWriteLayer,
                             BuildContext buildContext,
                             com.ibm.dbb.task.variables.internal.VariableGroup... variables)
        Initializes a TaskVariables object with the specified groups. The lookup order is the order groups are passed in.
        Parameters:
        shouldFileGetsDefault - boolean true if #getFileVariable calls should default to getVariable.
        hasWriteLayer - Whether to insert an empty VariableGroup at the start of the lookup order to hold writes until prepare() is next called.
        buildContext - the context variables object to associate with this object. Used in the default getter for replacing references: getDefaultGetter().
        variables - The variable groups in the order they should be looked up in.
    • Method Detail

      • prepare

        public void prepare()
        Clears the write layer if it is enabled.
      • getFileVariable

        public java.lang.Object getFileVariable​(java.lang.String key,
                                                java.lang.String file,
                                                boolean shouldFileGetsDefault)
                                         throws BuildException
        Retrieves the first match for the specified key and file, defaulting to the AbstractVariables.getVariable(String) method according to the shouldFileGetsDefault parameter. Returns null if there was no match found.
        Parameters:
        key - the key to match.
        file - the file to match.
        shouldFileGetsDefault - true to source the variable from normal variables if there is no matched file variable.
        Returns:
        Object or null if no match was found.
        Throws:
        BuildException
      • contains

        public boolean contains​(java.lang.String key,
                                java.lang.String file,
                                boolean searchContext)
        shouldFileGetsDefault defaults to the value set during construction.
        See Also:
        contains(String, String, boolean, boolean)
      • contains

        public boolean contains​(java.lang.String key,
                                java.lang.String file,
                                boolean searchContext,
                                boolean shouldFileGetsDefault)
        Returns true if the input key has a variable associated with it.
        Parameters:
        key - the key to test
        file - the file to match
        searchContext - true to additionaly search the attached BuildContext for the input key.
        shouldFileGetsDefault - true to source the variable from normal variables if there is no matched file variable.
        Returns:
        true if the key has a variable associated with it. False otherwise.
      • contains

        public boolean contains​(java.lang.String key)
        searchContext defaults to true.
        Overrides:
        contains in class AbstractVariables
        Parameters:
        key - the key to test
        Returns:
        true if the key has a variable associated with it. False otherwise.
        See Also:
        contains(String, boolean)
      • contains

        public boolean contains​(java.lang.String key,
                                boolean searchContext)
        Returns true if the input key has a variable associated with it.
        Parameters:
        key - the key to test
        searchContext - true to additionaly search the attached BuildContext for the input key
        Returns:
        true if the key has a variable associated with it. False otherwise.
      • getBuildContext

        public BuildContext getBuildContext()
        Returns the build context supplied at construction, which is used as a fallback to resolve variable references.
        Returns:
        BuildContext or null if not configured.
      • setFileVariable

        public boolean setFileVariable​(java.lang.String key,
                                       java.lang.Object value,
                                       java.lang.String filePattern)
                                throws com.ibm.dbb.task.configuration.ConfigurationException
        Sets a file variable for the input key and file pattern. The values source is set to the currently executing task.
        Parameters:
        key - the key to match.
        value - the value to assign.
        filePattern - the file pattern to use in matches.
        Returns:
        boolean, indicating success. False if there was no writable layer found.
        Throws:
        com.ibm.dbb.task.configuration.ConfigurationException - when attempting to assign a value to a restricted key.
      • setFileVariable

        public boolean setFileVariable​(java.lang.String key,
                                       java.lang.Object value,
                                       java.util.List<java.lang.String> filePatterns)
                                throws com.ibm.dbb.task.configuration.ConfigurationException
        Sets a file variable for the input key and file pattern. The values source is set to the currently executing task.
        Parameters:
        key - the key to match.
        value - the value to assign.
        filePatterns - a list of file patterns to use in matches.
        Returns:
        boolean, indicating success. False if there was no writable layer found.
        Throws:
        com.ibm.dbb.task.configuration.ConfigurationException - when attempting to assign a value to a restricted key.
      • replaceReferences

        public java.lang.Object replaceReferences​(java.lang.Object value,
                                                  java.lang.String file)
                                           throws BuildException
        Replaces any references for the input object if possible. Returning a copy of its content if it's a Collection. The input file is used to source from file variables first.
        Parameters:
        value - the value to perform replacement on.
        file - the file to compare against file pattern matchers.
        Returns:
        the input object with all valid references replaced.
        Throws:
        BuildException