@Test public void testGetFields() throws KettleStepException { ReplaceStringMeta meta = new ReplaceStringMeta(); meta.setFieldInStream( new String[] { FIELD_NAME } ); meta.setFieldOutStream( new String[] { FIELD_NAME } ); ValueMetaInterface inputFieldMeta = mock( ValueMetaInterface.class ); when( inputFieldMeta.getStringEncoding() ).thenReturn( ENCODING_NAME ); RowMetaInterface inputRowMeta = mock( RowMetaInterface.class ); when( inputRowMeta.searchValueMeta( anyString() ) ).thenReturn( inputFieldMeta ); StepMeta nextStep = mock( StepMeta.class ); VariableSpace space = mock( VariableSpace.class ); Repository repository = mock( Repository.class ); IMetaStore metaStore = mock( IMetaStore.class ); meta.getFields( inputRowMeta, "test", null, nextStep, space, repository, metaStore ); ArgumentCaptor<ValueMetaInterface> argument = ArgumentCaptor.forClass( ValueMetaInterface.class ); verify( inputRowMeta ).addValueMeta( argument.capture() ); assertEquals( ENCODING_NAME, argument.getValue().getStringEncoding() ); }
public void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { int nrFields = fieldInStream == null ? 0 : fieldInStream.length; for ( int i = 0; i < nrFields; i++ ) { String fieldName = space.environmentSubstitute( fieldOutStream[i] ); ValueMetaInterface valueMeta; if ( !Utils.isEmpty( fieldOutStream[i] ) ) { valueMeta = new ValueMetaString( fieldName ); valueMeta.setOrigin( name ); ValueMetaInterface sourceField = inputRowMeta.searchValueMeta( fieldInStream[i] ); if ( sourceField != null ) { valueMeta.setStringEncoding( sourceField.getStringEncoding() ); } inputRowMeta.addValueMeta( valueMeta ); } else { valueMeta = inputRowMeta.searchValueMeta( fieldInStream[i] ); if ( valueMeta == null ) { continue; } valueMeta.setStorageType( ValueMetaInterface.STORAGE_TYPE_NORMAL ); } } }
ReplaceStringMeta extends BaseStepMeta implements StepMetaInterface { public void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { int nrFields = fieldInStream == null ? 0 : fieldInStream.length; for ( int i = 0; i < nrFields; i++ ) { String fieldName = space.environmentSubstitute( fieldOutStream[i] ); ValueMetaInterface valueMeta; if ( !Utils.isEmpty( fieldOutStream[i] ) ) { valueMeta = new ValueMetaString( fieldName ); valueMeta.setOrigin( name ); ValueMetaInterface sourceField = inputRowMeta.searchValueMeta( fieldInStream[i] ); if ( sourceField != null ) { valueMeta.setStringEncoding( sourceField.getStringEncoding() ); } inputRowMeta.addValueMeta( valueMeta ); } else { valueMeta = inputRowMeta.searchValueMeta( fieldInStream[i] ); if ( valueMeta == null ) { continue; } valueMeta.setStorageType( ValueMetaInterface.STORAGE_TYPE_NORMAL ); } } } }
ReplaceStringMeta extends BaseStepMeta implements StepMetaInterface { public void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { int nrFields = fieldInStream == null ? 0 : fieldInStream.length; for ( int i = 0; i < nrFields; i++ ) { String fieldName = space.environmentSubstitute( fieldOutStream[i] ); ValueMetaInterface valueMeta; if ( !Utils.isEmpty( fieldOutStream[i] ) ) { valueMeta = new ValueMetaString( fieldName ); valueMeta.setOrigin( name ); ValueMetaInterface sourceField = inputRowMeta.searchValueMeta( fieldInStream[i] ); if ( sourceField != null ) { valueMeta.setStringEncoding( sourceField.getStringEncoding() ); } inputRowMeta.addValueMeta( valueMeta ); } else { valueMeta = inputRowMeta.searchValueMeta( fieldInStream[i] ); if ( valueMeta == null ) { continue; } valueMeta.setStorageType( ValueMetaInterface.STORAGE_TYPE_NORMAL ); } } } ReplaceStringMeta(); }
ReplaceStringMeta extends BaseStepMeta implements StepMetaInterface { public void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { int nrFields = fieldInStream == null ? 0 : fieldInStream.length; for ( int i = 0; i < nrFields; i++ ) { String fieldName = space.environmentSubstitute( fieldOutStream[i] ); ValueMetaInterface valueMeta; if ( !Utils.isEmpty( fieldOutStream[i] ) ) { valueMeta = new ValueMetaString( fieldName ); valueMeta.setOrigin( name ); ValueMetaInterface sourceField = inputRowMeta.searchValueMeta( fieldInStream[i] ); if ( sourceField != null ) { valueMeta.setStringEncoding( sourceField.getStringEncoding() ); } inputRowMeta.addValueMeta( valueMeta ); } else { valueMeta = inputRowMeta.searchValueMeta( fieldInStream[i] ); if ( valueMeta == null ) { continue; } valueMeta.setStorageType( ValueMetaInterface.STORAGE_TYPE_NORMAL ); } } } ReplaceStringMeta(); String[] getFieldInStream(); void setFieldInStream( String[] keyStream ); int[] getCaseSensitive(); int[] getWholeWord(); void setWholeWord( int[] wholeWord ); int[] getUseRegEx(); void setUseRegEx( int[] useRegEx ); boolean[] isSetEmptyString(); void setEmptyString( boolean[] setEmptyString ); String[] getFieldOutStream(); void setFieldOutStream( String[] keyStream ); String[] getReplaceString(); void setReplaceString( String[] replaceString ); String[] getReplaceByString(); void setReplaceByString( String[] replaceByString ); String[] getFieldReplaceByString(); void setFieldReplaceByString( String[] replaceFieldByString ); void setCaseSensitive( int[] caseSensitive ); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); void allocate( int nrkeys ); Object clone(); void setDefault(); String getXML(); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep,
    VariableSpace space, Repository repository, IMetaStore metaStore ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepinfo,
    RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
    Repository repository, IMetaStore metaStore ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr,
    TransMeta transMeta, Trans trans ); StepDataInterface getStepData(); boolean supportsErrorHandling(); static String getCaseSensitiveDesc( int i ); static String getWholeWordDesc( int i ); static String getUseRegExDesc( int i ); static int getCaseSensitiveByDesc( String tt ); static int getWholeWordByDesc( String tt ); static int getUseRegExByDesc( String tt ); @AfterInjection void afterInjectionSynchronization(); }
ReplaceStringMeta extends BaseStepMeta implements StepMetaInterface { public void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { int nrFields = fieldInStream == null ? 0 : fieldInStream.length; for ( int i = 0; i < nrFields; i++ ) { String fieldName = space.environmentSubstitute( fieldOutStream[i] ); ValueMetaInterface valueMeta; if ( !Utils.isEmpty( fieldOutStream[i] ) ) { valueMeta = new ValueMetaString( fieldName ); valueMeta.setOrigin( name ); ValueMetaInterface sourceField = inputRowMeta.searchValueMeta( fieldInStream[i] ); if ( sourceField != null ) { valueMeta.setStringEncoding( sourceField.getStringEncoding() ); } inputRowMeta.addValueMeta( valueMeta ); } else { valueMeta = inputRowMeta.searchValueMeta( fieldInStream[i] ); if ( valueMeta == null ) { continue; } valueMeta.setStorageType( ValueMetaInterface.STORAGE_TYPE_NORMAL ); } } } ReplaceStringMeta(); String[] getFieldInStream(); void setFieldInStream( String[] keyStream ); int[] getCaseSensitive(); int[] getWholeWord(); void setWholeWord( int[] wholeWord ); int[] getUseRegEx(); void setUseRegEx( int[] useRegEx ); boolean[] isSetEmptyString(); void setEmptyString( boolean[] setEmptyString ); String[] getFieldOutStream(); void setFieldOutStream( String[] keyStream ); String[] getReplaceString(); void setReplaceString( String[] replaceString ); String[] getReplaceByString(); void setReplaceByString( String[] replaceByString ); String[] getFieldReplaceByString(); void setFieldReplaceByString( String[] replaceFieldByString ); void setCaseSensitive( int[] caseSensitive ); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); void allocate( int nrkeys ); Object clone(); void setDefault(); String getXML(); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep,
    VariableSpace space, Repository repository, IMetaStore metaStore ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepinfo,
    RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
    Repository repository, IMetaStore metaStore ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr,
    TransMeta transMeta, Trans trans ); StepDataInterface getStepData(); boolean supportsErrorHandling(); static String getCaseSensitiveDesc( int i ); static String getWholeWordDesc( int i ); static String getUseRegExDesc( int i ); static int getCaseSensitiveByDesc( String tt ); static int getWholeWordByDesc( String tt ); static int getUseRegExByDesc( String tt ); @AfterInjection void afterInjectionSynchronization(); static final String[] caseSensitiveCode; static final String[] caseSensitiveDesc; static final int CASE_SENSITIVE_NO; static final int CASE_SENSITIVE_YES; static final String[] wholeWordDesc; static final String[] wholeWordCode; static final int WHOLE_WORD_NO; static final int WHOLE_WORD_YES; static final String[] useRegExDesc; static final String[] useRegExCode; static final int USE_REGEX_NO; static final int USE_REGEX_YES; }