EMMA Coverage Report (generated Thu Jan 24 13:37:04 CST 2013)
[all classes][org.springframework.batch.item.file.transform]

COVERAGE SUMMARY FOR SOURCE FILE [RecursiveCollectionLineAggregator.java]

nameclass, %method, %block, %line, %
RecursiveCollectionLineAggregator.java100% (1/1)100% (4/4)100% (55/55)100% (9/9)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class RecursiveCollectionLineAggregator100% (1/1)100% (4/4)100% (55/55)100% (9/9)
<static initializer> 100% (1/1)100% (4/4)100% (1/1)
RecursiveCollectionLineAggregator (): void 100% (1/1)100% (8/8)100% (2/2)
aggregate (Collection): String 100% (1/1)100% (39/39)100% (4/4)
setDelegate (LineAggregator): 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 */
16 
17package org.springframework.batch.item.file.transform;
18 
19import java.util.Collection;
20 
21 
22/**
23 * An implementation of {@link LineAggregator} that concatenates a collection of
24 * items of a common type with the system line separator.
25 * 
26 * @author Dave Syer
27 * 
28 */
29public class RecursiveCollectionLineAggregator<T> implements LineAggregator<Collection<T>> {
30 
31        private static final String LINE_SEPARATOR = System.getProperty("line.separator");
32 
33        private LineAggregator<T> delegate = new PassThroughLineAggregator<T>();
34 
35        /**
36         * Public setter for the {@link LineAggregator} to use on single items, that
37         * are not Strings. This can be used to strategise the conversion of
38         * collection and array elements to a String.<br/>
39         * 
40         * @param delegate the line aggregator to set. Defaults to a pass through.
41         */
42        public void setDelegate(LineAggregator<T> delegate) {
43                this.delegate = delegate;
44        }
45 
46        /*
47         * (non-Javadoc)
48         * @see org.springframework.batch.item.file.transform.LineAggregator#aggregate(java.lang.Object)
49         */
50        public String aggregate(Collection<T> items) {
51                StringBuilder builder = new StringBuilder();
52                for (T value : items) {
53                        builder.append(delegate.aggregate(value) + LINE_SEPARATOR);
54                }
55                return builder.delete(builder.length()-LINE_SEPARATOR.length(),builder.length()).toString();
56        }
57 
58}

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