Java Reference
In-Depth Information
Listing 7-20. Transaction Domain Object Code
package com.apress.springbatch.chapter7;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Transaction {
private String accountNumber;
private Date transactionDate;
private Double amount;
private DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
public String getAccountNumber() {
return accountNumber;
public void setAccountNumber(String accountNumber) {
this.accountNumber = accountNumber;
public Date getTransactionDate() {
return transactionDate;
public void setTransactionDate(Date transactionDate) {
this.transactionDate = transactionDate;
public Double getAmount() {
return amount;
public void setAmount(Double amount) {
this.amount = amount;
public String getDateString() {
return formatter.format(transactionDate);
With the record formats identified, you can look at the reader. Listing 7-21 shows the configuration
for the updated customerFileReader. As mentioned, using the PatternMatchingCompositeLineMapper,
you map two instances of the DelimitedLineTokenizer, each with the correct record format configured.
You'll notice that you have an additional field named prefix for each of the LineTokenizers. This is to
address the string at the beginning of each record (CUST and TRANS). Spring Batch will parse the prefix
and name it prefix in your FieldSet; however, since you don't have a prefix field in either of your domain
objects, it will be ignored in the mapping.
Search WWH ::

Custom Search