factor App.java into domain classes
This commit is contained in:
32
src/main/java/CSVReader.java
Normal file
32
src/main/java/CSVReader.java
Normal file
@ -0,0 +1,32 @@
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.espertech.esper.client.EPServiceProvider;
|
||||
import com.fasterxml.jackson.databind.MappingIterator;
|
||||
import com.fasterxml.jackson.dataformat.csv.CsvMapper;
|
||||
import com.fasterxml.jackson.dataformat.csv.CsvSchema;
|
||||
|
||||
public class CSVReader /*implements TickStreamReader*/ {
|
||||
File file;
|
||||
|
||||
|
||||
public CSVReader(File file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public void run(TickProcessor processor) {
|
||||
CsvMapper mapper = new CsvMapper();
|
||||
CsvSchema schema = mapper.schemaFor(TrueFXTick.class);
|
||||
|
||||
try {
|
||||
MappingIterator<TrueFXTick> it = mapper.readerFor(TrueFXTick.class).with(schema).readValues(file);
|
||||
while (it.hasNextValue()) {
|
||||
TrueFXTick value = it.nextValue();
|
||||
processor.process(value);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user