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

COVERAGE SUMMARY FOR SOURCE FILE [PatternSingleStreamReceiver.java]

nameclass, %method, %block, %line, %
PatternSingleStreamReceiver.java100% (1/1)71%  (5/7)94%  (102/109)93%  (27/29)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PatternSingleStreamReceiver100% (1/1)71%  (5/7)94%  (102/109)93%  (27/29)
getStreamId (): String 0%   (0/1)0%   (0/5)0%   (0/1)
getWindow (): SchedulerQueue 0%   (0/1)0%   (0/2)0%   (0/1)
PatternSingleStreamReceiver (PatternState, StreamProcessor, int): void 100% (1/1)100% (38/38)100% (11/11)
addToNextEvents (StateEvent): void 100% (1/1)100% (6/6)100% (2/2)
init (): void 100% (1/1)100% (13/13)100% (3/3)
moveNextEventsToCurrentEvents (): void 100% (1/1)100% (10/10)100% (3/3)
receive (StreamEvent): void 100% (1/1)100% (35/35)100% (8/8)

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.pattern;
19 
20import org.wso2.siddhi.core.event.StreamEvent;
21import org.wso2.siddhi.core.event.in.StateEvent;
22import org.wso2.siddhi.core.util.SchedulerQueue;
23import org.wso2.siddhi.core.statemachine.pattern.PatternState;
24import org.wso2.siddhi.core.stream.StreamElement;
25import org.wso2.siddhi.core.stream.StreamProcessor;
26import org.wso2.siddhi.core.stream.recevier.StreamReceiver;
27 
28import java.util.LinkedList;
29import java.util.List;
30 
31public class PatternSingleStreamReceiver implements StreamReceiver, StreamElement {
32    protected int complexEventSize;
33    protected PatternState state;
34    protected PatternState nextState;
35    protected PatternState nextEveryState;
36    protected StreamProcessor firstSimpleStreamProcessor;
37    protected List<StateEvent> currentEvents = new LinkedList<StateEvent>();
38    protected List<StateEvent> nextEvents = new LinkedList<StateEvent>();
39    //    private final boolean first;
40    protected final int currentState;
41 
42 
43    public PatternSingleStreamReceiver(PatternState state,
44                                       StreamProcessor firstSimpleStreamProcessor,
45                                       int complexEventSize) {
46        this.state = state;
47        this.nextState = state.getNextState();
48        this.nextEveryState = state.getNextEveryState();
49        this.currentState = state.getStateNumber();
50        this.complexEventSize = complexEventSize;
51        this.firstSimpleStreamProcessor = firstSimpleStreamProcessor;
52        this.firstSimpleStreamProcessor.setPrevious(this);
53//        init(state, complexEventSize);
54    }
55 
56    public void init() {
57        if (state.isFirst()) {
58            //first event
59            addToNextEvents(new StateEvent(new StreamEvent[complexEventSize]));
60        }
61    }
62 
63    @Override
64    public void receive(StreamEvent event) {
65        //System.out.println("pr state=" +currentState+" event="+ event+" ||currentEvents="+currentEvents);
66        for (StateEvent currentEvent : currentEvents) {
67 
68            currentEvent.setStreamEvent(currentState, event);
69            firstSimpleStreamProcessor.process(currentEvent);
70            if ( currentEvent.getEventState()<currentState) {
71                currentEvent.setStreamEvent(currentState, null);
72                addToNextEvents(currentEvent);
73            }
74        }
75//        currentEvents.clear();
76//        }
77    }
78 
79    public String getStreamId() {
80        return state.getSingleStream().getStreamId();
81    }
82 
83    @Override
84    public SchedulerQueue<StreamEvent> getWindow() {
85        return null;
86    }
87 
88    public synchronized void addToNextEvents(StateEvent stateEvent) {
89//        //System.out.println("add to next ss");
90        nextEvents.add(stateEvent);
91    }
92 
93    public synchronized void moveNextEventsToCurrentEvents() {
94        //todo need to check which is faster
95        // 1
96//        currentEvents.clear();
97//        currentEvents.addAll(nextEvents);
98//        nextEvents.clear();
99 
100//        // 2
101        currentEvents = nextEvents;
102        nextEvents = new LinkedList<StateEvent>();
103    }
104 
105}

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