Class AdvancedCsvProcessor<T>
- java.lang.Object
-
- science.aist.jack.persistence.filesystem.implementation.CSVProcessor<T>
-
- science.aist.jack.persistence.filesystem.implementation.ReflectionCSVProcessor<T>
-
- science.aist.jack.persistence.filesystem.implementation.AdvancedCsvProcessor<T>
-
public class AdvancedCsvProcessor<T> extends ReflectionCSVProcessor<T>
Extension of the
ReflectionCSVProcessor
. It is advanced as it takes anAdvancedCsvProcessorConfig
in order to configure the normalisation of the column headers to allow improved mapping of csv files to objects- Since:
- 2.0
- Author:
- Rainer Meindl
-
-
Field Summary
-
Fields inherited from class science.aist.jack.persistence.filesystem.implementation.CSVProcessor
columnDefinition, columnsToElementFunc, elementToFunc, separator
-
-
Constructor Summary
Constructors Constructor Description AdvancedCsvProcessor(char separator, List<String> columnDefinition, Class<T> clazz)
Constructor of a AdvancedCsvProcessor for domain types with simple-typed properties only (int, double, float, long, boolean, char, Integer, Float, Double, Long, String, Character, Boolean).AdvancedCsvProcessor(char separator, List<String> columnDefinition, Class<T> clazz, AdvancedCsvProcessorConfig csvProcessorConfig)
Constructor of a AdvancedCsvProcessor for domain types with simple-typed properties only (int, double, float, long, boolean, char, Integer, Float, Double, Long, String, Character, Boolean)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected List<String>
normalizeColumnDefinition(List<String> columnHeader)
Normalizes the headers according to theAdvancedCsvProcessorConfig
.protected List<String>
normalizeRow(List<String> csvLine)
Defines the normalisation of a singular csv line after the header.-
Methods inherited from class science.aist.jack.persistence.filesystem.implementation.ReflectionCSVProcessor
addFieldConverter, addIgnoredField
-
Methods inherited from class science.aist.jack.persistence.filesystem.implementation.CSVProcessor
getProcessor, getProcessor, getReader, getReader, getWriter, read, write
-
-
-
-
Constructor Detail
-
AdvancedCsvProcessor
public AdvancedCsvProcessor(char separator, List<String> columnDefinition, Class<T> clazz, AdvancedCsvProcessorConfig csvProcessorConfig)
Constructor of a AdvancedCsvProcessor for domain types with simple-typed properties only (int, double, float, long, boolean, char, Integer, Float, Double, Long, String, Character, Boolean)- Parameters:
separator
- separator used in the csv filecolumnDefinition
- columnDefinition of the csv file (can be null for reading if the CSV file contains a header which is used inCSVProcessor.read(File, boolean, boolean)
)clazz
- clazz of domain typecsvProcessorConfig
- Configuration for this class. Defines how the header normalization should be handled
-
AdvancedCsvProcessor
public AdvancedCsvProcessor(char separator, List<String> columnDefinition, Class<T> clazz)
Constructor of a AdvancedCsvProcessor for domain types with simple-typed properties only (int, double, float, long, boolean, char, Integer, Float, Double, Long, String, Character, Boolean). The configuration is set to a default, meaning only whitespaces of the column headers are trimmed and concatenated into one "word"- Parameters:
separator
- separator used in the csv filecolumnDefinition
- columnDefinition of the csv file (can be null for reading if the CSV file contains a header which is used inCSVProcessor.read(File, boolean, boolean)
)clazz
- clazz of domain type
-
-
Method Detail
-
normalizeColumnDefinition
protected List<String> normalizeColumnDefinition(List<String> columnHeader)
Normalizes the headers according to theAdvancedCsvProcessorConfig
. It first removes the strings defined in the config.charactersToRemove, then replaces the strings defined in config.charactersToReplace.- Overrides:
normalizeColumnDefinition
in classCSVProcessor<T>
- Parameters:
columnHeader
- the extracted column headers to be used to map them to object fields- Returns:
- normalized column headers as define in the
AdvancedCsvProcessorConfig
. Should allow mapping of the values to objects.
-
normalizeRow
protected List<String> normalizeRow(List<String> csvLine)
Description copied from class:CSVProcessor
Defines the normalisation of a singular csv line after the header. Adapter method- Overrides:
normalizeRow
in classCSVProcessor<T>
- Parameters:
csvLine
- the split line of a csv file.- Returns:
- the normalized csv lines
-
-