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

nameclass, %method, %block, %line, %
SequenceStreamPacker.java100% (1/1)100% (6/6)100% (62/62)100% (20/20)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SequenceStreamPacker100% (1/1)100% (6/6)100% (62/62)100% (20/20)
SequenceStreamPacker (SequenceState): void 100% (1/1)100% (10/10)100% (4/4)
passToStreamReceivers (StateEvent): void 100% (1/1)100% (20/20)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 (SequenceSingleStreamReceiver): 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.AtomicEvent;
21import org.wso2.siddhi.core.event.ComplexEvent;
22import org.wso2.siddhi.core.event.in.StateEvent;
23import org.wso2.siddhi.core.statemachine.sequence.OrSequenceState;
24import org.wso2.siddhi.core.statemachine.sequence.SequenceState;
25import org.wso2.siddhi.core.stream.packer.SingleStreamPacker;
26import org.wso2.siddhi.core.stream.recevier.sequence.SequenceSingleStreamReceiver;
27 
28public class SequenceStreamPacker extends SingleStreamPacker {
29 
30    protected SequenceSingleStreamReceiver streamReceiver;
31    protected SequenceState state;
32    protected SequenceState nextState;
33 
34    public SequenceStreamPacker(SequenceState state) {
35        this.state = state;
36        this.nextState = state.getNextState();
37    }
38 
39    public void setStreamReceiver(SequenceSingleStreamReceiver streamReceiver) {
40        this.streamReceiver = streamReceiver;
41    }
42 
43    @Override
44    public void process(ComplexEvent complexEvent) {
45        //System.out.println("sp state=" + state.getStateNumber() + " event=" + complexEvent);
46        setEventState((StateEvent) complexEvent);
47        if (state.isLast()) {
48            sendEvent((StateEvent)complexEvent);
49        }
50        passToStreamReceivers((StateEvent) complexEvent);
51    }
52 
53    protected void setEventState(StateEvent eventBundle) {
54        eventBundle.setEventState(state.getStateNumber());
55    }
56 
57    protected void sendEvent(AtomicEvent atomicEvent) {
58        queryProjector.process(atomicEvent);
59    }
60 
61    protected void passToStreamReceivers(StateEvent eventBundle) {
62        if (nextState != null) {
63            //System.out.println("->" + nextState.getStateNumber());
64            if (nextState instanceof OrSequenceState) {
65                //System.out.println("->" + ((OrSequenceState) nextState).getPartnerState().getStateNumber());
66                ((OrSequenceState) nextState).getPartnerState().getSequenceSingleStreamReceiver().addToNextEvents(eventBundle);
67            }
68            nextState.getSequenceSingleStreamReceiver().addToNextEvents(eventBundle);
69        }
70    }
71}

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