Example usage for org.springframework.batch.item.file.transform DelimitedLineTokenizer setIncludedFields

List of usage examples for org.springframework.batch.item.file.transform DelimitedLineTokenizer setIncludedFields

Introduction

In this page you can find the example usage for org.springframework.batch.item.file.transform DelimitedLineTokenizer setIncludedFields.

Prototype

public void setIncludedFields(int... includedFields) 

Source Link

Document

The fields to include in the output by position (starting at 0).

Usage

From source file:de.codecentric.batch.jobs.FlatFileToDbNoSkipJobConfiguration.java

@Bean
public LineMapper<Item> lineMapper() {
    DefaultLineMapper<Item> lineMapper = new DefaultLineMapper<Item>();
    DelimitedLineTokenizer lineTokenizer = new DelimitedLineTokenizer();
    lineTokenizer.setNames(new String[] { "id", "description", "firstAction", "secondAction" });
    lineTokenizer.setIncludedFields(new int[] { 0, 1, 2, 3 });
    BeanWrapperFieldSetMapper<Item> fieldSetMapper = new BeanWrapperFieldSetMapper<Item>();
    fieldSetMapper.setTargetType(Item.class);
    lineMapper.setLineTokenizer(lineTokenizer);
    lineMapper.setFieldSetMapper(fieldSetMapper);
    return lineMapper;
}