EMMA Coverage Report (generated Thu May 22 12:08:10 CDT 2014)
[all classes][org.springframework.batch.item.database.support]

COVERAGE SUMMARY FOR SOURCE FILE [ColumnMapItemPreparedStatementSetter.java]

nameclass, %method, %block, %line, %
ColumnMapItemPreparedStatementSetter.java100% (1/1)100% (2/2)100% (27/27)100% (8/8)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ColumnMapItemPreparedStatementSetter100% (1/1)100% (2/2)100% (27/27)100% (8/8)
ColumnMapItemPreparedStatementSetter (): void 100% (1/1)100% (3/3)100% (1/1)
setValues (Map, PreparedStatement): void 100% (1/1)100% (24/24)100% (7/7)

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 
17package org.springframework.batch.item.database.support;
18 
19import java.sql.PreparedStatement;
20import java.sql.SQLException;
21import java.util.Map;
22 
23import org.springframework.batch.item.database.ItemPreparedStatementSetter;
24import org.springframework.jdbc.core.ColumnMapRowMapper;
25import org.springframework.jdbc.core.SqlTypeValue;
26import org.springframework.jdbc.core.StatementCreatorUtils;
27import org.springframework.util.Assert;
28 
29/**
30 * </p>Implementation of the {@link ItemPreparedStatementSetter} interface that assumes all
31 * keys are contained within a {@link Map} with the column name as the key.  It assumes nothing 
32 * about ordering, and assumes that the order the entry set can be iterated over is the same as
33 * the PreparedStatement should be set.</p>
34 * 
35 * @author Lucas Ward
36 * @author Dave Syer
37 * @see ItemPreparedStatementSetter
38 * @see ColumnMapRowMapper
39 */
40public class ColumnMapItemPreparedStatementSetter implements ItemPreparedStatementSetter<Map<String, Object>> {
41 
42    @Override
43        public void setValues(Map<String, Object> item, PreparedStatement ps) throws SQLException {
44                Assert.isInstanceOf(Map.class, item, "Input to map PreparedStatement parameters must be of type Map.");
45                int counter = 1;
46                for(Object value : item.values()){
47                        StatementCreatorUtils.setParameterValue(ps, counter, SqlTypeValue.TYPE_UNKNOWN, value);
48                        counter++;
49                }
50        }
51 
52}

[all classes][org.springframework.batch.item.database.support]
EMMA 2.0.5312 (C) Vladimir Roubtsov