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 */ 016package org.springframework.batch.sample.domain.football.internal; 017 018import java.sql.ResultSet; 019import java.sql.SQLException; 020 021import org.springframework.batch.core.test.football.PlayerSummary; 022import org.springframework.jdbc.core.RowMapper; 023 024/** 025 * RowMapper used to map a ResultSet to a {@link PlayerSummary} 026 * 027 * @author Lucas Ward 028 * 029 */ 030public class PlayerSummaryRowMapper implements RowMapper<PlayerSummary> { 031 032 /* (non-Javadoc) 033 * @see org.springframework.jdbc.core.RowMapper#mapRow(java.sql.ResultSet, int) 034 */ 035 @Override 036 public PlayerSummary mapRow(ResultSet rs, int rowNum) throws SQLException { 037 038 PlayerSummary summary = new PlayerSummary(); 039 040 summary.setId(rs.getString(1)); 041 summary.setYear(rs.getInt(2)); 042 summary.setCompletes(rs.getInt(3)); 043 summary.setAttempts(rs.getInt(4)); 044 summary.setPassingYards(rs.getInt(5)); 045 summary.setPassingTd(rs.getInt(6)); 046 summary.setInterceptions(rs.getInt(7)); 047 summary.setRushes(rs.getInt(8)); 048 summary.setRushYards(rs.getInt(9)); 049 summary.setReceptions(rs.getInt(10)); 050 summary.setReceptionYards(rs.getInt(11)); 051 summary.setTotalTd(rs.getInt(12)); 052 053 return summary; 054 } 055 056}