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

COVERAGE SUMMARY FOR SOURCE FILE [CountSequenceSingleStreamReceiver.java]

nameclass, %method, %block, %line, %
CountSequenceSingleStreamReceiver.java100% (1/1)100% (6/6)100% (107/107)100% (29/29)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CountSequenceSingleStreamReceiver100% (1/1)100% (6/6)100% (107/107)100% (29/29)
CountSequenceSingleStreamReceiver (CountSequenceState, StreamProcessor, int):... 100% (1/1)100% (20/20)100% (6/6)
addOnlyToNextEvents (StateEvent): void 100% (1/1)100% (6/6)100% (2/2)
addToNextEvents (StateEvent): void 100% (1/1)100% (18/18)100% (4/4)
isPassed (): boolean 100% (1/1)100% (3/3)100% (1/1)
sendForProcess (StreamEvent): void 100% (1/1)100% (56/56)100% (14/14)
setPassed (boolean): 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.recevier.sequence;
19 
20import org.wso2.siddhi.core.event.Event;
21import org.wso2.siddhi.core.event.ListEvent;
22import org.wso2.siddhi.core.event.StreamEvent;
23import org.wso2.siddhi.core.event.in.InListEvent;
24import org.wso2.siddhi.core.event.in.StateEvent;
25import org.wso2.siddhi.core.statemachine.sequence.CountSequenceState;
26import org.wso2.siddhi.core.stream.StreamProcessor;
27 
28public class CountSequenceSingleStreamReceiver extends SequenceSingleStreamReceiver {
29 
30    private int min = -1;
31    private int max = -1;
32    private boolean passed;
33 
34    public CountSequenceSingleStreamReceiver(CountSequenceState state,
35                                             StreamProcessor firstSimpleStreamProcessor,
36                                             int complexEventSize) {
37        super(state, firstSimpleStreamProcessor, complexEventSize);
38        this.min = state.getMin();
39        this.max = state.getMax();
40 
41    }
42 
43//    @Override
44//    public void receive(Event event) {
45//        if (checkReset(event)) {
46//            return;
47//        }
48//        //System.out.println("cr state=" + currentState + " event=" + event + " ||currentEvents=" + currentEvents);
49//        for (StateEvent currentEvent : currentEvents) {
50//
51//            if (currentEvent.getEventState() <= (state.getStateNumber())) {
52//                SingleEventList singleEventList = (SingleEventList) currentEvent.getStreamEvent(currentState);
53//                if (singleEventList == null) {
54//                    singleEventList = new SingleEventList(max);
55//                    currentEvent.setStreamEvent(currentState, singleEventList);
56//                }
57//                setPassed(false);
58//                singleEventList.addEvent(((Event) event));
59//                firstSimpleStreamProcessor.process(currentEvent);
60//
61//                if (!isPassed()) {
62//                    singleEventList.removeLast();  //to stop aggregation of not passed events
63////                    nextEvents.add(currentEvent);   //only to add to itself
64//                }
65//                init();
66//
67//            }
68//        }
69////        currentEvents.clear();
70////        }
71//    }
72 
73    protected void sendForProcess(StreamEvent streamEvent) {
74        //System.out.println("cr state=" + currentState + " event=" + streamEvent + " ||currentEvents=" + currentEvents);
75        for (StateEvent currentEvent : currentEvents) {
76 
77            if (currentEvent.getEventState() <= (state.getStateNumber())) {
78                ListEvent listEvent = (ListEvent) currentEvent.getStreamEvent(currentState);
79                if (listEvent == null) {
80                    listEvent = new InListEvent(max);
81                    currentEvent.setStreamEvent(currentState, listEvent);
82                }
83                setPassed(false);
84                if (!listEvent.addEvent(((Event) streamEvent))) {
85                    continue;
86                }
87                firstSimpleStreamProcessor.process(currentEvent);
88 
89                if (!isPassed()) {
90                    listEvent.removeLast();  //to stop aggregation of not passed events
91//                    nextEvents.add(currentEvent);   //only to add to itself
92                }
93//                init();
94            }
95        }
96    }
97 
98//    protected InComplexEvent createFirstEvent(int complexEventSize) {
99//        return new InComplexEvent(new SingleEventBundle[complexEventSize]);
100//    }
101 
102    public synchronized void addToNextEvents(StateEvent stateEvent) {
103//        //System.out.println("in");
104        if (min == 0) {
105            state.getSequenceStreamPacker().process(stateEvent.cloneEvent(currentState));
106//
107//            if (stateEvent.getEventState() < currentState) {
108//                if (nextState != null) {
109//                    if (nextState instanceof OrSequenceState) {
110//                        ((OrSequenceState) nextState).getPartnerState().getSequenceSingleStreamReceiver().addToNextEvents(stateEvent);
111//                    }
112//                    nextState.getSequenceSingleStreamReceiver().addToNextEvents(stateEvent);
113////                    nextEvents.add(stateEvent);//to keep the reference of the next events
114//                }
115//            }
116        } else {
117            nextEvents.add(stateEvent);
118        }
119    }
120 
121    public synchronized void setPassed(boolean passed) {
122        this.passed = passed;
123    }
124 
125    public synchronized boolean isPassed() {
126        return passed;
127    }
128 
129    public void addOnlyToNextEvents(StateEvent stateEvent) {
130        nextEvents.add(stateEvent);
131    }
132}

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