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

COVERAGE SUMMARY FOR SOURCE FILE [CountPatternStreamPacker.java]

nameclass, %method, %block, %line, %
CountPatternStreamPacker.java100% (1/1)100% (2/2)87%  (123/142)90%  (26/29)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CountPatternStreamPacker100% (1/1)100% (2/2)87%  (123/142)90%  (26/29)
process (ComplexEvent): void 100% (1/1)86%  (119/138)89%  (24/27)
CountPatternStreamPacker (CountPatternState): 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.pattern;
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.pattern.CountPatternState;
24import org.wso2.siddhi.core.statemachine.pattern.LogicPatternState;
25import org.wso2.siddhi.core.stream.recevier.pattern.CountPatternSingleStreamReceiver;
26 
27public class CountPatternStreamPacker extends PatternStreamPacker {
28 
29    public CountPatternStreamPacker(CountPatternState state) {
30        super(state);
31    }
32 
33    public void process(ComplexEvent complexEvent) {
34        //System.out.println("cp state=" + state.getStateNumber() + " event=" + complexEvent);
35        ((CountPatternSingleStreamReceiver) streamReceiver).setPassed(true);
36        if (((StateEvent) complexEvent).getEventState() <= (state.getStateNumber())) {
37            setEventState((StateEvent) complexEvent);
38            int activeEvents = 0;
39            ListEvent listEvent = ((ListEvent) ((StateEvent) complexEvent).getStreamEvent(state.getStateNumber()));
40            if (listEvent != null) {
41                activeEvents = listEvent.getActiveEvents();
42            }
43//            //System.out.println(" active "+activeEvents);
44//            int activeEvents = ((SingleEventList) ((StateEvent) complexEvent).getStreamEvent(state.getStateNumber())).getActiveEvents();
45            if (state.isLast()) {
46                sendEvent((StateEvent)complexEvent);
47            }
48 
49 
50            //passToStreamReceivers
51            if (activeEvents < ((CountPatternState) state).getMin()) {
52                //System.out.println("->" + state.getStateNumber());
53                ((CountPatternSingleStreamReceiver) streamReceiver).addOnlyToNextEvents((StateEvent) complexEvent);
54            } else if (activeEvents == ((CountPatternState) state).getMin() ) {
55                if (nextState != null) {
56                    //System.out.println("->" + nextState.getStateNumber());
57                    if (nextState instanceof LogicPatternState) {
58                        //System.out.println("->" + ((LogicPatternState) nextState).getPartnerState().getStateNumber());
59                        ((LogicPatternState) nextState).getPartnerState().getPatternSingleStreamReceiver().addToNextEvents((StateEvent) complexEvent);
60                    }
61                    nextState.getPatternSingleStreamReceiver().addToNextEvents((StateEvent) complexEvent);
62                    ((CountPatternSingleStreamReceiver) streamReceiver).addOnlyToNextEvents((StateEvent) complexEvent);
63                }
64                if (nextEveryState != null) {
65                    //System.out.println("->" + nextEveryState.getStateNumber());
66                    StateEvent newStateEvent = ((StateEvent) complexEvent).cloneEvent(nextEveryState.getStateNumber());
67                    newStateEvent.setEventState(nextEveryState.getStateNumber() - 1);
68                    if (nextEveryState instanceof LogicPatternState) {
69                        //System.out.println("->" + ((LogicPatternState) nextEveryState).getPartnerState().getStateNumber());
70                        ((LogicPatternState) nextEveryState).getPartnerState().getPatternSingleStreamReceiver().addToNextEvents(newStateEvent);
71                    }
72                    nextEveryState.getPatternSingleStreamReceiver().addToNextEvents(newStateEvent);
73                }
74            } else if (activeEvents >= ((CountPatternState) state).getMin() && activeEvents <= ((CountPatternState) state).getMax()) {
75                ((CountPatternSingleStreamReceiver) streamReceiver).addOnlyToNextEvents((StateEvent) complexEvent);
76                //System.out.println("->" + state.getStateNumber());
77//                if (state.getNextStateListSize() > 0) {
78//                    for (State nextState : state.getNextStates()) {
79//                        StateEvent complexEvent = ((StateEvent) complexEvent).cloneEvent();
80//                        if (nextState instanceof LogicState) {
81//                            ((LogicState) nextState).getPartnerState().getPatternSingleStreamReceiver().addToNextEvents(complexEvent);
82//                        }
83//                        nextState.getPatternSingleStreamReceiver().addToNextEvents(complexEvent);
84//                    }
85//                }
86 
87            }
88        }
89    }
90}

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