public class SmartLineBasedProcessor extends Object implements RowProcessor
LineBasedProcessor
to transform rows into maps.
Based on a list of known columns and aliases and the first row of the input, an assignment map is computed to transform an incoming row into a map of column names to values.
Constructor and Description |
---|
SmartLineBasedProcessor() |
Modifier and Type | Method and Description |
---|---|
List<sirius.kernel.commons.Tuple<String,String>> |
getColumnMapping()
Returns
tuples of the original column names and their mapped column names. |
void |
handleRow(int lineNumber,
sirius.kernel.commons.Values row)
Called the handle a row of an input file.
|
SmartLineBasedProcessor |
withColumn(String key,
String... aliases)
Registers a known column and possible aliases.
|
SmartLineBasedProcessor |
withProcessor(NamedRowProcessor processor)
Attaches the processor which is supplied with a map of data per row in the input.
|
public SmartLineBasedProcessor withColumn(String key, String... aliases)
key
- the column namealiases
- a list of aliases for this columnpublic SmartLineBasedProcessor withProcessor(NamedRowProcessor processor)
Note that all column names which are used as map keys here, are trimmed and made lower case.
processor
- the processor used to process input data.public void handleRow(int lineNumber, sirius.kernel.commons.Values row)
RowProcessor
Note that an exception thrown here will completely abort the whole process. Therefore proper exception handling is required.
handleRow
in interface RowProcessor
lineNumber
- the line number which is currently being processed.row
- the data of the row / line to processCopyright © 2018. All rights reserved.