Good day,
I am referring to here in my work.
Here is part of the code :
<bean id="flatFileTokenizer" class="org.springframework.batch.item.file.transform.PrefixMatchingCompositeLineTokenizer">
<property name="tokenizers">
<map>
<entry key="10" value-ref="recordType10" />
<entry key="20" value-ref="recordType20" />
<entry key="21" value-ref="recordType21" />
[...]
</map>
</property>
</bean>
Would like to ask what is the key stand for? and what are the 10, 20, 21 is refer to?
Is it means It will match with my input file, which is the first row of data start with 10, 20 and so on?
Here is my own work, the following is my code :
<beans:bean id="salaryDeductionLineTokenizer" class="org.springframework.batch.item.file.transform.PatternMatchingCompositeLineTokenizer">
<beans:property name="tokenizers">
<beans:map>
<beans:entry key="01*" value-ref="header" />
<beans:entry key="02*" value-ref="details" />
</beans:map>
</beans:property>
</beans:bean>
<beans:bean id="header" class="org.springframework.batch.item.file.transform.FixedLengthTokenizer">
<beans:property name="names" value="headerRecordType,headerDate,headerAGBranchCode,headerTotalRecord,headerTotalAmount,headerAgencyName,headerFiller" />
<beans:property name="columns" value="1-2, 3-8, 9-12, 13-17, 18-28, 29-48, 49-120" />
</beans:bean>
<beans:bean id="details" class="org.springframework.batch.item.file.transform.FixedLengthTokenizer">
<beans:property name="names" value="recordType,department,payCenter,region,personelNo,ic,accountNumber,name,deductionAmount,deductionCode,filler" />
<beans:property name="columns" value="1-2, 3-10, 11-14, 15-16, 17-24, 25-36, 37-56, 57-96, 97-105, 106-109, 110-120" />
</beans:bean>
The purpose to create this tokenizer is to read data from a txt file which consists of different styles of data row, which is first row is header, and the other row is details row.
The following is example data of my txt file :
0120140310700000500000030000AgencyA Filler1
02PTJ ABCD00123456788912190860771234567890 Chong Jun Xian
02KLM ABCE00123456798912190860781234567894 Chong Jun Xian
02KLN ABCF0012345680891219086081108187066968 Chong Jun Cian
I am getting error as follow : Caused by: java.lang.IllegalArgumentException: Cannot access column [recordType] from [headerRecordType, headerDate, headerAGBranchCode, headerTotalRecord, headerTotalAmount, headerAgencyName, headerFiller]
Try googling but cant found solution. Kindly advise.
*Please notify me if my question is confusing. *