public class Variables extends Object implements VariableSpace
Constructor and Description |
---|
Variables() |
Modifier and Type | Method and Description |
---|---|
void |
copyVariablesFrom(VariableSpace space)
Copy the variables from another space, without initializing with the defaults.
|
String |
environmentSubstitute(String aString)
Substitute the string using the current variable space.
|
String[] |
environmentSubstitute(String[] string)
Replaces environment variables in an array of strings.
|
String |
fieldSubstitute(String aString,
RowMetaInterface rowMeta,
Object[] rowData)
Substitutes field values in
aString . |
static VariableSpace |
getADefaultVariableSpace()
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.
|
VariableSpace |
getParentVariableSpace()
Get the parent of the variable space.
|
String |
getVariable(String variableName)
Get the value of a variable.
|
String |
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[] |
listVariables()
List the variables (not the values) that are currently in the variable space.
|
void |
setParentVariableSpace(VariableSpace parent)
Set the parent variable space
|
void |
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.
|
public void copyVariablesFrom(VariableSpace space)
VariableSpace
copyVariablesFrom
in interface VariableSpace
space
- the space to copy the variables from.public VariableSpace getParentVariableSpace()
VariableSpace
getParentVariableSpace
in interface VariableSpace
public void setParentVariableSpace(VariableSpace parent)
VariableSpace
setParentVariableSpace
in interface VariableSpace
parent
- The parent variable space to setpublic String getVariable(String variableName, String defaultValue)
VariableSpace
getVariable
in interface VariableSpace
variableName
- The name of the variabledefaultValue
- The default value in case the variable could not be foundpublic String getVariable(String variableName)
VariableSpace
getVariable
in interface VariableSpace
variableName
- The name of the variablepublic boolean getBooleanValueOfVariable(String variableName, boolean defaultValue)
VariableSpace
getBooleanValueOfVariable
in interface VariableSpace
variableName
- The variable to look up.defaultValue
- The default value to return.static method ValueMeta.convertStringToBoolean()
public void initializeVariablesFrom(VariableSpace parent)
VariableSpace
initializeVariablesFrom
in interface VariableSpace
parent
- the parent to start from, or null if root.public String[] listVariables()
VariableSpace
listVariables
in interface VariableSpace
public void setVariable(String variableName, String variableValue)
VariableSpace
setVariable
in interface VariableSpace
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.public String environmentSubstitute(String aString)
VariableSpace
environmentSubstitute
in interface VariableSpace
aString
- The string to substitute.public String fieldSubstitute(String aString, RowMetaInterface rowMeta, Object[] rowData) throws KettleValueException
aString
. Field values are of the form "?{fieldSubstitute
in interface VariableSpace
aString
- the string on which to apply the substitution.rowMeta
- The row metadata to use.rowData
- The row data to useKettleValueException
- In case there is a String conversion errorpublic String[] environmentSubstitute(String[] string)
VariableSpace
environmentSubstitute
in interface VariableSpace
string
- The array of strings that wants its variables to be replaced.public void shareVariablesWith(VariableSpace space)
VariableSpace
shareVariablesWith
in interface VariableSpace
space
- Variable space to be shared.public void injectVariables(Map<String,String> prop)
VariableSpace
injectVariables
in interface VariableSpace
prop
- Properties object containing key-value pairs.public static VariableSpace getADefaultVariableSpace()