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 [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        public FieldSet tokenize(String line) {
49                return tokenizers.match(line).tokenize(line);
50        }
51 
52        /*
53         * (non-Javadoc)
54         * 
55         * @see
56         * org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
57         */
58        public void afterPropertiesSet() throws Exception {
59                Assert.isTrue(this.tokenizers != null, "The 'tokenizers' property must be non-empty");
60        }
61 
62        public void setTokenizers(Map<String, LineTokenizer> tokenizers) {
63                Assert.isTrue(!tokenizers.isEmpty(), "The 'tokenizers' property must be non-empty");
64                this.tokenizers = new PatternMatcher<LineTokenizer>(tokenizers);
65        }
66}

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