plugins/transforms/selectvalues/src/main/java/org/apache/hop/pipeline/transforms/selectvalues/SelectValues.java
@VisibleForTesting
  synchronized Object[] metadataValues( IRowMeta rowMeta, Object[] rowData ) throws HopException {
    if ( data.firstmetadata ) {
      data.firstmetadata = false;

      data.metanrs = new int[ meta.getMeta().length ];
      for ( int i = 0; i < data.metanrs.length; i++ ) {
        data.metanrs[ i ] = rowMeta.indexOfValue( meta.getMeta()[ i ].getName() );
        if ( data.metanrs[ i ] < 0 ) {
          logError( BaseMessages
            .getString( PKG, "SelectValues.Log.CouldNotFindField", meta.getMeta()[ i ].getName() ) );
          setErrors( 1 );
          stopAll();
          return null;
        }
      }

      // Check for doubles in the selected fields...
      int[] cnt = new int[ meta.getMeta().length ];
      for ( int i = 0; i < meta.getMeta().length; i++ ) {
        cnt[ i ] = 0;
        for ( int j = 0; j < meta.getMeta().length; j++ ) {
          if ( meta.getMeta()[ i ].getName().equals( meta.getMeta()[ j ].getName() ) ) {
            cnt[ i ]++;
          }

          if ( cnt[ i ] > 1 ) {
            logError( BaseMessages.getString( PKG, "SelectValues.Log.FieldCouldNotSpecifiedMoreThanTwice2", meta
              .getMeta()[ i ].getName() ) );
            setErrors( 1 );
            stopAll();
            return null;
          }
        }
      }

      // Also apply the metadata on the row meta to allow us to convert the data correctly, with the correct mask.
      //
      for ( int i = 0; i < data.metanrs.length; i++ ) {
        SelectMetadataChange change = meta.getMeta()[ i ];
        IValueMeta valueMeta = rowMeta.getValueMeta( data.metanrs[ i ] );
        if ( !Utils.isEmpty( change.getConversionMask() ) ) {
          valueMeta.setConversionMask( change.getConversionMask() );
        }

        valueMeta.setDateFormatLenient( change.isDateFormatLenient() );
        valueMeta.setDateFormatLocale( EnvUtil.createLocale( change.getDateFormatLocale() ) );
        valueMeta.setDateFormatTimeZone( EnvUtil.createTimeZone( change.getDateFormatTimeZone() ) );
        valueMeta.setLenientStringToNumber( change.isLenientStringToNumber() );

        if ( !Utils.isEmpty( change.getEncoding() ) ) {
          valueMeta.setStringEncoding( change.getEncoding() );
        }
        if ( !Utils.isEmpty( change.getDecimalSymbol() ) ) {
          valueMeta.setDecimalSymbol( change.getDecimalSymbol() );
        }
        if ( !Utils.isEmpty( change.getGroupingSymbol() ) ) {
          valueMeta.setGroupingSymbol( change.getGroupingSymbol() );
        }
        if ( !Utils.isEmpty( change.getCurrencySymbol() ) ) {
          valueMeta.setCurrencySymbol( change.getCurrencySymbol() );
        }
      }
    }

    //
    // Change the data too
    //
    for ( int i = 0; i < data.metanrs.length; i++ ) {
      int index = data.metanrs[ i ];
      IValueMeta fromMeta = rowMeta.getValueMeta( index );
      IValueMeta toMeta = data.metadataRowMeta.getValueMeta( index );

      // If we need to change from BINARY_STRING storage type to NORMAL...
      //
      try {
        if ( fromMeta.isStorageBinaryString()
          && meta.getMeta()[ i ].getStorageType() == IValueMeta.STORAGE_TYPE_NORMAL ) {
          rowData[ index ] = fromMeta.convertBinaryStringToNativeType( (byte[]) rowData[ index ] );
        }
        if ( meta.getMeta()[ i ].getType() != IValueMeta.TYPE_NONE && fromMeta.getType() != toMeta.getType() ) {
          rowData[ index ] = toMeta.convertData( fromMeta, rowData[ index ] );
        }
      } catch ( HopValueException e ) {
        throw new HopConversionException( e.getMessage(), Collections.<Exception>singletonList( e ),
          Collections.singletonList( toMeta ), rowData );
      }
    }

    return rowData;
  }
/**
   * Change the meta-data of certain fields.
   * <p/>
   * This, we can do VERY fast.
   * <p/>
   *
   * @param rowMeta The row metadata to change
   * @param rowData the row data to change
   * @return the altered RowData array
   * @throws HopValueException
   */
Change the meta-data of certain fields.

This, we can do VERY fast.

@param rowMeta The row metadata to change
@param rowData the row data to change
@return the altered RowData array
@throws HopValueException
Change the meta - data of certain fields . This we can do VERY fast . @param rowMeta The row metadata to change @param rowData the row data to change @return the altered RowData array @throws HopValueException
@VisibleForTesting
  synchronized Object[] metadataValues( IRowMeta rowMeta, Object[] rowData ) throws HopException {
    if ( data.firstmetadata ) {
      data.firstmetadata = false;
      data.metanrs = new int[ meta.getMeta().length ];
      for ( int i = 0; i < data.metanrs.length; i++ ) {
        data.metanrs[ i ] = rowMeta.indexOfValue( meta.getMeta()[ i ].getName() );
        if ( data.metanrs[ i ] < 0 ) {
          logError( BaseMessages
            .getString( PKG, "SelectValues.Log.CouldNotFindField", meta.getMeta()[ i ].getName() ) );
          setErrors( 1 );
          stopAll();
          return null;
        }
      }
      int[] cnt = new int[ meta.getMeta().length ];
      for ( int i = 0; i < meta.getMeta().length; i++ ) {
        cnt[ i ] = 0;
        for ( int j = 0; j < meta.getMeta().length; j++ ) {
          if ( meta.getMeta()[ i ].getName().equals( meta.getMeta()[ j ].getName() ) ) {
            cnt[ i ]++;
          }
          if ( cnt[ i ] > 1 ) {
            logError( BaseMessages.getString( PKG, "SelectValues.Log.FieldCouldNotSpecifiedMoreThanTwice2", meta
              .getMeta()[ i ].getName() ) );
            setErrors( 1 );
            stopAll();
            return null;
          }
        }
      }
      for ( int i = 0; i < data.metanrs.length; i++ ) {
        SelectMetadataChange change = meta.getMeta()[ i ];
        IValueMeta valueMeta = rowMeta.getValueMeta( data.metanrs[ i ] );
        if ( !Utils.isEmpty( change.getConversionMask() ) ) {
          valueMeta.setConversionMask( change.getConversionMask() );
        }
        valueMeta.setDateFormatLenient( change.isDateFormatLenient() );
        valueMeta.setDateFormatLocale( EnvUtil.createLocale( change.getDateFormatLocale() ) );
        valueMeta.setDateFormatTimeZone( EnvUtil.createTimeZone( change.getDateFormatTimeZone() ) );
        valueMeta.setLenientStringToNumber( change.isLenientStringToNumber() );
        if ( !Utils.isEmpty( change.getEncoding() ) ) {
          valueMeta.setStringEncoding( change.getEncoding() );
        }
        if ( !Utils.isEmpty( change.getDecimalSymbol() ) ) {
          valueMeta.setDecimalSymbol( change.getDecimalSymbol() );
        }
        if ( !Utils.isEmpty( change.getGroupingSymbol() ) ) {
          valueMeta.setGroupingSymbol( change.getGroupingSymbol() );
        }
        if ( !Utils.isEmpty( change.getCurrencySymbol() ) ) {
          valueMeta.setCurrencySymbol( change.getCurrencySymbol() );
        }
      }
    }
     Change the data too
    for ( int i = 0; i < data.metanrs.length; i++ ) {
      int index = data.metanrs[ i ];
      IValueMeta fromMeta = rowMeta.getValueMeta( index );
      IValueMeta toMeta = data.metadataRowMeta.getValueMeta( index );
       If we need to change from BINARY_STRING storage type to NORMAL...
      try {
        if ( fromMeta.isStorageBinaryString()
          && meta.getMeta()[ i ].getStorageType() == IValueMeta.STORAGE_TYPE_NORMAL ) {
          rowData[ index ] = fromMeta.convertBinaryStringToNativeType( (byte[]) rowData[ index ] );
        }
        if ( meta.getMeta()[ i ].getType() != IValueMeta.TYPE_NONE && fromMeta.getType() != toMeta.getType() ) {
          rowData[ index ] = toMeta.convertData( fromMeta, rowData[ index ] );
        }
      } catch ( HopValueException e ) {
        throw new HopConversionException( e.getMessage(), Collections.<Exception>singletonList( e ),
          Collections.singletonList( toMeta ), rowData );
      }
    }
    return rowData;
  }
@ VisibleForTesting synchronized Object [ ] metadataValues ( IRowMeta rowMeta , Object [ ] rowData ) throws HopException { if ( data . firstmetadata ) { data . firstmetadata = false ; data . metanrs = new int [ meta . getMeta ( ) . length ] ; for ( int i = 0 ; i < data . metanrs . length ; i ++ ) { data . metanrs [ i ] = rowMeta . indexOfValue ( meta . getMeta ( ) [ i ] . getName ( ) ) ; if ( data . metanrs [ i ] < 0 ) { logError ( BaseMessages . getString ( PKG , "SelectValues.Log.CouldNotFindField" , meta . getMeta ( ) [ i ] . getName ( ) ) ) ; setErrors ( 1 ) ; stopAll ( ) ; return null ; } } int [ ] cnt = new int [ meta . getMeta ( ) . length ] ; for ( int i = 0 ; i < meta . getMeta ( ) . length ; i ++ ) { cnt [ i ] = 0 ; for ( int j = 0 ; j < meta . getMeta ( ) . length ; j ++ ) { if ( meta . getMeta ( ) [ i ] . getName ( ) . equals ( meta . getMeta ( ) [ j ] . getName ( ) ) ) { cnt [ i ] ++ ; } if ( cnt [ i ] > 1 ) { logError ( BaseMessages . getString ( PKG , "SelectValues.Log.FieldCouldNotSpecifiedMoreThanTwice2" , meta . getMeta ( ) [ i ] . getName ( ) ) ) ; setErrors ( 1 ) ; stopAll ( ) ; return null ; } } } for ( int i = 0 ; i < data . metanrs . length ; i ++ ) { SelectMetadataChange change = meta . getMeta ( ) [ i ] ; IValueMeta valueMeta = rowMeta . getValueMeta ( data . metanrs [ i ] ) ; if ( ! Utils . isEmpty ( change . getConversionMask ( ) ) ) { valueMeta . setConversionMask ( change . getConversionMask ( ) ) ; } valueMeta . setDateFormatLenient ( change . isDateFormatLenient ( ) ) ; valueMeta . setDateFormatLocale ( EnvUtil . createLocale ( change . getDateFormatLocale ( ) ) ) ; valueMeta . setDateFormatTimeZone ( EnvUtil . createTimeZone ( change . getDateFormatTimeZone ( ) ) ) ; valueMeta . setLenientStringToNumber ( change . isLenientStringToNumber ( ) ) ; if ( ! Utils . isEmpty ( change . getEncoding ( ) ) ) { valueMeta . setStringEncoding ( change . getEncoding ( ) ) ; } if ( ! Utils . isEmpty ( change . getDecimalSymbol ( ) ) ) { valueMeta . setDecimalSymbol ( change . getDecimalSymbol ( ) ) ; } if ( ! Utils . isEmpty ( change . getGroupingSymbol ( ) ) ) { valueMeta . setGroupingSymbol ( change . getGroupingSymbol ( ) ) ; } if ( ! Utils . isEmpty ( change . getCurrencySymbol ( ) ) ) { valueMeta . setCurrencySymbol ( change . getCurrencySymbol ( ) ) ; } } } for ( int i = 0 ; i < data . metanrs . length ; i ++ ) { int index = data . metanrs [ i ] ; IValueMeta fromMeta = rowMeta . getValueMeta ( index ) ; IValueMeta toMeta = data . metadataRowMeta . getValueMeta ( index ) ; try { if ( fromMeta . isStorageBinaryString ( ) && meta . getMeta ( ) [ i ] . getStorageType ( ) == IValueMeta . STORAGE_TYPE_NORMAL ) { rowData [ index ] = fromMeta . convertBinaryStringToNativeType ( ( byte [ ] ) rowData [ index ] ) ; } if ( meta . getMeta ( ) [ i ] . getType ( ) != IValueMeta . TYPE_NONE && fromMeta . getType ( ) != toMeta . getType ( ) ) { rowData [ index ] = toMeta . convertData ( fromMeta , rowData [ index ] ) ; } } catch ( HopValueException e ) { throw new HopConversionException ( e . getMessage ( ) , Collections . < Exception > singletonList ( e ) , Collections . singletonList ( toMeta ) , rowData ) ; } } return rowData ; }
Change the meta-data of certain fields.
Change the meta - data of certain fields .
// Check for doubles in the selected fields... // Also apply the metadata on the row meta to allow us to convert the data correctly, with the correct mask. // // // Change the data too // // If we need to change from BINARY_STRING storage type to NORMAL... //