EMMA Coverage Report (generated Tue Jul 10 07:50:22 IST 2012)
[all classes][org.wso2.siddhi.query.api.stream.pattern]

COVERAGE SUMMARY FOR SOURCE FILE [PatternStream.java]

nameclass, %method, %block, %line, %
PatternStream.java100% (1/1)50%  (3/6)51%  (88/171)55%  (18/33)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PatternStream100% (1/1)50%  (3/6)51%  (88/171)55%  (18/33)
constructEventStreamList (PatternElement, Map, List): List 0%   (0/1)0%   (0/73)0%   (0/13)
constructQueryEventStreamList (Map, List): List 0%   (0/1)0%   (0/7)0%   (0/1)
getPatternElement (): PatternElement 0%   (0/1)0%   (0/3)0%   (0/1)
PatternStream (PatternElement): void 100% (1/1)100% (17/17)100% (4/4)
collectStreamIds (PatternElement, HashSet): HashSet 100% (1/1)100% (68/68)100% (13/13)
getStreamIds (): List 100% (1/1)100% (3/3)100% (1/1)

1/*
2*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3*
4*  WSO2 Inc. licenses this file to you under the Apache License,
5*  Version 2.0 (the "License"); you may not use this file except
6*  in compliance with the License.
7*  You may obtain a copy of the License at
8*
9*    http://www.apache.org/licenses/LICENSE-2.0
10*
11* Unless required by applicable law or agreed to in writing,
12* software distributed under the License is distributed on an
13* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14* KIND, either express or implied.  See the License for the
15* specific language governing permissions and limitations
16* under the License.
17*/
18package org.wso2.siddhi.query.api.stream.pattern;
19 
20import org.wso2.siddhi.query.api.query.QueryEventStream;
21import org.wso2.siddhi.query.api.stream.SingleStream;
22import org.wso2.siddhi.query.api.stream.Stream;
23import org.wso2.siddhi.query.api.definition.StreamDefinition;
24import org.wso2.siddhi.query.api.stream.pattern.element.CountElement;
25import org.wso2.siddhi.query.api.stream.pattern.element.FollowedByElement;
26import org.wso2.siddhi.query.api.stream.pattern.element.LogicalElement;
27import org.wso2.siddhi.query.api.stream.pattern.element.PatternElement;
28 
29import java.util.ArrayList;
30import java.util.HashSet;
31import java.util.List;
32import java.util.Map;
33 
34public class PatternStream implements Stream, PatternElement {
35 
36    private PatternElement patternElement;
37    private List<String> streamIdList;
38 
39    public PatternStream(PatternElement patternElement) {
40        this.patternElement = patternElement;
41        this.streamIdList = new ArrayList<String>(collectStreamIds(patternElement, new HashSet<String>()));
42    }
43 
44    @Override
45    public List<String> getStreamIds() {
46        return streamIdList;
47    }
48 
49    @Override
50    public List<QueryEventStream> constructQueryEventStreamList(
51            Map<String, StreamDefinition> streamDefinitionMap,
52            List<QueryEventStream> queryEventStreams) {
53        return constructEventStreamList(patternElement, streamDefinitionMap, queryEventStreams);
54    }
55 
56    public PatternElement getPatternElement() {
57        return patternElement;
58    }
59 
60    private HashSet<String> collectStreamIds(PatternElement patternElement,
61                                             HashSet<String> streamIds) {
62        if (patternElement instanceof PatternStream) {
63            streamIds.addAll(((PatternStream) patternElement).getStreamIds());
64        } else if (patternElement instanceof SingleStream) {
65            streamIds.addAll(((SingleStream) patternElement).getStreamIds());
66        } else if (patternElement instanceof LogicalElement) {
67            collectStreamIds(((LogicalElement) patternElement).getSingleStream1(), streamIds);
68            collectStreamIds(((LogicalElement) patternElement).getSingleStream2(), streamIds);
69        } else if (patternElement instanceof CountElement) {
70            collectStreamIds(((CountElement) patternElement).getSingleStream(), streamIds);
71        } else if (patternElement instanceof FollowedByElement) {
72            collectStreamIds(((FollowedByElement) patternElement).getPatternElement(), streamIds);
73            collectStreamIds(((FollowedByElement) patternElement).getFollowedByPatternElement(), streamIds);
74        }
75        return streamIds;
76    }
77 
78    public List<QueryEventStream> constructEventStreamList(PatternElement patternElement,
79                                                           Map<String, StreamDefinition> streamDefinitionMap,
80                                                           List<QueryEventStream> queryEventStreams) {
81 
82 
83        if (patternElement instanceof SingleStream) {
84            ((SingleStream) patternElement).constructQueryEventStreamList(streamDefinitionMap, queryEventStreams);
85        } else if (patternElement instanceof LogicalElement) {
86            constructEventStreamList(((LogicalElement) patternElement).getSingleStream1(), streamDefinitionMap, queryEventStreams);
87            constructEventStreamList(((LogicalElement) patternElement).getSingleStream2(), streamDefinitionMap, queryEventStreams);
88        } else if (patternElement instanceof CountElement) {
89            constructEventStreamList(((CountElement) patternElement).getSingleStream(), streamDefinitionMap, queryEventStreams);
90        } else if (patternElement instanceof FollowedByElement) {
91            constructEventStreamList(((FollowedByElement) patternElement).getPatternElement(), streamDefinitionMap, queryEventStreams);
92            constructEventStreamList(((FollowedByElement) patternElement).getFollowedByPatternElement(), streamDefinitionMap, queryEventStreams);
93        } else if (patternElement instanceof PatternStream) {
94            ((PatternStream) patternElement).constructQueryEventStreamList(streamDefinitionMap, queryEventStreams);
95        }
96 
97        return queryEventStreams;
98    }
99}

[all classes][org.wso2.siddhi.query.api.stream.pattern]
EMMA 2.1.5320 (stable) (C) Vladimir Roubtsov