Package org.pentaho.di.core.variables
Class Variables
java.lang.Object
org.pentaho.di.core.variables.Variables
- All Implemented Interfaces:
VariableSpace
This class is an implementation of VariableSpace
- Author:
- Sven Boden
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
copyVariablesFrom
(VariableSpace space) Copy the variables from another space, without initializing with the defaults.environmentSubstitute
(String aString) Substitute the string using the current variable space.String[]
environmentSubstitute
(String[] string) Replaces environment variables in an array of strings.environmentSubstitute
(String aString, boolean escapeHexDelimiter) Substitute the string using the current variable space.fieldSubstitute
(String aString, RowMetaInterface rowMeta, Object[] rowData) Substitutes field values inaString
.static VariableSpace
Get a default variable space as a placeholder.boolean
getBooleanValueOfVariable
(String variableName, boolean defaultValue) This method returns a boolean for the new variable check boxes.Get the parent of the variable space.getVariable
(String variableName) Get the value of a variable.getVariable
(String variableName, String defaultValue) Get the value of a variable with a default in case the variable is not found.void
initializeVariablesFrom
(VariableSpace parent) Initialize variable space using the defaults, copy over the variables from the parent (using copyVariablesFrom()), after this the "injected" variables should be inserted (injectVariables()).void
injectVariables
(Map<String, String> prop) Inject variables.String[]
List the variables (not the values) that are currently in the variable space.void
setParentVariableSpace
(VariableSpace parent) Set the parent variable spacevoid
setVariable
(String variableName, String variableValue) Sets a variable in the Kettle Variables list.void
shareVariablesWith
(VariableSpace space) Share a variable space from another variable space.
-
Constructor Details
-
Variables
public Variables()
-
-
Method Details
-
copyVariablesFrom
Description copied from interface:VariableSpace
Copy the variables from another space, without initializing with the defaults. This does not affect any parent relationship.- Specified by:
copyVariablesFrom
in interfaceVariableSpace
- Parameters:
space
- the space to copy the variables from.
-
getParentVariableSpace
Description copied from interface:VariableSpace
Get the parent of the variable space.- Specified by:
getParentVariableSpace
in interfaceVariableSpace
- Returns:
- the parent.
-
setParentVariableSpace
Description copied from interface:VariableSpace
Set the parent variable space- Specified by:
setParentVariableSpace
in interfaceVariableSpace
- Parameters:
parent
- The parent variable space to set
-
getVariable
Description copied from interface:VariableSpace
Get the value of a variable with a default in case the variable is not found.- Specified by:
getVariable
in interfaceVariableSpace
- Parameters:
variableName
- The name of the variabledefaultValue
- The default value in case the variable could not be found- Returns:
- the String value of a variable
-
getVariable
Description copied from interface:VariableSpace
Get the value of a variable.- Specified by:
getVariable
in interfaceVariableSpace
- Parameters:
variableName
- The name of the variable- Returns:
- the String value of a variable or null in case the variable could not be found.
-
getBooleanValueOfVariable
Description copied from interface:VariableSpace
This method returns a boolean for the new variable check boxes. If the variable name is not set or the variable name is not specified, this method simply returns the default value. If not, it convert the variable value to a boolean. "Y", "YES" and "TRUE" all convert to true. (case insensitive)- Specified by:
getBooleanValueOfVariable
in interfaceVariableSpace
- Parameters:
variableName
- The variable to look up.defaultValue
- The default value to return.- Returns:
- See Also:
-
static method ValueMeta.convertStringToBoolean()
-
initializeVariablesFrom
Description copied from interface:VariableSpace
Initialize variable space using the defaults, copy over the variables from the parent (using copyVariablesFrom()), after this the "injected" variables should be inserted (injectVariables()). The parent is set as parent variable space.- Specified by:
initializeVariablesFrom
in interfaceVariableSpace
- Parameters:
parent
- the parent to start from, or null if root.
-
listVariables
Description copied from interface:VariableSpace
List the variables (not the values) that are currently in the variable space.- Specified by:
listVariables
in interfaceVariableSpace
- Returns:
- Array of String variable names.
-
setVariable
Description copied from interface:VariableSpace
Sets a variable in the Kettle Variables list.- Specified by:
setVariable
in interfaceVariableSpace
- Parameters:
variableName
- The name of the variable to setvariableValue
- The value of the variable to set. If the variableValue is null, the variable is cleared from the list.
-
environmentSubstitute
Description copied from interface:VariableSpace
Substitute the string using the current variable space.- Specified by:
environmentSubstitute
in interfaceVariableSpace
- Parameters:
aString
- The string to substitute.- Returns:
- The substituted string.
-
environmentSubstitute
Description copied from interface:VariableSpace
Substitute the string using the current variable space.- Specified by:
environmentSubstitute
in interfaceVariableSpace
- Parameters:
aString
- The string to substitute.escapeHexDelimiter
- escapes the hex delimiter substitution- Returns:
- The substituted string.
-
fieldSubstitute
public String fieldSubstitute(String aString, RowMetaInterface rowMeta, Object[] rowData) throws KettleValueException Substitutes field values inaString
. Field values are of the form "?{}". The values are retrieved from the specified row. Please note that the getString() method is used to convert to a String, for all values in the row. - Specified by:
fieldSubstitute
in interfaceVariableSpace
- Parameters:
aString
- the string on which to apply the substitution.rowMeta
- The row metadata to use.rowData
- The row data to use- Returns:
- the string with the substitution applied.
- Throws:
KettleValueException
- In case there is a String conversion error
-
environmentSubstitute
Description copied from interface:VariableSpace
Replaces environment variables in an array of strings. See also: environmentSubstitute(String string)- Specified by:
environmentSubstitute
in interfaceVariableSpace
- Parameters:
string
- The array of strings that wants its variables to be replaced.- Returns:
- the array with the environment variables replaced.
-
injectVariables
Description copied from interface:VariableSpace
Inject variables. The behaviour should be that the properties object will be stored and at the time the VariableSpace is initialized (or upon calling this method if the space is already initialized). After injecting the link of the properties object should be removed.- Specified by:
injectVariables
in interfaceVariableSpace
- Parameters:
prop
- Properties object containing key-value pairs.
-
getADefaultVariableSpace
Get a default variable space as a placeholder. Everytime you will get a new instance.- Returns:
- a default variable space.
-