easy-batch job mappers

mappers can map input records to domain objects

api mode

Job job = new JobBuilder()
    .mapper(new MyRecordMapper())
    .build();

Provided mapping

 

 


 

 

Custom type conversion

The raw text data of some recordMapper (DelimitedRecordMapper, FixedLengthRecordMapper, ApacheCommonCsvRecordMapper and JdbcRecordMapper) is converted into typed data in Java objects. Easy Batch supports all Java primitives and wrapper types. If you want to provide a custom type converter, you can implement the org.easybatch.core.api.TypeConverter interface and register the implementation in the record mapper used.

Notes on fixed value recording

If the format of the delimited record is incorrect, DelimitedRecordMapper raises an exception under the following circumstances, causing the record to be rejected:

  • Field number is not equal to CSV RFC
  • The field does not meet the expected condition of the data qualifier, which means that after the qualifier is specified by DelimitedRecordMapper, all fields are expected to meet the condition.

DelimitedRecordMapper limitations

DelimitedRecordMapper is designed to cover the basic requirements of delimited value mapping. It does not support detection of delimiters and line breaks in restricted fields. If you need these functions, you can use ApacheCommonCsvRecordMapper or OpenCsvRecordMapper.

Notes on fixed-length records

If the fixed-length record format is incorrect FixedLengthRecordMapper, an exception will be thrown, causing the record to be rejected. If the fixed-length record length is not equal to the expected record length, the format is incorrect.

XML record verification

When creating XmlRecordMapper, you should specify the target domain object type. If you need to verify Xml records according to the Xsd mode, you can specify the mode at the time of creation, as follows:

 
Job job = new JobBuilder()
        .mapper(new XmlRecordMapper(MyPojoType.class, myXsdFile))
        .build();

References

https://github.com/j-easy/easy-batch/wiki/mappers

Guess you like

Origin www.cnblogs.com/rongfengliang/p/12730140.html