Java Code Examples for org.pentaho.di.core.row.RowMetaInterface#exists()

The following examples show how to use org.pentaho.di.core.row.RowMetaInterface#exists() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Adds <code>String</code> value meta with given name if not present and returns index
 *
 * @param rowMeta
 * @param fieldName
 * @return Index in row meta of value meta with <code>fieldName</code>
 */
public static int addValueMeta( String stepName, RowMetaInterface rowMeta, String fieldName ) {
  ValueMetaInterface valueMeta = new ValueMetaString( fieldName );
  valueMeta.setOrigin( stepName );
  // add if doesn't exist
  int index = -1;
  if ( !rowMeta.exists( valueMeta ) ) {
    index = rowMeta.size();
    rowMeta.addValueMeta( valueMeta );
  } else {
    index = rowMeta.indexOfValue( fieldName );
  }
  return index;
}
 
Example 2
Source Project: pentaho-kettle   File: TextFileInput.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Adds <code>String</code> value meta with given name if not present and returns index
 *
 * @param rowMeta
 * @param fieldName
 * @return Index in row meta of value meta with <code>fieldName</code>
 */
private int addValueMeta( RowMetaInterface rowMeta, String fieldName ) {
  ValueMetaInterface valueMeta = new ValueMetaString( fieldName );
  valueMeta.setOrigin( getStepname() );
  // add if doesn't exist
  int index = -1;
  if ( !rowMeta.exists( valueMeta ) ) {
    index = rowMeta.size();
    rowMeta.addValueMeta( valueMeta );
  } else {
    index = rowMeta.indexOfValue( fieldName );
  }
  return index;
}
 
Example 3
public void getFields( RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep,
                       VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException {
  if ( StringUtils.isNotBlank( this.getIdOutField() ) ) {
    ValueMetaInterface valueMeta = new ValueMetaString( space.environmentSubstitute( this.getIdOutField() ) );
    valueMeta.setOrigin( name );
    // add if doesn't exist
    if ( !r.exists( valueMeta ) ) {
      r.addValueMeta( valueMeta );
    }
  }
}