EMMA Coverage Report (generated Fri Jan 30 13:20:29 EST 2009)
[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 * The implementation is thread-safe if the delegate is thread-safe.
13 * 
14 * @author Dave Syer
15 * @author Robert Kasanicky
16 */
17public class DelegatingItemWriter implements ItemWriter, InitializingBean {
18 
19        private ItemWriter delegate;
20        
21        /**
22         * Default constructor.
23         */
24        public DelegatingItemWriter() {
25                super();
26        }
27        
28        /**
29         * @param itemWriter
30         */
31        public DelegatingItemWriter(ItemWriter itemWriter) {
32                this();
33                this.delegate = itemWriter;
34        }
35 
36        /**
37         * Calls {@link #doProcess(Object)} and then writes the result to the
38         * delegate {@link ItemWriter}.
39         * @throws Exception 
40         * 
41         * @see ItemWriter#write(Object)
42         */
43        public void write(Object item) throws Exception {
44                Object result = doProcess(item);
45                delegate.write(result);
46        }
47 
48        /**
49         * By default returns the argument. This method is an extension point meant
50         * to be overridden by subclasses that implement processing logic.
51         * @throws Exception 
52         */
53        protected Object doProcess(Object item) throws Exception {
54                return item;
55        }
56 
57        /**
58         * Setter for {@link ItemWriter}.
59         */
60        public void setDelegate(ItemWriter writer) {
61                this.delegate = writer;
62        }
63 
64        public void afterPropertiesSet() throws Exception {
65                Assert.notNull(delegate);
66        }
67 
68        /**
69         * Delegates to {@link ItemWriter#clear()}
70         */
71        public void clear() throws ClearFailedException {
72                delegate.clear();
73        }
74 
75        /**
76         * Delegates to {@link ItemWriter#flush()}
77         */
78        public void flush() throws FlushFailedException {
79                delegate.flush();
80        }
81 
82}

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