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

COVERAGE SUMMARY FOR SOURCE FILE [CountSequenceStreamPacker.java]

nameclass, %method, %block, %line, %
CountSequenceStreamPacker.java100% (1/1)100% (2/2)86%  (93/108)90%  (18/20)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CountSequenceStreamPacker100% (1/1)100% (2/2)86%  (93/108)90%  (18/20)
process (ComplexEvent): void 100% (1/1)86%  (89/104)89%  (16/18)
CountSequenceStreamPacker (CountSequenceState): void 100% (1/1)100% (4/4)100% (2/2)

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.core.stream.packer.sequence;
19 
20import org.wso2.siddhi.core.event.ComplexEvent;
21import org.wso2.siddhi.core.event.ListEvent;
22import org.wso2.siddhi.core.event.in.StateEvent;
23import org.wso2.siddhi.core.statemachine.sequence.CountSequenceState;
24import org.wso2.siddhi.core.statemachine.sequence.OrSequenceState;
25import org.wso2.siddhi.core.stream.recevier.sequence.CountSequenceSingleStreamReceiver;
26import org.wso2.siddhi.query.api.utils.SiddhiConstants;
27 
28public class CountSequenceStreamPacker extends SequenceStreamPacker {
29 
30    public CountSequenceStreamPacker(CountSequenceState state) {
31        super(state);
32    }
33 
34    public void process(ComplexEvent complexEvent) {
35        //System.out.println("cp state=" + state.getStateNumber() + " event=" + complexEvent);
36        ((CountSequenceSingleStreamReceiver) streamReceiver).setPassed(true);
37        if (((StateEvent) complexEvent).getEventState() <= (state.getStateNumber())) {
38            setEventState((StateEvent) complexEvent);
39            int activeEvents = 0;
40            ListEvent listEvent = ((ListEvent) ((StateEvent) complexEvent).getStreamEvent(state.getStateNumber()));
41            if (listEvent != null) {
42                activeEvents = listEvent.getActiveEvents();
43            }
44//            //System.out.println(" active "+activeEvents);
45//            int activeEvents = ((SingleEventList) ((StateEvent) complexEvent).getStreamEvent(state.getStateNumber())).getActiveEvents();
46            if (state.isLast()) {
47                sendEvent((StateEvent)complexEvent);
48            }
49            //passToStreamReceivers
50            if (activeEvents < ((CountSequenceState) state).getMin()) {
51                //System.out.println("->" + state.getStateNumber());
52                ((CountSequenceSingleStreamReceiver) streamReceiver).addOnlyToNextEvents((StateEvent) complexEvent);
53            } else if (activeEvents >= ((CountSequenceState) state).getMin() && activeEvents <= ((CountSequenceState) state).getMax()||activeEvents >= ((CountSequenceState) state).getMin() && ((CountSequenceState) state).getMax()== SiddhiConstants.UNLIMITED) {
54                if (nextState != null) {
55                    //System.out.println("->" + nextState.getStateNumber());
56                    if (nextState instanceof OrSequenceState) {
57                        //System.out.println("->" + ((OrSequenceState) nextState).getPartnerState().getStateNumber());
58                        ((OrSequenceState) nextState).getPartnerState().getSequenceSingleStreamReceiver().addToNextEvents((StateEvent) complexEvent);
59                    }
60                    nextState.getSequenceSingleStreamReceiver().addToNextEvents((StateEvent) complexEvent);
61                    ((CountSequenceSingleStreamReceiver) streamReceiver).addOnlyToNextEvents((StateEvent) complexEvent);
62                }
63//            } else if (activeEvents >= ((CountSequenceState) state).getMin() && activeEvents <= ((CountSequenceState) state).getMax()||activeEvents >= ((CountSequenceState) state).getMin() && ((CountSequenceState) state).getMax()==RegexElement.UNLIMITED) {
64//                //System.out.println("->" + state.getStateNumber());
65//                ((CountSequenceSingleStreamReceiver) streamReceiver).addOnlyToNextEvents((StateEvent) complexEvent);
66////                if (state.getNextStateListSize() > 0) {
67////                    for (State nextState : state.getNextStates()) {
68////                        StateEvent complexEvent = ((StateEvent) complexEvent).cloneEvent();
69////                        if (nextState instanceof LogicState) {
70////                            ((LogicState) nextState).getPartnerState().getPatternSingleStreamReceiver().addToNextEvents(complexEvent);
71////                        }
72////                        nextState.getPatternSingleStreamReceiver().addToNextEvents(complexEvent);
73////                    }
74////                }
75 
76            }
77        }
78    }
79}

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