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 [PatternStreamPacker.java]

nameclass, %method, %block, %line, %
PatternStreamPacker.java100% (1/1)100% (6/6)93%  (91/98)96%  (26/27)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PatternStreamPacker100% (1/1)100% (6/6)93%  (91/98)96%  (26/27)
passToStreamReceivers (StateEvent): void 100% (1/1)87%  (45/52)91%  (10/11)
PatternStreamPacker (PatternState): void 100% (1/1)100% (14/14)100% (5/5)
process (ComplexEvent): void 100% (1/1)100% (17/17)100% (5/5)
sendEvent (AtomicEvent): void 100% (1/1)100% (5/5)100% (2/2)
setEventState (StateEvent): void 100% (1/1)100% (6/6)100% (2/2)
setStreamReceiver (PatternSingleStreamReceiver): 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.AtomicEvent;
21import org.wso2.siddhi.core.event.in.StateEvent;
22import org.wso2.siddhi.core.event.ComplexEvent;
23import org.wso2.siddhi.core.statemachine.pattern.LogicPatternState;
24import org.wso2.siddhi.core.statemachine.pattern.PatternState;
25import org.wso2.siddhi.core.stream.packer.SingleStreamPacker;
26import org.wso2.siddhi.core.stream.recevier.pattern.PatternSingleStreamReceiver;
27 
28public class PatternStreamPacker extends SingleStreamPacker {
29 
30    protected PatternSingleStreamReceiver streamReceiver;
31    protected PatternState state;
32    protected PatternState nextState;
33    protected PatternState nextEveryState;
34 
35    public PatternStreamPacker(PatternState state) {
36        this.state = state;
37        this.nextState = state.getNextState();
38        this.nextEveryState = state.getNextEveryState();
39    }
40 
41    public void setStreamReceiver(PatternSingleStreamReceiver streamReceiver) {
42        this.streamReceiver = streamReceiver;
43    }
44 
45    @Override
46    public void process(ComplexEvent complexEvent) {
47        //System.out.println("pp state=" + state.getStateNumber() + " event=" + complexEvent);
48        setEventState((StateEvent) complexEvent);
49        if (state.isLast()) {
50            sendEvent((StateEvent)complexEvent);
51        }
52        passToStreamReceivers((StateEvent) complexEvent);
53    }
54 
55    protected void setEventState(StateEvent eventBundle) {
56        eventBundle.setEventState(state.getStateNumber());
57    }
58 
59    protected void sendEvent(AtomicEvent atomicEvent) {
60        queryProjector.process(atomicEvent);
61    }
62 
63    protected void passToStreamReceivers(StateEvent eventBundle) {
64        if (nextState != null) {
65            //System.out.println("->" + nextState.getStateNumber());
66            if (nextState instanceof LogicPatternState) {
67                //System.out.println("->" + ((LogicPatternState) nextState).getPartnerState().getStateNumber());
68                ((LogicPatternState) nextState).getPartnerState().getPatternSingleStreamReceiver().addToNextEvents(eventBundle);
69            }
70            nextState.getPatternSingleStreamReceiver().addToNextEvents(eventBundle);
71        }
72        if (nextEveryState != null) {
73            //System.out.println("->" + nextEveryState.getStateNumber());
74            StateEvent newStateEvent = eventBundle.cloneEvent(nextEveryState.getStateNumber());
75            newStateEvent.setEventState(nextEveryState.getStateNumber() - 1);
76            if (nextEveryState instanceof LogicPatternState) {
77                //System.out.println("->" + ((LogicPatternState) nextEveryState).getPartnerState().getStateNumber());
78                ((LogicPatternState) nextEveryState).getPartnerState().getPatternSingleStreamReceiver().addToNextEvents(newStateEvent);
79            }
80            nextEveryState.getPatternSingleStreamReceiver().addToNextEvents(newStateEvent);
81        }
82    }
83}

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