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

COVERAGE SUMMARY FOR SOURCE FILE [PatternMatchingCompositeLineTokenizer.java]

nameclass, %method, %block, %line, %
PatternMatchingCompositeLineTokenizer.java100% (1/1)100% (4/4)97%  (37/38)99%  (7.9/8)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PatternMatchingCompositeLineTokenizer100% (1/1)100% (4/4)97%  (37/38)99%  (7.9/8)
setTokenizers (Map): void 100% (1/1)93%  (14/15)98%  (2.9/3)
PatternMatchingCompositeLineTokenizer (): void 100% (1/1)100% (6/6)100% (2/2)
afterPropertiesSet (): void 100% (1/1)100% (9/9)100% (2/2)
tokenize (String): FieldSet 100% (1/1)100% (8/8)100% (1/1)

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.Map;
20 
21import org.springframework.batch.support.PatternMatcher;
22import org.springframework.beans.factory.InitializingBean;
23import org.springframework.util.Assert;
24 
25/**
26 * A {@link LineTokenizer} implementation that stores a mapping of String
27 * patterns to delegate {@link LineTokenizer}s. Each line tokenizied will be
28 * checked to see if it matches a pattern. If the line matches a key in the map
29 * of delegates, then the corresponding delegate {@link LineTokenizer} will be
30 * used. Patterns are sorted starting with the most specific, and the first
31 * match succeeds.
32 * 
33 * @author Ben Hale
34 * @author Dan Garrette
35 * @author Dave Syer
36 */
37public class PatternMatchingCompositeLineTokenizer implements LineTokenizer, InitializingBean {
38 
39        private PatternMatcher<LineTokenizer> tokenizers = null;
40 
41        /*
42         * (non-Javadoc)
43         * 
44         * @see
45         * org.springframework.batch.item.file.transform.LineTokenizer#tokenize(
46         * java.lang.String)
47         */
48    @Override
49        public FieldSet tokenize(String line) {
50                return tokenizers.match(line).tokenize(line);
51        }
52 
53        /*
54         * (non-Javadoc)
55         * 
56         * @see
57         * org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
58         */
59    @Override
60        public void afterPropertiesSet() throws Exception {
61                Assert.isTrue(this.tokenizers != null, "The 'tokenizers' property must be non-empty");
62        }
63 
64        public void setTokenizers(Map<String, LineTokenizer> tokenizers) {
65                Assert.isTrue(!tokenizers.isEmpty(), "The 'tokenizers' property must be non-empty");
66                this.tokenizers = new PatternMatcher<LineTokenizer>(tokenizers);
67        }
68}

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