Interface CsvInputAwareHelper

All Known Implementing Classes:
CsvInputHelper, TextFileInputHelper

public interface CsvInputAwareHelper
  • Method Details

    • getFieldNames

      default String[] getFieldNames(TransMeta transMeta, CsvInputAwareMeta meta)
      Retrieves the field names from the CSV input metadata.
      Parameters:
      meta - the CSV input metadata
      Returns:
      an array of field names
    • getFieldNamesImpl

      default String[] getFieldNamesImpl(TransMeta transMeta, BufferedInputStreamReader reader, CsvInputAwareMeta meta) throws org.pentaho.di.core.exception.KettleException
      Retrieves the field names from the CSV input metadata using the provided reader.
      Parameters:
      reader - the buffered input stream reader for reading the CSV file
      meta - the CSV input metadata
      Returns:
      an array of field names
      Throws:
      org.pentaho.di.core.exception.KettleException - if an error occurs while retrieving the field names
    • massageFieldName

      default String massageFieldName(String fieldName)
      Custom handling of each field can be implemented here.
    • getReader

      default InputStreamReader getReader(TransMeta transMeta, CsvInputAwareMeta meta, InputStream inputStream)
      Returns the InputStreamReader corresponding to the csv file, or null if the file cannot be read.
      Returns:
      the InputStreamReader corresponding to the csv file, or null if the file cannot be read
    • convertFieldsToJsonArray

      default org.json.simple.JSONArray convertFieldsToJsonArray(TextFileInputFieldDTO[] textFileInputFields) throws com.fasterxml.jackson.core.JsonProcessingException
      Converts an array of TextFileInputFieldDTO objects into a JSON array.
      Parameters:
      textFileInputFields - an array of TextFileInputFieldDTO objects to be converted
      Returns:
      a JSONArray containing the JSON representation of the input fields
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - if an error occurs during JSON processing
    • getStringFromRow

      default String getStringFromRow(org.pentaho.di.core.row.RowMetaInterface rowMeta, Object[] row, int index, boolean failOnParseError) throws org.pentaho.di.core.exception.KettleException
      When failOnParseError is set to false, returns the String value from RowMeta at the given index, or directly from the row object, if there is a problem fetching the value from RowMeta. When failOnParseError is true, any Exception thrown by the call to RowMeta.getString(Object[], int) is reported back to the caller.
      Parameters:
      rowMeta - an instance of RowMetaInterface
      row - an Object array containing row data
      index - the index representing the column in a row
      failOnParseError - when true, Exceptions are reported back to the called, when false, exceptions are ignored and a null value is returned
      Returns:
      the row value at the given index
      Throws:
      org.pentaho.di.core.exception.KettleException
    • getBufferedReader

      default BufferedInputStreamReader getBufferedReader(TransMeta transMeta, CsvInputAwareMeta meta, InputStream inputStream)
      Creates a buffered input stream reader for the given CSV input metadata and input stream.
      Parameters:
      meta - the CSV input metadata
      inputStream - the input stream to read from
      Returns:
      a BufferedInputStreamReader for reading the CSV file
    • logError

      default void logError(String message, Exception exception)
      Logs an error message along with an exception.
      Parameters:
      message - the error message to log
      exception - the exception to log
    • logError

      default void logError(String message)
      Logs an error message.
      Parameters:
      message - the error message to log
    • getInputStream

      InputStream getInputStream(TransMeta transMeta, CsvInputAwareMeta meta)
      Returns the InputStream corresponding to the csv file, or null if the file cannot be read.
      Returns:
      the InputStream corresponding to the csv file, or null if the file cannot be read
    • logChannel

      org.pentaho.di.core.logging.LogChannelInterface logChannel()