@Test public void testFieldSubstitution() throws KettleValueException { Object[] rowData = new Object[]{ "DataOne", "DataTwo" }; RowMeta rm = new RowMeta(); rm.addValueMeta( new ValueMetaString( "FieldOne" ) ); rm.addValueMeta( new ValueMetaString( "FieldTwo" ) ); Variables vars = new Variables(); assertNull( vars.fieldSubstitute( null, rm, rowData ) ); assertEquals( "", vars.fieldSubstitute( "", rm, rowData ) ); assertEquals( "DataOne", vars.fieldSubstitute( "?{FieldOne}", rm, rowData ) ); assertEquals( "TheDataOne", vars.fieldSubstitute( "The?{FieldOne}", rm, rowData ) ); }
@Override public String fieldSubstitute( String aString, RowMetaInterface rowMeta, Object[] rowData ) throws KettleValueException { if ( aString == null || aString.length() == 0 ) { return aString; } return StringUtil.substituteField( aString, rowMeta, rowData ); }
Variables implements VariableSpace { @Override public String fieldSubstitute( String aString, RowMetaInterface rowMeta, Object[] rowData ) throws KettleValueException { if ( aString == null || aString.length() == 0 ) { return aString; } return StringUtil.substituteField( aString, rowMeta, rowData ); } }
Variables implements VariableSpace { @Override public String fieldSubstitute( String aString, RowMetaInterface rowMeta, Object[] rowData ) throws KettleValueException { if ( aString == null || aString.length() == 0 ) { return aString; } return StringUtil.substituteField( aString, rowMeta, rowData ); } Variables(); }
Variables implements VariableSpace { @Override public String fieldSubstitute( String aString, RowMetaInterface rowMeta, Object[] rowData ) throws KettleValueException { if ( aString == null || aString.length() == 0 ) { return aString; } return StringUtil.substituteField( aString, rowMeta, rowData ); } Variables(); @Override void copyVariablesFrom( VariableSpace space ); @Override VariableSpace getParentVariableSpace(); @Override void setParentVariableSpace( VariableSpace parent ); @Override String getVariable( String variableName, String defaultValue ); @Override String getVariable( String variableName ); @Override boolean getBooleanValueOfVariable( String variableName, boolean defaultValue ); @Override void initializeVariablesFrom( VariableSpace parent ); @Override String[] listVariables(); @Override void setVariable( String variableName, String variableValue ); @Override String environmentSubstitute( String aString ); @Override String fieldSubstitute( String aString, RowMetaInterface rowMeta, Object[] rowData ); @Override String[] environmentSubstitute( String[] string ); @Override void shareVariablesWith( VariableSpace space ); @Override void injectVariables( Map<String, String> prop ); static synchronized VariableSpace getADefaultVariableSpace(); }
Variables implements VariableSpace { @Override public String fieldSubstitute( String aString, RowMetaInterface rowMeta, Object[] rowData ) throws KettleValueException { if ( aString == null || aString.length() == 0 ) { return aString; } return StringUtil.substituteField( aString, rowMeta, rowData ); } Variables(); @Override void copyVariablesFrom( VariableSpace space ); @Override VariableSpace getParentVariableSpace(); @Override void setParentVariableSpace( VariableSpace parent ); @Override String getVariable( String variableName, String defaultValue ); @Override String getVariable( String variableName ); @Override boolean getBooleanValueOfVariable( String variableName, boolean defaultValue ); @Override void initializeVariablesFrom( VariableSpace parent ); @Override String[] listVariables(); @Override void setVariable( String variableName, String variableValue ); @Override String environmentSubstitute( String aString ); @Override String fieldSubstitute( String aString, RowMetaInterface rowMeta, Object[] rowData ); @Override String[] environmentSubstitute( String[] string ); @Override void shareVariablesWith( VariableSpace space ); @Override void injectVariables( Map<String, String> prop ); static synchronized VariableSpace getADefaultVariableSpace();  }