001/*
002 * Copyright 2006-2007 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.batch.sample.domain.order.internal.mapper;
018
019import org.springframework.batch.item.file.mapping.FieldSetMapper;
020import org.springframework.batch.item.file.transform.FieldSet;
021import org.springframework.batch.sample.domain.order.Address;
022
023public class AddressFieldSetMapper implements FieldSetMapper<Address> {
024
025        public static final String ADDRESSEE_COLUMN = "ADDRESSEE";
026        public static final String ADDRESS_LINE1_COLUMN = "ADDR_LINE1";
027        public static final String ADDRESS_LINE2_COLUMN = "ADDR_LINE2";
028        public static final String CITY_COLUMN = "CITY";
029        public static final String ZIP_CODE_COLUMN = "ZIP_CODE";
030        public static final String STATE_COLUMN = "STATE";
031        public static final String COUNTRY_COLUMN = "COUNTRY";
032
033        @Override
034        public Address mapFieldSet(FieldSet fieldSet) {
035                Address address = new Address();
036
037                address.setAddressee(fieldSet.readString(ADDRESSEE_COLUMN));
038                address.setAddrLine1(fieldSet.readString(ADDRESS_LINE1_COLUMN));
039                address.setAddrLine2(fieldSet.readString(ADDRESS_LINE2_COLUMN));
040                address.setCity(fieldSet.readString(CITY_COLUMN));
041                address.setZipCode(fieldSet.readString(ZIP_CODE_COLUMN));
042                address.setState(fieldSet.readString(STATE_COLUMN));
043                address.setCountry(fieldSet.readString(COUNTRY_COLUMN));
044
045                return address;
046        }
047}