/** * Substitutes variables in <code>aString</code>. Variables are of the form "%%<variable name>%%", following the * Windows convention. The values are retrieved from the given map. * * @param aString * the string on which to apply the substitution. * @param variables * a map containg the variable values. The keys are the variable names, the values are the variable values. * @return the string with the substitution applied. */ public static String substituteWindows( String aString, Map<String, String> variables ) { return substitute( aString, variables, WINDOWS_OPEN, WINDOWS_CLOSE ); }
/** * Substitutes variables in <code>aString</code>. Variables are of the form "${<variable name>}", following the Unix * scripting convention. The values are retrieved from the given map. * * @param aString * the string on which to apply the substitution. * @param variables * a map containg the variable values. The keys are the variable names, the values are the variable values. * @return the string with the substitution applied. */ public static String substituteUnix( String aString, Map<String, String> variables ) { return substitute( aString, variables, UNIX_OPEN, UNIX_CLOSE ); }
/** * Substitutes variables in <code>aString</code>. Variable names are delimited by open and close strings. The values * are retrieved from the given map. * * @param aString * the string on which to apply the substitution. * @param variablesValues * a map containing the variable values. The keys are the variable names, the values are the variable values. * @param open * the open delimiter for variables. * @param close * the close delimiter for variables. * @return the string with the substitution applied. */ public static String substitute( String aString, Map<String, String> variablesValues, String open, String close ) { return substitute( aString, variablesValues, open, close, 0 ); }
value = substitute( (String) value, variablesValues, open, close, ++recursion );
/** * Substitutes field values in <code>aString</code>. Field values are of the form "?{<field name>}". 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. * * @param aString * the string on which to apply the substitution. * @param rowMeta * The row metadata to use. * @param rowData * The row data to use * * @return the string with the substitution applied. * @throws KettleValueException * In case there is a String conversion error */ public static String substituteField( String aString, RowMetaInterface rowMeta, Object[] rowData ) throws KettleValueException { Map<String, String> variables = new HashMap<String, String>(); for ( int i = 0; i < rowMeta.size(); i++ ) { variables.put( rowMeta.getValueMeta( i ).getName(), rowMeta.getString( rowData, i ) ); } return substitute( aString, variables, FIELD_OPEN, FIELD_CLOSE ); }