Class ReflectionCSVProcessor<T>
- java.lang.Object
-
- science.aist.jack.persistence.filesystem.implementation.CSVProcessor<T>
-
- science.aist.jack.persistence.filesystem.implementation.ReflectionCSVProcessor<T>
-
- Direct Known Subclasses:
AdvancedCsvProcessor
public class ReflectionCSVProcessor<T> extends CSVProcessor<T>
Reflection based implementation for reading/writing CSV files.
- Since:
- 2.0
- Author:
- Christoph Praschl
-
-
Field Summary
-
Fields inherited from class science.aist.jack.persistence.filesystem.implementation.CSVProcessor
columnDefinition, columnsToElementFunc, elementToFunc, separator
-
-
Constructor Summary
Constructors Constructor Description ReflectionCSVProcessor(char separator, List<String> columnDefinition, Class<T> clazz)
Constructor of a ReflectionCSVProcessor 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 void
addFieldConverter(Class<?> clazz, Function<String,Object> converter)
Add a converter for the given class.void
addIgnoredField(String fieldName)
Add a field which will be ignored so it won't be read or written-
Methods inherited from class science.aist.jack.persistence.filesystem.implementation.CSVProcessor
getProcessor, getProcessor, getReader, getReader, getWriter, normalizeColumnDefinition, normalizeRow, read, write
-
-
-
-
Constructor Detail
-
ReflectionCSVProcessor
public ReflectionCSVProcessor(char separator, List<String> columnDefinition, Class<T> clazz)
Constructor of a ReflectionCSVProcessor 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 type
-
-
Method Detail
-
addIgnoredField
public void addIgnoredField(String fieldName)
Add a field which will be ignored so it won't be read or written- Parameters:
fieldName
- name of the ignored field
-
addFieldConverter
public void addFieldConverter(Class<?> clazz, Function<String,Object> converter)
Add a converter for the given class. This converter will be used for converting the CSV string to the expected field type. Using this method you can also override the default converters for simple-typed properties only (int, double, float, long, boolean, char, Integer, Float, Double, Long, String, Character, Boolean)- Parameters:
clazz
- for which the converter will be usedconverter
- converter which transforms the given csv value to an object of the expected type
-
-