Java tutorial
/* * 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 lcn.module.batch.core.item.file.mapping; import lcn.module.batch.core.item.file.transform.LineTokenizer; import org.springframework.batch.item.file.LineMapper; import org.springframework.beans.factory.InitializingBean; import org.springframework.util.Assert; /** * DefaultLineMapper ? * @author ?? * @since 2012.07.20 * @version 1.0 * @see * <pre> * ?(Modification Information) * * ? ? * ------- -------- --------------------------- * 2012.07.20 ?? ? * </pre> */ public class DefaultLineMapper<T> implements LineMapper<T>, InitializingBean { //String Line? token LineTokenizer private LineTokenizer<T> tokenizer; //Token? VO ObjectMapper private ObjectMapper<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(LineTokenizer<T> tokenizer) { this.tokenizer = tokenizer; } /** * ObjectMapper . * * @param objectMapper */ public void setObjectMapper(ObjectMapper<T> objectMapper) { this.objectMapper = objectMapper; } public void afterPropertiesSet() { Assert.notNull(tokenizer, "The LineTokenizer must be set"); Assert.notNull(objectMapper, "The ObjectMapper must be set"); } }