EMMA Coverage Report (generated Tue May 06 07:28:24 PDT 2008)
[all classes][org.springframework.batch.item.validator]

COVERAGE SUMMARY FOR SOURCE FILE [ValidatingItemReader.java]

nameclass, %method, %block, %line, %
ValidatingItemReader.java100% (1/1)75%  (3/4)72%  (18/25)70%  (7/10)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ValidatingItemReader100% (1/1)75%  (3/4)72%  (18/25)70%  (7/10)
afterPropertiesSet (): void 0%   (0/1)0%   (0/7)0%   (0/3)
ValidatingItemReader (): void 100% (1/1)100% (3/3)100% (1/1)
read (): Object 100% (1/1)100% (11/11)100% (4/4)
setValidator (Validator): void 100% (1/1)100% (4/4)100% (2/2)

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 */
16package org.springframework.batch.item.validator;
17 
18import org.springframework.batch.item.support.DelegatingItemReader;
19import org.springframework.util.Assert;
20 
21/**
22 * Simple extension of {@link DelegatingItemReader} that provides for
23 * validation before returning input.
24 *
25 * @author Lucas Ward
26 *
27 */
28public class ValidatingItemReader extends DelegatingItemReader {
29 
30        private Validator validator;
31 
32        /* (non-Javadoc)
33         * @see org.springframework.batch.item.reader.DelegatingItemReader#afterPropertiesSet()
34         */
35        public void afterPropertiesSet() throws Exception {
36                super.afterPropertiesSet();
37                Assert.notNull(validator, "Validator must not be null.");
38        }
39 
40        /* (non-Javadoc)
41         * @see org.springframework.batch.item.reader.DelegatingItemReader#read()
42         */
43        public Object read() throws Exception {
44                Object input = super.read();
45                if(input != null){
46                        validator.validate(input);
47                }
48                return input;
49        }
50 
51        /**
52         * Set the validator used to validate each item.
53         *
54         * @param validator
55         */
56        public void setValidator(Validator validator) {
57                this.validator = validator;
58        }
59}

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