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

COVERAGE SUMMARY FOR SOURCE FILE [DelegatingItemWriter.java]

nameclass, %method, %block, %line, %
DelegatingItemWriter.java100% (1/1)88%  (7/8)83%  (30/36)82%  (14/17)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DelegatingItemWriter100% (1/1)88%  (7/8)83%  (30/36)82%  (14/17)
DelegatingItemWriter (ItemWriter): void 0%   (0/1)0%   (0/6)0%   (0/3)
DelegatingItemWriter (): void 100% (1/1)100% (3/3)100% (2/2)
afterPropertiesSet (): void 100% (1/1)100% (4/4)100% (2/2)
clear (): void 100% (1/1)100% (4/4)100% (2/2)
doProcess (Object): Object 100% (1/1)100% (2/2)100% (1/1)
flush (): void 100% (1/1)100% (4/4)100% (2/2)
setDelegate (ItemWriter): void 100% (1/1)100% (4/4)100% (2/2)
write (Object): void 100% (1/1)100% (9/9)100% (3/3)

1package org.springframework.batch.item.support;
2 
3import org.springframework.batch.item.ClearFailedException;
4import org.springframework.batch.item.FlushFailedException;
5import org.springframework.batch.item.ItemWriter;
6import org.springframework.beans.factory.InitializingBean;
7import org.springframework.util.Assert;
8 
9/**
10 * Simple wrapper around {@link ItemWriter}.
11 * 
12 * @author Dave Syer
13 * @author Robert Kasanicky
14 */
15public class DelegatingItemWriter implements ItemWriter, InitializingBean {
16 
17        private ItemWriter delegate;
18        
19        /**
20         * Default constructor.
21         */
22        public DelegatingItemWriter() {
23                super();
24        }
25        
26        /**
27         * @param itemWriter
28         */
29        public DelegatingItemWriter(ItemWriter itemWriter) {
30                this();
31                this.delegate = itemWriter;
32        }
33 
34        /**
35         * Calls {@link #doProcess(Object)} and then writes the result to the
36         * delegate {@link ItemWriter}.
37         * @throws Exception 
38         * 
39         * @see ItemWriter#write(Object)
40         */
41        public void write(Object item) throws Exception {
42                Object result = doProcess(item);
43                delegate.write(result);
44        }
45 
46        /**
47         * By default returns the argument. This method is an extension point meant
48         * to be overridden by subclasses that implement processing logic.
49         * @throws Exception 
50         */
51        protected Object doProcess(Object item) throws Exception {
52                return item;
53        }
54 
55        /**
56         * Setter for {@link ItemWriter}.
57         */
58        public void setDelegate(ItemWriter writer) {
59                this.delegate = writer;
60        }
61 
62        public void afterPropertiesSet() throws Exception {
63                Assert.notNull(delegate);
64        }
65 
66        /**
67         * Delegates to {@link ItemWriter#clear()}
68         */
69        public void clear() throws ClearFailedException {
70                delegate.clear();
71        }
72 
73        /**
74         * Delegates to {@link ItemWriter#flush()}
75         */
76        public void flush() throws FlushFailedException {
77                delegate.flush();
78        }
79 
80}

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