Java Code Examples for org.pentaho.di.core.row.ValueMetaInterface#TRIM_TYPE_RIGHT

The following examples show how to use org.pentaho.di.core.row.ValueMetaInterface#TRIM_TYPE_RIGHT . 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
Source File: BaseFileField.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void guessTrimType() {
  boolean spaces_before = false;
  boolean spaces_after = false;

  for ( int i = 0; i < samples.length; i++ ) {
    spaces_before |= Const.nrSpacesBefore( samples[i] ) > 0;
    spaces_after |= Const.nrSpacesAfter( samples[i] ) > 0;
    samples[i] = Const.trim( samples[i] );
  }

  trimtype = ValueMetaInterface.TRIM_TYPE_NONE;

  if ( spaces_before ) {
    trimtype |= ValueMetaInterface.TRIM_TYPE_LEFT;
  }
  if ( spaces_after ) {
    trimtype |= ValueMetaInterface.TRIM_TYPE_RIGHT;
  }
}
 
Example 2
Source File: TextFileInputField.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void guessTrimType() {
  boolean spaces_before = false;
  boolean spaces_after = false;

  for ( int i = 0; i < samples.length; i++ ) {
    spaces_before |= Const.nrSpacesBefore( samples[i] ) > 0;
    spaces_after |= Const.nrSpacesAfter( samples[i] ) > 0;
    samples[i] = Const.trim( samples[i] );
  }

  trimtype = ValueMetaInterface.TRIM_TYPE_NONE;

  if ( spaces_before ) {
    trimtype |= ValueMetaInterface.TRIM_TYPE_LEFT;
  }
  if ( spaces_after ) {
    trimtype |= ValueMetaInterface.TRIM_TYPE_RIGHT;
  }
}
 
Example 3
Source File: Const.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Return the input string trimmed as specified.
 *
 * @param string
 *          String to be trimmed
 * @param trimType
 *          Type of trimming
 *
 * @return Trimmed string.
 */
public static String trimToType( String string, int trimType ) {
  switch ( trimType ) {
    case ValueMetaInterface.TRIM_TYPE_BOTH:
      return trim( string );
    case ValueMetaInterface.TRIM_TYPE_LEFT:
      return ltrim( string );
    case ValueMetaInterface.TRIM_TYPE_RIGHT:
      return rtrim( string );
    case ValueMetaInterface.TRIM_TYPE_NONE:
    default:
      return string;
  }
}