egovframework.rte.bat.core.item.file.mapping.EgovDefaultLineMapper.java Source code

Java tutorial

Introduction

Here is the source code for egovframework.rte.bat.core.item.file.mapping.EgovDefaultLineMapper.java

Source

/*
 * Copyright 2006-2007 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package egovframework.rte.bat.core.item.file.mapping;

import org.springframework.batch.item.file.LineMapper;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;

import egovframework.rte.bat.core.item.file.transform.EgovLineTokenizer;

/**
 * EgovDefaultLineMapper ?
 * @author   ??
 * @since 2012.07.20
 * @version 1.0
 * @see 
 * <pre>
 *      ?(Modification Information)
 *   
 *   ?      ?           
 *  ------- -------- ---------------------------
 *  2012.07.20  ??      ?
 * </pre>
*/
public class EgovDefaultLineMapper<T> implements LineMapper<T>, InitializingBean {

    //String Line? token  LineTokenizer
    private EgovLineTokenizer<T> tokenizer;

    //Token? VO  ObjectMapper 
    private EgovObjectMapper<T> objectMapper;

    /**
     * String line? String Array tokenize  ?, Object ? VO .
     * 
     * @param line
     * @param lineNumber
     */
    public T mapLine(String line, int lineNumber) throws Exception {
        return (T) objectMapper.mapObject(tokenizer.tokenize(line));
    }

    /**
     * LineTokenizer .
     * 
     * @param tokenizer
     */
    public void setLineTokenizer(EgovLineTokenizer<T> tokenizer) {
        this.tokenizer = tokenizer;
    }

    /**
     * ObjectMapper .
     * 
     * @param objectMapper
     */
    public void setObjectMapper(EgovObjectMapper<T> objectMapper) {
        this.objectMapper = objectMapper;
    }

    public void afterPropertiesSet() {
        Assert.notNull(tokenizer, "The LineTokenizer must be set");
        Assert.notNull(objectMapper, "The ObjectMapper must be set");
    }
}