use of org.springframework.batch.item.file.mapping.DefaultLineMapper in project spring-batch by roytuts.
the class SpringBatchConfig method fileItemReader.
@Bean
public FlatFileItemReader<Person> fileItemReader(BeanWrapperFieldSetMapper<Person> beanWrapperFieldSetMapper) {
FlatFileItemReader<Person> fileItemReader = new FlatFileItemReader<>();
fileItemReader.setResource(new ClassPathResource("person.csv"));
DelimitedLineTokenizer delimitedLineTokenizer = new DelimitedLineTokenizer();
delimitedLineTokenizer.setNames("id", "firstName", "lastName");
DefaultLineMapper<Person> defaultLineMapper = new DefaultLineMapper<>();
defaultLineMapper.setLineTokenizer(delimitedLineTokenizer);
defaultLineMapper.setFieldSetMapper(beanWrapperFieldSetMapper);
fileItemReader.setLineMapper(defaultLineMapper);
return fileItemReader;
}
use of org.springframework.batch.item.file.mapping.DefaultLineMapper in project spring-batch by roytuts.
the class SpringBatchConfig method fileItemReader.
@Bean
public FlatFileItemReader<Person> fileItemReader() {
FlatFileItemReader<Person> fileItemReader = new FlatFileItemReader<>();
fileItemReader.setResource(new ClassPathResource("person.csv"));
DelimitedLineTokenizer delimitedLineTokenizer = new DelimitedLineTokenizer();
delimitedLineTokenizer.setNames("id", "firstName", "lastName");
DefaultLineMapper<Person> defaultLineMapper = new DefaultLineMapper<>();
defaultLineMapper.setLineTokenizer(delimitedLineTokenizer);
defaultLineMapper.setFieldSetMapper(new PersonFieldSetMapper());
fileItemReader.setLineMapper(defaultLineMapper);
return fileItemReader;
}
use of org.springframework.batch.item.file.mapping.DefaultLineMapper in project spring-batch by roytuts.
the class SpringBatchConfig method fileItemReader.
@Bean
public FlatFileItemReader<Person> fileItemReader(BeanWrapperFieldSetMapper<Person> beanWrapperFieldSetMapper) {
FlatFileItemReader<Person> fileItemReader = new FlatFileItemReader<>();
fileItemReader.setResource(new ClassPathResource("person.csv"));
DelimitedLineTokenizer delimitedLineTokenizer = new DelimitedLineTokenizer();
delimitedLineTokenizer.setNames("id", "firstName", "lastName");
DefaultLineMapper<Person> defaultLineMapper = new DefaultLineMapper<>();
defaultLineMapper.setLineTokenizer(delimitedLineTokenizer);
defaultLineMapper.setFieldSetMapper(beanWrapperFieldSetMapper);
fileItemReader.setLineMapper(defaultLineMapper);
return fileItemReader;
}
use of org.springframework.batch.item.file.mapping.DefaultLineMapper in project spring-batch by roytuts.
the class SpringBatchConfig method reader.
@Bean
public // creates an item reader
ItemReader<User> reader() {
FlatFileItemReader<User> reader = new FlatFileItemReader<User>();
// look for file user.csv
reader.setResource(new ClassPathResource("user.csv"));
// line mapper
DefaultLineMapper<User> lineMapper = new DefaultLineMapper<User>();
// each line with comma separated
lineMapper.setLineTokenizer(new DelimitedLineTokenizer());
// map file's field with object
lineMapper.setFieldSetMapper(new UserFieldSetMapper());
reader.setLineMapper(lineMapper);
return reader;
}
Aggregations