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

COVERAGE SUMMARY FOR SOURCE FILE [SpELItemKeyMapper.java]

nameclass, %method, %block, %line, %
SpELItemKeyMapper.java100% (1/1)100% (2/2)100% (19/19)100% (5/5)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SpELItemKeyMapper100% (1/1)100% (2/2)100% (19/19)100% (5/5)
SpELItemKeyMapper (String): void 100% (1/1)100% (14/14)100% (4/4)
convert (Object): Object 100% (1/1)100% (5/5)100% (1/1)

1/*
2 * Copyright 2002-2013 the original author or authors.
3 * 
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5 * the License. You may obtain a copy of the License at
6 * 
7 * http://www.apache.org/licenses/LICENSE-2.0
8 * 
9 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11 * specific language governing permissions and limitations under the License.
12 */
13package org.springframework.batch.item;
14 
15import org.springframework.core.convert.converter.Converter;
16import org.springframework.expression.Expression;
17import org.springframework.expression.ExpressionParser;
18import org.springframework.expression.spel.standard.SpelExpressionParser;
19 
20/**
21 * An implementation of {@link Converter} that uses SpEL to map a Value to a key
22 * @author David Turanski
23 * @since 2.2
24 */
25public class SpELItemKeyMapper<K,V> implements Converter<V,K> {
26        private final ExpressionParser parser = new SpelExpressionParser();
27        private final Expression parsedExpression;
28        
29        public SpELItemKeyMapper(String keyExpression) {
30                parsedExpression =  parser.parseExpression(keyExpression);
31        }
32        /* (non-Javadoc)
33         * @see org.springframework.batch.item.ItemKeyMapper#mapKey(java.lang.Object)
34         */
35        @SuppressWarnings("unchecked")
36        @Override
37        public K convert(V item) {
38                return (K) parsedExpression.getValue(item);
39        }
40}

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