@Test public void testGetOneRow() throws Exception { ReplaceStringData data = new ReplaceStringData(); ReplaceString replaceString = new ReplaceString( stepMockHelper.stepMeta, data, 0, stepMockHelper.transMeta, stepMockHelper.trans ); RowMetaInterface inputRowMeta = new RowMeta(); inputRowMeta.addValueMeta( 0, new ValueMetaString( "SomeDataMeta" ) ); inputRowMeta.addValueMeta( 1, new ValueMetaString( "AnotherDataMeta" ) ); replaceString.init( stepMockHelper.processRowsStepMetaInterface, data ); replaceString.setInputRowMeta( inputRowMeta ); data.outputRowMeta = inputRowMeta; data.outputRowMeta.addValueMeta( new ValueMetaString( "AnotherDataMeta" ) ); data.inputFieldsNr = 2; data.numFields = 2; data.inStreamNrs = new int[] { 1, 1 }; data.patterns = new Pattern[] { Pattern.compile( "a" ), Pattern.compile( "t" ) }; data.replaceFieldIndex = new int[] { -1, -1 }; data.outStreamNrs = new String[] { "", "1" }; data.replaceByString = new String[] { "1", "2" }; data.setEmptyString = new boolean[] { false, false }; Object[] output = replaceString.getOneRow( inputRowMeta, row ); assertArrayEquals( "Output varies", expectedRow, output ); }
synchronized Object[] getOneRow( RowMetaInterface rowMeta, Object[] row ) throws KettleException { Object[] rowData = RowDataUtil.resizeArray( row, data.outputRowMeta.size() ); int index = 0; Set<Integer> numFieldsAlreadyBeenTransformed = new HashSet<Integer>(); for ( int i = 0; i < data.numFields; i++ ) { RowMetaInterface currentRowMeta = ( numFieldsAlreadyBeenTransformed.contains( data.inStreamNrs[i] ) ) ? data.outputRowMeta : getInputRowMeta(); String value = replaceString( currentRowMeta.getString( rowData, data.inStreamNrs[i] ), data.patterns[i], getResolvedReplaceByString( i, row ) ); if ( Utils.isEmpty( data.outStreamNrs[i] ) ) { rowData[data.inStreamNrs[i]] = value; numFieldsAlreadyBeenTransformed.add( data.inStreamNrs[i] ); } else { rowData[data.inputFieldsNr + index++] = value; } } return rowData; }
ReplaceString extends BaseStep implements StepInterface { synchronized Object[] getOneRow( RowMetaInterface rowMeta, Object[] row ) throws KettleException { Object[] rowData = RowDataUtil.resizeArray( row, data.outputRowMeta.size() ); int index = 0; Set<Integer> numFieldsAlreadyBeenTransformed = new HashSet<Integer>(); for ( int i = 0; i < data.numFields; i++ ) { RowMetaInterface currentRowMeta = ( numFieldsAlreadyBeenTransformed.contains( data.inStreamNrs[i] ) ) ? data.outputRowMeta : getInputRowMeta(); String value = replaceString( currentRowMeta.getString( rowData, data.inStreamNrs[i] ), data.patterns[i], getResolvedReplaceByString( i, row ) ); if ( Utils.isEmpty( data.outStreamNrs[i] ) ) { rowData[data.inStreamNrs[i]] = value; numFieldsAlreadyBeenTransformed.add( data.inStreamNrs[i] ); } else { rowData[data.inputFieldsNr + index++] = value; } } return rowData; } }
ReplaceString extends BaseStep implements StepInterface { synchronized Object[] getOneRow( RowMetaInterface rowMeta, Object[] row ) throws KettleException { Object[] rowData = RowDataUtil.resizeArray( row, data.outputRowMeta.size() ); int index = 0; Set<Integer> numFieldsAlreadyBeenTransformed = new HashSet<Integer>(); for ( int i = 0; i < data.numFields; i++ ) { RowMetaInterface currentRowMeta = ( numFieldsAlreadyBeenTransformed.contains( data.inStreamNrs[i] ) ) ? data.outputRowMeta : getInputRowMeta(); String value = replaceString( currentRowMeta.getString( rowData, data.inStreamNrs[i] ), data.patterns[i], getResolvedReplaceByString( i, row ) ); if ( Utils.isEmpty( data.outStreamNrs[i] ) ) { rowData[data.inStreamNrs[i]] = value; numFieldsAlreadyBeenTransformed.add( data.inStreamNrs[i] ); } else { rowData[data.inputFieldsNr + index++] = value; } } return rowData; } ReplaceString( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
    Trans trans ); }
ReplaceString extends BaseStep implements StepInterface { synchronized Object[] getOneRow( RowMetaInterface rowMeta, Object[] row ) throws KettleException { Object[] rowData = RowDataUtil.resizeArray( row, data.outputRowMeta.size() ); int index = 0; Set<Integer> numFieldsAlreadyBeenTransformed = new HashSet<Integer>(); for ( int i = 0; i < data.numFields; i++ ) { RowMetaInterface currentRowMeta = ( numFieldsAlreadyBeenTransformed.contains( data.inStreamNrs[i] ) ) ? data.outputRowMeta : getInputRowMeta(); String value = replaceString( currentRowMeta.getString( rowData, data.inStreamNrs[i] ), data.patterns[i], getResolvedReplaceByString( i, row ) ); if ( Utils.isEmpty( data.outStreamNrs[i] ) ) { rowData[data.inStreamNrs[i]] = value; numFieldsAlreadyBeenTransformed.add( data.inStreamNrs[i] ); } else { rowData[data.inputFieldsNr + index++] = value; } } return rowData; } ReplaceString( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
    Trans trans ); static String replaceString( String originalString, Pattern pattern, String replaceByString ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); }
ReplaceString extends BaseStep implements StepInterface { synchronized Object[] getOneRow( RowMetaInterface rowMeta, Object[] row ) throws KettleException { Object[] rowData = RowDataUtil.resizeArray( row, data.outputRowMeta.size() ); int index = 0; Set<Integer> numFieldsAlreadyBeenTransformed = new HashSet<Integer>(); for ( int i = 0; i < data.numFields; i++ ) { RowMetaInterface currentRowMeta = ( numFieldsAlreadyBeenTransformed.contains( data.inStreamNrs[i] ) ) ? data.outputRowMeta : getInputRowMeta(); String value = replaceString( currentRowMeta.getString( rowData, data.inStreamNrs[i] ), data.patterns[i], getResolvedReplaceByString( i, row ) ); if ( Utils.isEmpty( data.outStreamNrs[i] ) ) { rowData[data.inStreamNrs[i]] = value; numFieldsAlreadyBeenTransformed.add( data.inStreamNrs[i] ); } else { rowData[data.inputFieldsNr + index++] = value; } } return rowData; } ReplaceString( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
    Trans trans ); static String replaceString( String originalString, Pattern pattern, String replaceByString ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi );  }