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

COVERAGE SUMMARY FOR SOURCE FILE [SequenceStream.java]

nameclass, %method, %block, %line, %
SequenceStream.java100% (1/1)33%  (2/6)32%  (55/171)39%  (13/33)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SequenceStream100% (1/1)33%  (2/6)32%  (55/171)39%  (13/33)
constructEventStreamList (SequenceElement, 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)
getSequenceElement (): SequenceElement 0%   (0/1)0%   (0/3)0%   (0/1)
getStreamIds (): List 0%   (0/1)0%   (0/3)0%   (0/1)
collectStreamIds (SequenceElement, HashSet): HashSet 100% (1/1)56%  (38/68)69%  (9/13)
SequenceStream (SequenceElement): void 100% (1/1)100% (17/17)100% (4/4)

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.sequence;
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.sequence.element.RegexElement;
25import org.wso2.siddhi.query.api.stream.sequence.element.NextElement;
26import org.wso2.siddhi.query.api.stream.sequence.element.OrElement;
27import org.wso2.siddhi.query.api.stream.sequence.element.SequenceElement;
28 
29import java.util.ArrayList;
30import java.util.HashSet;
31import java.util.List;
32import java.util.Map;
33 
34public class SequenceStream implements Stream, SequenceElement {
35    private SequenceElement sequenceElement;
36    private List<String> streamIdList;
37 
38    public SequenceStream(SequenceElement sequenceElement) {
39        this.sequenceElement = sequenceElement;
40        this.streamIdList = new ArrayList<String>(collectStreamIds(sequenceElement, new HashSet<String>()));
41    }
42 
43    public SequenceElement getSequenceElement() {
44        return sequenceElement;
45    }
46 
47    @Override
48    public List<String> getStreamIds() {
49        return streamIdList;
50    }
51 
52    @Override
53    public List<QueryEventStream> constructQueryEventStreamList(
54            Map<String, StreamDefinition> streamDefinitionMap,
55            List<QueryEventStream> queryEventStreams) {
56        return constructEventStreamList(getSequenceElement(), streamDefinitionMap, queryEventStreams);
57    }
58    private HashSet<String> collectStreamIds(SequenceElement sequenceElement,
59                                             HashSet<String> streamIds) {
60        if (sequenceElement instanceof SequenceStream) {
61            streamIds.addAll(((SequenceStream) sequenceElement).getStreamIds());
62        } else if (sequenceElement instanceof SingleStream) {
63            streamIds.addAll(((SingleStream) sequenceElement).getStreamIds());
64        } else if (sequenceElement instanceof OrElement) {
65            collectStreamIds(((OrElement) sequenceElement).getSingleStream1(), streamIds);
66            collectStreamIds(((OrElement) sequenceElement).getSingleStream2(), streamIds);
67        } else if (sequenceElement instanceof RegexElement) {
68            collectStreamIds(((RegexElement) sequenceElement).getSingleStream(), streamIds);
69        } else if (sequenceElement instanceof NextElement) {
70            collectStreamIds(((NextElement) sequenceElement).getSequenceElement(), streamIds);
71            collectStreamIds(((NextElement) sequenceElement).getNextSequenceElement(), streamIds);
72        }
73        return streamIds;
74    }
75 
76    public List<QueryEventStream> constructEventStreamList(SequenceElement sequenceElement,
77                                                           Map<String, StreamDefinition> streamDefinitionMap,
78                                                           List<QueryEventStream> queryEventStreams) {
79 
80 
81        if (sequenceElement instanceof SingleStream) {
82            ((SingleStream) sequenceElement).constructQueryEventStreamList(streamDefinitionMap, queryEventStreams);
83        } else if (sequenceElement instanceof OrElement) {
84            constructEventStreamList(((OrElement) sequenceElement).getSingleStream1(), streamDefinitionMap, queryEventStreams);
85            constructEventStreamList(((OrElement) sequenceElement).getSingleStream2(), streamDefinitionMap, queryEventStreams);
86        } else if (sequenceElement instanceof RegexElement) {
87            constructEventStreamList(((RegexElement) sequenceElement).getSingleStream(), streamDefinitionMap, queryEventStreams);
88        } else if (sequenceElement instanceof NextElement) {
89            constructEventStreamList(((NextElement) sequenceElement).getSequenceElement(), streamDefinitionMap, queryEventStreams);
90            constructEventStreamList(((NextElement) sequenceElement).getNextSequenceElement(), streamDefinitionMap, queryEventStreams);
91        } else if (sequenceElement instanceof SequenceStream) {
92            ((SequenceStream) sequenceElement).constructQueryEventStreamList(streamDefinitionMap, queryEventStreams);
93        }
94 
95        return queryEventStreams;
96    }
97}

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