View Javadoc

1   /*
2    * Copyright 2006-2007 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.springframework.batch.sample.domain.football.internal;
17  
18  import java.sql.ResultSet;
19  import java.sql.SQLException;
20  
21  import org.springframework.batch.sample.domain.football.PlayerSummary;
22  import org.springframework.jdbc.core.RowMapper;
23  
24  /**
25   * RowMapper used to map a ResultSet to a {@link PlayerSummary}
26   * 
27   * @author Lucas Ward
28   *
29   */
30  public class PlayerSummaryRowMapper implements RowMapper {
31  
32  	/* (non-Javadoc)
33  	 * @see org.springframework.jdbc.core.RowMapper#mapRow(java.sql.ResultSet, int)
34  	 */
35  	public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
36  		
37  		PlayerSummary summary = new PlayerSummary();
38  		
39  		summary.setId(rs.getString(1));
40  		summary.setYear(rs.getInt(2));
41  		summary.setCompletes(rs.getInt(3));
42  		summary.setAttempts(rs.getInt(4));
43  		summary.setPassingYards(rs.getInt(5));
44  		summary.setPassingTd(rs.getInt(6));
45  		summary.setInterceptions(rs.getInt(7));
46  		summary.setRushes(rs.getInt(8));
47  		summary.setRushYards(rs.getInt(9));
48  		summary.setReceptions(rs.getInt(10));
49  		summary.setReceptionYards(rs.getInt(11));
50  		summary.setTotalTd(rs.getInt(12));
51  		
52  		return summary;
53  	}
54  
55  }