Package com.ibm.dbb.task
Class TaskVariables
- java.lang.Object
-
- com.ibm.dbb.task.variables.AbstractVariables
-
- com.ibm.dbb.task.TaskVariables
-
- All Implemented Interfaces:
TypableFileVariable
,TypableVariable
public class TaskVariables extends AbstractVariables implements TypableFileVariable
TaskVariables stores task-level configuration for zBuilder tasks.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.ibm.dbb.task.variables.AbstractVariables
AbstractVariables.ReferenceReplacementMetadata
-
-
Constructor Summary
Constructors Constructor Description TaskVariables()
Initializes a TaskVariables object.TaskVariables(boolean shouldFileGetsDefault)
Initializes a TaskVariables object.TaskVariables(boolean shouldFileGetsDefault, boolean hasWriteLayer, BuildContext buildContext, com.ibm.dbb.task.variables.internal.VariableGroup... variables)
Initializes a TaskVariables object with the specified groups.TaskVariables(boolean shouldFileGetsDefault, boolean hasWriteLayer, com.ibm.dbb.task.variables.internal.VariableGroup... variables)
buildContext
defaults tonull
.TaskVariables(boolean shouldFileGetsDefault, BuildContext buildContext)
Initializes a TaskVariables object.TaskVariables(boolean shouldFileGetsDefault, com.ibm.dbb.task.variables.internal.VariableGroup... variables)
hasWriteLayer
defaults tofalse
.TaskVariables(com.ibm.dbb.task.variables.internal.VariableGroup... variables)
shouldFileGetsDefault
defaults tofalse
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(java.lang.String key)
searchContext
defaults to true.boolean
contains(java.lang.String key, boolean searchContext)
Returns true if the input key has a variable associated with it.boolean
contains(java.lang.String key, java.lang.String file)
searchContext
defaults to true.boolean
contains(java.lang.String key, java.lang.String file, boolean searchContext)
shouldFileGetsDefault
defaults to the value set during construction.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.BuildContext
getBuildContext()
Returns the build context supplied at construction, which is used as a fallback to resolve variable references.java.lang.Object
getFileVariable(java.lang.String key, java.lang.String file)
shouldFileGetsDefault
defaults to the value saved during construction.java.lang.Object
getFileVariable(java.lang.String key, java.lang.String file, boolean shouldFileGetsDefault)
Retrieves the first match for the specified key and file, defaulting to theAbstractVariables.getVariable(String)
method according to theshouldFileGetsDefault
parameter.void
prepare()
Clears the write layer if it is enabled.java.lang.Object
replaceReferences(java.lang.Object value, java.lang.String file)
Replaces any references for the input object if possible.boolean
setFileVariable(java.lang.String key, java.lang.Object value, java.lang.String filePattern)
Sets a file variable for the input key and file pattern.boolean
setFileVariable(java.lang.String key, java.lang.Object value, java.util.List<java.lang.String> filePatterns)
Sets a file variable for the input key and file pattern.-
Methods inherited from class com.ibm.dbb.task.variables.AbstractVariables
getReferenceMetadata, getVariable, isRestricted, replaceReferences, replaceReferences, setGroup, setVariable, validateRestrictedFields
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.ibm.dbb.task.variables.TypableFileVariable
getBooleanFileVariable, getBooleanFileVariable, getDoubleFileVariable, getDoubleFileVariable, getIntegerFileVariable, getIntegerFileVariable, getListFileVariable, getListFileVariable, getListStringFileVariable, getListStringFileVariable, getMapFileVariable, getMapFileVariable, getSetFileVariable, getSetFileVariable, getSetStringFileVariable, getSetStringFileVariable, getStringFileVariable, getStringFileVariable
-
Methods inherited from interface com.ibm.dbb.task.variables.TypableVariable
getBooleanVariable, getBooleanVariable, getBuildGroup, getBuildResult, getCommandLine, getDoubleVariable, getDoubleVariable, getIntegerVariable, getIntegerVariable, getListStringVariable, getListStringVariable, getListVariable, getListVariable, getMapVariable, getMapVariable, getSetStringVariable, getSetStringVariable, getSetVariable, getStringVariable, getStringVariable
-
-
-
-
Constructor Detail
-
TaskVariables
public TaskVariables()
Initializes a TaskVariables object.shouldFileGetsDefault
defaults tofalse
.- See Also:
#Constructor(boolean)
-
TaskVariables
public TaskVariables(boolean shouldFileGetsDefault)
Initializes a TaskVariables object.buildContext
defaults tonull
.- 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 tofalse
.- 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 tofalse
.- 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 tonull
.- 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 untilprepare()
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) throws BuildException
shouldFileGetsDefault
defaults to the value saved during construction.- Specified by:
getFileVariable
in interfaceTypableFileVariable
- Parameters:
key
- the key to match.file
- the file to match.- Returns:
- Object or null if no match is found.
- Throws:
BuildException
- See Also:
getFileVariable(String, String, boolean)
-
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 theAbstractVariables.getVariable(String)
method according to theshouldFileGetsDefault
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)
searchContext
defaults to true.- See Also:
contains(String, String, boolean)
-
contains
public boolean contains(java.lang.String key, java.lang.String file, boolean searchContext)
shouldFileGetsDefault
defaults to the value set during construction.
-
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 testfile
- the file to matchsearchContext
- 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 classAbstractVariables
- 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 testsearchContext
- 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
-
-