Interface CsvInputAwareHelper
- All Known Implementing Classes:
CsvInputHelper,TextFileInputHelper
public interface CsvInputAwareHelper
-
Method Summary
Modifier and TypeMethodDescriptiondefault org.json.simple.JSONArrayconvertFieldsToJsonArray(TextFileInputFieldDTO[] textFileInputFields) Converts an array of TextFileInputFieldDTO objects into a JSON array.default BufferedInputStreamReadergetBufferedReader(TransMeta transMeta, CsvInputAwareMeta meta, InputStream inputStream) Creates a buffered input stream reader for the given CSV input metadata and input stream.default String[]getFieldNames(TransMeta transMeta, CsvInputAwareMeta meta) Retrieves the field names from the CSV input metadata.default String[]getFieldNamesImpl(TransMeta transMeta, BufferedInputStreamReader reader, CsvInputAwareMeta meta) Retrieves the field names from the CSV input metadata using the provided reader.getInputStream(TransMeta transMeta, CsvInputAwareMeta meta) Returns theInputStreamcorresponding to the csv file, or null if the file cannot be read.default InputStreamReadergetReader(TransMeta transMeta, CsvInputAwareMeta meta, InputStream inputStream) Returns theInputStreamReadercorresponding to the csv file, or null if the file cannot be read.default StringgetStringFromRow(org.pentaho.di.core.row.RowMetaInterface rowMeta, Object[] row, int index, boolean failOnParseError) WhenfailOnParseErroris set tofalse, returns theStringvalue fromRowMetaat the givenindex, or directly from therowobject, if there is a problem fetching the value fromRowMeta.org.pentaho.di.core.logging.LogChannelInterfacedefault voidLogs an error message.default voidLogs an error message along with an exception.default StringmassageFieldName(String fieldName) Custom handling of each field can be implemented here.
-
Method Details
-
getFieldNames
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 filemeta- 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
Custom handling of each field can be implemented here. -
getReader
default InputStreamReader getReader(TransMeta transMeta, CsvInputAwareMeta meta, InputStream inputStream) Returns theInputStreamReadercorresponding to the csv file, or null if the file cannot be read.- Returns:
- the
InputStreamReadercorresponding 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 WhenfailOnParseErroris set tofalse, returns theStringvalue fromRowMetaat the givenindex, or directly from therowobject, if there is a problem fetching the value fromRowMeta. WhenfailOnParseErroristrue, anyExceptionthrown by the call toRowMeta.getString(Object[], int)is reported back to the caller.- Parameters:
rowMeta- an instance ofRowMetaInterfacerow- an Object array containing row dataindex- the index representing the column in a rowfailOnParseError- 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 metadatainputStream- the input stream to read from- Returns:
- a BufferedInputStreamReader for reading the CSV file
-
logError
Logs an error message along with an exception.- Parameters:
message- the error message to logexception- the exception to log
-
logError
Logs an error message.- Parameters:
message- the error message to log
-
getInputStream
Returns theInputStreamcorresponding to the csv file, or null if the file cannot be read.- Returns:
- the
InputStreamcorresponding to the csv file, or null if the file cannot be read
-
logChannel
org.pentaho.di.core.logging.LogChannelInterface logChannel()
-