Java Code Examples for org.pentaho.di.core.util.StringUtil

The following examples show how to use org.pentaho.di.core.util.StringUtil. These examples are extracted from open source projects. 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 Project: pentaho-pdi-dataset   Source File: ExecuteTestsDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void ok() {
  if ( StringUtil.isEmpty( wStepname.getText() ) ) {
    return;
  }

  stepname = wStepname.getText(); // return value

  input.setChanged();

  input.setTestNameInputField( wTestNameInputField.getText() );
  input.setTypeToExecute( DataSetConst.getTestTypeForDescription( wTypeToExecute.getText() ) );
  input.setTransformationNameField( wTransformationNameField.getText() );
  input.setUnitTestNameField( wUnitTestNameField.getText() );
  input.setDataSetNameField( wDataSetNameField.getText() );
  input.setStepNameField( wStepNameField.getText() );
  input.setErrorField( wErrorField.getText() );
  input.setCommentField( wCommentField.getText() );

  dispose();
}
 
Example 2
@Override
public void callExtensionPoint( LogChannelInterface log, Object object ) throws KettleException {
  if ( !( object instanceof TransMeta ) ) {
    return;
  }

  TransMeta transMeta = (TransMeta) object;

  TransUnitTest unitTest = DataSetHelper.getCurrentUnitTest( transMeta );
  if ( unitTest == null ) {
    return;
  }

  String unitTestName = unitTest.getName();

  if ( !StringUtil.isEmpty( unitTestName ) ) {
    // We're running in Spoon and there's a unit test selected : test it
    //
    transMeta.setVariable( DataSetConst.VAR_RUN_UNIT_TEST, "Y" );
    transMeta.setVariable( DataSetConst.VAR_UNIT_TEST_NAME, unitTestName );
  }
}
 
Example 3
Source Project: pentaho-pdi-dataset   Source File: DataSetHelper.java    License: Apache License 2.0 6 votes vote down vote up
public static String validateDataSet( DataSet dataSet, String previousName, List<String> setNames ) {

    String message = null;

    String newName = dataSet.getName();
    if ( StringUtil.isEmpty( newName ) ) {
      message = BaseMessages.getString( PKG, "DataSetHelper.DataSet.NoNameSpecified.Message" );
    } else if ( !StringUtil.isEmpty( previousName ) && !previousName.equals( newName ) ) {
      message = BaseMessages.getString( PKG, "DataSetHelper.DataSet.RenamingOfADataSetsNotSupported.Message" );
    } else if ( dataSet.getGroup() == null ) {
      message = BaseMessages.getString( PKG, "DataSetHelper.DataSet.NoGroupSpecified.Message" );
    } else {
      if ( StringUtil.isEmpty( previousName ) && Const.indexOfString( newName, setNames ) >= 0 ) {
        message = BaseMessages.getString( PKG, "DataSetHelper.DataSet.ADataSetWithNameExists.Message", newName );
      }
    }

    return message;
  }
 
Example 4
Source Project: pentaho-kettle   Source File: JobEntryExportRepository.java    License: Apache License 2.0 6 votes vote down vote up
public String buildUniqueFilename( String filename ) {
  String retval = "";
  if ( Utils.isEmpty( filename ) ) {
    return null;
  }

  int lenstring = filename.length();
  int lastindexOfDot = filename.lastIndexOf( '.' );
  if ( lastindexOfDot == -1 ) {
    lastindexOfDot = lenstring;
  }
  retval = filename.substring( 0, lastindexOfDot );
  retval += StringUtil.getFormattedDateTimeNow();
  retval += filename.substring( lastindexOfDot, lenstring );

  return retval;
}
 
Example 5
Source Project: pentaho-kettle   Source File: HTTPPOST.java    License: Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
String getRequestBodyParamsAsStr( NameValuePair[] pairs, String charset ) throws KettleException {
  StringBuffer buf = new StringBuffer();
  try {
    for ( int i = 0; i < pairs.length; ++i ) {
      NameValuePair pair = pairs[ i ];
      if ( pair.getName() != null ) {
        if ( i > 0 ) {
          buf.append( "&" );
        }

        buf.append( URLEncoder.encode( pair.getName(), !StringUtil.isEmpty( charset ) ? charset : DEFAULT_ENCODING ) );
        buf.append( "=" );
        if ( pair.getValue() != null ) {
          buf.append( URLEncoder.encode( pair.getValue(), !StringUtil.isEmpty( charset ) ? charset : DEFAULT_ENCODING ) );
        }
      }
    }
    return buf.toString();
  } catch ( UnsupportedEncodingException e ) {
    throw new KettleException( e.getMessage(), e.getCause() );
  }
}
 
Example 6
Source Project: pentaho-kettle   Source File: VFSFileSelection.java    License: Apache License 2.0 6 votes vote down vote up
private Optional<String> promptForFile() {
  String curFile = abstractMeta.environmentSubstitute( wFileName.getText() );
  FileObject root;

  try {
    root = KettleVFS.getFileObject( curFile != null ? curFile : Const.getUserHomeDirectory() );
    VfsFileChooserDialog vfsFileChooser = Spoon.getInstance().getVfsFileChooserDialog( root.getParent(), root );
    if ( StringUtil.isEmpty( initialScheme ) ) {
      initialScheme = "file";
    }
    FileObject file = vfsFileChooser.open( getShell(), null, initialScheme, true, curFile, fileFilters, fileFilterNames, false,
      fileDialogMode, showLocation, true );
    if ( file == null ) {
      return Optional.empty();
    }

    String filePath = getRelativePath( file.getName().toString() );
    return Optional.ofNullable( filePath );
  } catch ( IOException | KettleException e ) {
    new ErrorDialog( getShell(),
      BaseMessages.getString( PKG, "VFSFileSelection.ErrorLoadingFile.DialogTitle" ),
      BaseMessages.getString( PKG, "VFSFileSelection.ErrorLoadingFile.DialogMessage" ), e );
  }
  return Optional.empty();
}
 
Example 7
Source Project: pentaho-kettle   Source File: LogMessage.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @return The formatted message.
 */
@Override
public String getMessage() {
  String formatted = message;
  if ( arguments != null ) {
    // get all "tokens" enclosed by curly brackets within the message
    final List<String> tokens = new ArrayList<>();
    StringUtil.getUsedVariables( formatted, "{", "}", tokens, true );
    // perform MessageFormat.format( ... ) on each token, if we get an exception, we'll know that we have a
    // segment that isn't parsable by MessageFormat, likely a pdi variable name (${foo}) - in this case, we need to
    // escape the curly brackets in the message, so that MessageFormat does not complain
    for ( final String token : tokens ) {
      try {
        MessageFormat.format( "{" + token + "}", arguments );
      } catch ( final IllegalArgumentException iar ) {
        formatted = formatted.replaceAll( "\\{" + token + "\\}",  "\\'{'" + token + "\\'}'" );
      }
    }
    // now that we have escaped curly brackets in all invalid tokens, we can attempt to format the entire message
    formatted = MessageFormat.format( formatted, arguments );
  }
  return formatted;
}
 
Example 8
@Test
public void onlyValidExtraOptions_AreAppendedToUrl() {
  Map<String, String> extraOptions = generateExtraOptions( CONN_TYPE_MSSQL, 1 );
  extraOptions.put( STRING_DEFAULT, STRING_DEFAULT );
  extraOptions.put( CONN_TYPE_MSSQL + "." + "key1", StringUtil.EMPTY_STRING );
  extraOptions.put( CONN_TYPE_MSSQL + "." + "key2", DatabaseMeta.EMPTY_OPTIONS_STRING );

  String expectedExtraOptionsUrl =
    STRING_EXTRA_OPTION + 0 + mssqlServerDatabaseMeta.getExtraOptionValueSeparator() + STRING_OPTION_VALUE + 0;
  String expectedUrl =
    CONN_URL_NO_EXTRA_OPTIONS + mssqlServerDatabaseMeta.getExtraOptionSeparator() + expectedExtraOptionsUrl;


  String connUrlWithExtraOptions = meta.appendExtraOptions( CONN_URL_NO_EXTRA_OPTIONS, extraOptions );
  assertEquals( expectedUrl, connUrlWithExtraOptions );
}
 
Example 9
@Override public void callExtensionPoint( LogChannelInterface logChannelInterface, Object o ) throws KettleException {
  JobMeta jobMeta = (JobMeta) ( (Object[]) o )[ 0 ];
  final EmbeddedMetaStore embeddedMetaStore = jobMeta.getEmbeddedMetaStore();

  RunConfigurationManager embeddedRunConfigurationManager =
    EmbeddedRunConfigurationManager.build( embeddedMetaStore );
  embeddedRunConfigurationManager.deleteAll();

  List<String> runConfigurationNames = new ArrayList<>();
  boolean embedAll = false;
  for ( JobEntryCopy jobEntryCopy : jobMeta.getJobCopies() ) {
    if ( jobEntryCopy.getEntry() instanceof JobEntryRunConfigurableInterface ) {
      String usedConfiguration = ( (JobEntryRunConfigurableInterface) jobEntryCopy.getEntry() ).getRunConfiguration();
      embedAll = embedAll || StringUtil.isVariable( usedConfiguration );
      if ( !Utils.isEmpty( usedConfiguration ) && !runConfigurationNames.contains( usedConfiguration ) ) {
        runConfigurationNames.add( usedConfiguration );
      }
    }
  }

  if ( embedAll ) {
    embedAllRunConfigurations( embeddedRunConfigurationManager );
  } else {
    embedRunConfigurations( embeddedRunConfigurationManager, runConfigurationNames );
  }
}
 
Example 10
Source Project: pentaho-kettle   Source File: MQTTClientBuilderTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testEmptyClientId() throws MqttException {
  builder
    .withClientId( "asdf" )
    .buildAndConnect();
  assertEquals( "asdf", clientIdCapture.getValue() );

  builder
    .withClientId( null )
    .buildAndConnect();
  assertFalse( StringUtil.isEmpty( clientIdCapture.getValue() ) );
  assertNotEquals( "asdf", clientIdCapture.getValue() );

  builder
    .withClientId( "" )
    .buildAndConnect();
  assertFalse( StringUtil.isEmpty( clientIdCapture.getValue() ) );
  assertNotEquals( "asdf", clientIdCapture.getValue() );
}
 
Example 11
Source Project: pentaho-pdi-dataset   Source File: DataSetDatabaseGroup.java    License: Apache License 2.0 5 votes vote down vote up
public static final void writeDataSetData( LoggingObjectInterface loggingObject, DataSetGroup dataSetGroup, String tableName,
                                           RowMetaInterface rowMeta, List<Object[]> rows ) throws KettleException {

  Database database = new Database( loggingObject, dataSetGroup.getDatabaseMeta() );
  try {
    database.connect();

    String schemaTable = dataSetGroup.getDatabaseMeta().getQuotedSchemaTableCombination( dataSetGroup.getSchemaName(), tableName );

    String sql;
    if ( database.checkTableExists( schemaTable ) ) {
      // Clean out old junk, allow for rollback
      //
      database.truncateTable( schemaTable );
      sql = database.getAlterTableStatement( schemaTable, rowMeta, null, false, null, true );
    } else {
      sql = database.getCreateTableStatement( schemaTable, rowMeta, null, false, null, true );
    }
    if ( !StringUtil.isEmpty( sql ) ) {
      database.execStatements( sql );
    }
    database.prepareInsert( rowMeta, schemaTable );
    for ( Object[] row : rows ) {
      database.setValuesInsert( new RowMetaAndData( rowMeta, row ) );
      database.insertRow();
    }

    database.commit();
  } finally {
    database.disconnect();
  }

}
 
Example 12
Source Project: pentaho-pdi-dataset   Source File: DataSetDialog.java    License: Apache License 2.0 5 votes vote down vote up
private void verifySettings() throws KettleException {
  DataSetGroup group = DataSetConst.findDataSetGroup( groups, wDataSetGroup.getText() );

  if ( group == null ) {
    throw new KettleException( BaseMessages.getString( PKG, "DataSetDialog.Error.NoGroupSpecified" ) );
  }
  if ( StringUtil.isEmpty( wTableName.getText() ) ) {
    throw new KettleException( BaseMessages.getString( PKG, "DataSetDialog.Error.NoTableSpecified" ) );
  }
  group.verifySettings();

}
 
Example 13
Source Project: pentaho-pdi-dataset   Source File: DataSetDialog.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Look at the metadata specified here and create the table accordingly...
 * - Create a table for the Database Group type
 * - Create a metadata file for the CSV group type
 */
protected void createTable() {
  try {
    verifySettings();

    DataSet set = new DataSet();
    getInfo( set );
    DataSetGroup group = set.getGroup();

    String tableName = wTableName.getText();

    // Calculate the row metadata of the table
    //
    RowMetaInterface rowMeta = new RowMeta();
    int nrFields = wFieldMapping.nrNonEmpty();
    for ( int i = 0; i < nrFields; i++ ) {
      TableItem item = wFieldMapping.getNonEmpty( i );
      int colnr = 2;
      String columnName = item.getText( colnr++ );
      if ( StringUtil.isEmpty( columnName ) ) {
        throw new KettleException( BaseMessages.getString( PKG, "DataSetDialog.Error.NoColumnName", Integer.toString( i ) ) );
      }
      int fieldType = ValueMetaFactory.getIdForValueMeta( item.getText( colnr++ ) );
      if ( fieldType == ValueMetaInterface.TYPE_NONE ) {
        throw new KettleException( BaseMessages.getString( PKG, "DataSetDialog.Error.NoDataType", Integer.toString( i ) ) );
      }
      int length = Const.toInt( item.getText( colnr++ ), -1 );
      int precision = Const.toInt( item.getText( colnr++ ), -1 );

      ValueMetaInterface valueMeta = ValueMetaFactory.createValueMeta( columnName, fieldType, length, precision );
      rowMeta.addValueMeta( valueMeta );
    }

    group.createTable( tableName, rowMeta );

  } catch ( Exception e ) {
    new ErrorDialog( shell, "Error", "Error retrieving metadata from dataset table", e );
  }

}
 
Example 14
Source Project: pentaho-pdi-dataset   Source File: DataSetHelper.java    License: Apache License 2.0 5 votes vote down vote up
private String validateDataSetGroup( DataSetGroup dataSetGroup, String previousName, List<String> groupNames ) {

    String message = null;

    String newName = dataSetGroup.getName();
    if ( StringUtil.isEmpty( newName ) ) {
      message = BaseMessages.getString( PKG, "DataSetHelper.DataSetGroup.NoNameSpecified.Message" );
    } else if ( !StringUtil.isEmpty( previousName ) && !previousName.equals( newName ) ) {
      message = BaseMessages.getString( PKG, "DataSetHelper.DataSetGroup.RenamingOfADataSetNotSupported.Message" );
    } else if ( StringUtil.isEmpty( previousName ) && Const.indexOfString( newName, groupNames ) >= 0 ) {
      message = BaseMessages.getString( PKG, "DataSetHelper.DataSetGroup.AGroupWithNameExists.Message", newName );
    } else if ( dataSetGroup.getType() == null ) {
      message = BaseMessages.getString( PKG, "DataSetHelper.DataSetGroup.NoGroupTypeSpecified.Message" );
    } else {
      switch ( dataSetGroup.getType() ) {
        case Database:
          if ( dataSetGroup.getDatabaseMeta() == null ) {
            message = BaseMessages.getString( PKG, "DataSetHelper.DataSetGroup.NoDatabaseSpecified.Message" );
          }
          break;
        case CSV:
          break;
      }
    }

    return message;
  }
 
Example 15
Source Project: pentaho-pdi-dataset   Source File: DataSetConst.java    License: Apache License 2.0 5 votes vote down vote up
public static final DataSetGroup findDataSetGroup( List<DataSetGroup> list, String dataSetGroupName ) {
  if ( StringUtil.isEmpty( dataSetGroupName ) ) {
    return null;
  }
  for ( DataSetGroup dataSetGroup : list ) {
    if ( dataSetGroupName.equals( dataSetGroup.getName() ) ) {
      return dataSetGroup;
    }
  }
  return null;
}
 
Example 16
Source Project: learning-hadoop   Source File: CassandraOutputDialog.java    License: Apache License 2.0 5 votes vote down vote up
private void checkPasswordVisible() {
  String password = m_passText.getText();
  ArrayList<String> list = new ArrayList<String>();
  StringUtil.getUsedVariables(password, list, true);
  if (list.size() == 0) {
    m_passText.setEchoChar('*');
  } else {
    m_passText.setEchoChar('\0'); // show everything
  }
}
 
Example 17
Source Project: learning-hadoop   Source File: CassandraInputDialog.java    License: Apache License 2.0 5 votes vote down vote up
private void checkPasswordVisible() {
  String password = m_passText.getText();
  ArrayList<String> list = new ArrayList<String>();
  StringUtil.getUsedVariables(password, list, true);
  if (list.size() == 0) {
    m_passText.setEchoChar('*');
  } else {
    m_passText.setEchoChar('\0'); // show everything
  }
}
 
Example 18
Source Project: pentaho-mongodb-plugin   Source File: MongoDbModel.java    License: Apache License 2.0 5 votes vote down vote up
public boolean validate() {
  boolean valid = false;

  valid = ( !StringUtil.isEmpty( hostname ) )
      //   (!StringUtil.isEmpty(port)) &&     // port can be empty; MongoDb will assume 27017
      && ( !StringUtil.isEmpty( dbName ) ) && ( !StringUtil.isEmpty( collection ) ) && ( fields.size() > 0 );

  firePropertyChange( "validate", null, valid );
  return valid;
}
 
Example 19
Source Project: pentaho-kettle   Source File: ResourceEntry.java    License: Apache License 2.0 5 votes vote down vote up
public String toXml( int indentLevel ) {
  StringBuilder buff = new StringBuilder( 30 );
  buff
    .append( StringUtil.getIndent( indentLevel ) )
    .append( "<Resource type='" )
    .append( this.getResourcetype() )
    .append( "'><![CDATA[" ).append( this.getResource() ).append( "]]>" ).append( "</Resource>" ).append(
      StringUtil.CRLF );
  return buff.toString();
}
 
Example 20
Source Project: pentaho-kettle   Source File: ResourceReference.java    License: Apache License 2.0 5 votes vote down vote up
public void addXmlElementWithAttribute( StringBuilder buff, int indentLevel, String elementName, String attrName,
  String attrValue ) {
  buff
    .append( StringUtil.getIndent( indentLevel ) )
    .append( "<" ).append( elementName ).append( " " ).append( attrName ).append( "='" );
  buff.append( attrValue ).append( "'>" ).append( StringUtil.CRLF );
}
 
Example 21
Source Project: pentaho-kettle   Source File: JobEntryBase.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * <p>Appends the date, time and/or datetime to the given filename (before the extension if it exists), using the
 * provided patterns.</p>
 *
 * @param filename       the original filename (can have path and variables)
 * @param addDate        if the date is to be added
 * @param datePattern    the pattern to be used for the date
 * @param addTime        if the time is to be added
 * @param timePattern    the pattern to be used for the time
 * @param specifyFormat  if the datetime is to be added
 * @param datetimeFormat the pattern to be used for the datetime
 * @return the resulting filename after adding the specified suffixes to the given filename
 */
protected String addDatetimeToFilename( String filename, boolean addDate, String datePattern, boolean addTime,
                                        String timePattern, boolean specifyFormat, String datetimeFormat ) {

  if ( Utils.isEmpty( filename ) ) {
    return null;
  }

  // Replace possible environment variables...
  String realfilename = environmentSubstitute( filename );
  String filenameNoExtension = FilenameUtils.removeExtension( realfilename );
  String extension = FilenameUtils.getExtension( realfilename );

  // If an extension exists, add the corresponding dot before
  if ( !StringUtil.isEmpty( extension ) ) {
    extension = '.' + extension;
  }

  final SimpleDateFormat sdf = new SimpleDateFormat();
  Date now = new Date();

  if ( specifyFormat && !Utils.isEmpty( datetimeFormat ) ) {
    sdf.applyPattern( datetimeFormat );
    String dt = sdf.format( now );
    filenameNoExtension += dt;
  } else {
    if ( addDate && null != datePattern ) {
      sdf.applyPattern( datePattern );
      String d = sdf.format( now );
      filenameNoExtension += '_' + d;
    }
    if ( addTime && null != timePattern ) {
      sdf.applyPattern( timePattern );
      String t = sdf.format( now );
      filenameNoExtension += '_' + t;
    }
  }

  return filenameNoExtension + extension;
}
 
Example 22
Source Project: pentaho-kettle   Source File: JobEntrySimpleEval.java    License: Apache License 2.0 5 votes vote down vote up
private String getVariableWithSpec() {
  String variable = getVariableName();
  if ( ( !variable.contains( StringUtil.UNIX_OPEN ) && !variable.contains( StringUtil.WINDOWS_OPEN ) && !variable
    .contains( StringUtil.HEX_OPEN ) )
    && ( ( !variable.contains( StringUtil.UNIX_CLOSE ) && !variable.contains( StringUtil.WINDOWS_CLOSE ) && !variable
      .contains( StringUtil.HEX_CLOSE ) ) ) ) {
    // Add specifications to variable
    variable = StringUtil.UNIX_OPEN + variable + StringUtil.UNIX_CLOSE;
    if ( isDetailed() ) {
      logDetailed( BaseMessages.getString( PKG, "JobEntrySimpleEval.CheckingVariable", variable ) );
    }
  }
  return variable;
}
 
Example 23
Source Project: pentaho-kettle   Source File: JobMeta.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Gets the used variables.
 *
 * @return the used variables
 */
public List<String> getUsedVariables() {
  // Get the list of Strings.
  List<StringSearchResult> stringList = getStringList( true, true, false );

  List<String> varList = new ArrayList<String>();

  // Look around in the strings, see what we find...
  for ( StringSearchResult result : stringList ) {
    StringUtil.getUsedVariables( result.getString(), varList, false );
  }

  return varList;
}
 
Example 24
Source Project: pentaho-kettle   Source File: ReplaceString.java    License: Apache License 2.0 5 votes vote down vote up
private String getResolvedReplaceByString( int index, Object[] row ) throws KettleException {

    if ( data.setEmptyString[index] ) {
      // return empty string rather than null value
      return StringUtil.EMPTY_STRING;
    }

    // if there is something in the original replaceByString, then use it.
    if ( data.replaceFieldIndex[index] == -1 ) {
      return data.replaceByString[index];
    }

    return getInputRowMeta().getString( row, data.replaceFieldIndex[index] );
  }
 
Example 25
Source Project: pentaho-kettle   Source File: IfNull.java    License: Apache License 2.0 5 votes vote down vote up
public void replaceNull( Object[] row, ValueMetaInterface sourceValueMeta, int i, String realReplaceByValue,
  String realconversionMask, boolean setEmptystring ) throws Exception {
  if ( setEmptystring ) {
    row[i] = StringUtil.EMPTY_STRING;
  } else {
    // DO CONVERSION OF THE DEFAULT VALUE ...
    // Entered by user
    ValueMetaInterface targetValueMeta = data.outputRowMeta.getValueMeta( i );
    if ( !Utils.isEmpty( realconversionMask ) ) {
      sourceValueMeta.setConversionMask( realconversionMask );
    }
    row[i] = targetValueMeta.convertData( sourceValueMeta, realReplaceByValue );
  }
}
 
Example 26
Source Project: pentaho-kettle   Source File: ExcelInputMeta.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void setDefault() {
  startsWithHeader = true;
  ignoreEmptyRows = true;
  rowNumberField = StringUtil.EMPTY_STRING;
  sheetRowNumberField = StringUtil.EMPTY_STRING;
  isaddresult = true;
  int nrfiles = 0;
  int nrfields = 0;
  int nrsheets = 0;

  allocate( nrfiles, nrsheets, nrfields );

  rowLimit = 0L;

  strictTypes = false;
  errorIgnored = false;
  errorLineSkipped = false;
  warningFilesDestinationDirectory = null;
  warningFilesExtension = "warning";
  errorFilesDestinationDirectory = null;
  errorFilesExtension = "error";
  lineNumberFilesDestinationDirectory = null;
  lineNumberFilesExtension = "line";

  spreadSheetType = SpreadSheetType.JXL; // default.
}
 
Example 27
Source Project: pentaho-kettle   Source File: TextFileInput.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @deprecated Use {@link #convertLineToRow(LogChannelInterface, TextFileLine,
 * InputFileMetaInterface, Object[], int, RowMetaInterface,RowMetaInterface,
 * String, long, String, String, String, FileErrorHandler, boolean, boolean,
 * boolean, boolean, boolean, boolean, boolean, boolean, String, String, boolean,
 * Date, String, String, String, long)} instead.
 */
@Deprecated
public static final Object[] convertLineToRow( LogChannelInterface log, TextFileLine textFileLine,
    InputFileMetaInterface info, RowMetaInterface outputRowMeta, RowMetaInterface convertRowMeta, String fname,
    long rowNr, String delimiter, FileErrorHandler errorHandler, boolean addShortFilename, boolean addExtension,
    boolean addPath, boolean addSize, boolean addIsHidden, boolean addLastModificationDate, boolean addUri,
    boolean addRootUri, String shortFilename, String path, boolean hidden, Date modificationDateTime, String uri,
    String rooturi, String extension, long size ) throws KettleException {
  return convertLineToRow( log, textFileLine, info, null, 0, outputRowMeta, convertRowMeta, fname, rowNr, delimiter,
      StringUtil.substituteHex( info.getEnclosure() ), StringUtil.substituteHex( info.getEscapeCharacter() ),
      errorHandler, addShortFilename, addExtension, addPath, addSize, addIsHidden, addLastModificationDate, addUri,
      addRootUri, shortFilename, path, hidden, modificationDateTime, uri, rooturi, extension, size );
}
 
Example 28
Source Project: pentaho-kettle   Source File: StepOption.java    License: Apache License 2.0 5 votes vote down vote up
public static void checkInteger( List<CheckResultInterface> remarks, StepMeta stepMeta, VariableSpace space,
                                 String identifier, String value ) {
  try {
    if ( !StringUtil.isEmpty( space.environmentSubstitute( value ) ) ) {
      Integer.parseInt( space.environmentSubstitute( value ) );
    }
  } catch ( NumberFormatException e ) {
    remarks.add( new CheckResult(
      CheckResultInterface.TYPE_RESULT_ERROR,
      BaseMessages.getString( PKG, "StepOption.CheckResult.NotAInteger", identifier ),
      stepMeta ) );
  }
}
 
Example 29
Source Project: pentaho-kettle   Source File: StepOption.java    License: Apache License 2.0 5 votes vote down vote up
public static void checkLong( List<CheckResultInterface> remarks, StepMeta stepMeta, VariableSpace space,
                              String identifier, String value ) {
  try {
    if ( !StringUtil.isEmpty( space.environmentSubstitute( value ) ) ) {
      Long.parseLong( space.environmentSubstitute( value ) );
    }
  } catch ( NumberFormatException e ) {
    remarks.add( new CheckResult(
      CheckResultInterface.TYPE_RESULT_ERROR,
      BaseMessages.getString( PKG, "StepOption.CheckResult.NotAInteger", identifier ),
      stepMeta ) );
  }
}
 
Example 30
Source Project: pentaho-kettle   Source File: StepOption.java    License: Apache License 2.0 5 votes vote down vote up
public static void checkBoolean( List<CheckResultInterface> remarks, StepMeta stepMeta, VariableSpace space,
                                 String identifier, String value ) {
  if ( !StringUtil.isEmpty( space.environmentSubstitute( value ) ) && null == BooleanUtils
    .toBooleanObject( space.environmentSubstitute( value ) ) ) {
    remarks.add( new CheckResult(
      CheckResultInterface.TYPE_RESULT_ERROR,
      BaseMessages.getString( PKG, "StepOption.CheckResult.NotABoolean", identifier ),
      stepMeta ) );
  }
}