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

COVERAGE SUMMARY FOR SOURCE FILE [MinAggregateAttributeGenerator.java]

nameclass, %method, %block, %line, %
MinAggregateAttributeGenerator.java0%   (0/1)0%   (0/6)0%   (0/59)0%   (0/14)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class MinAggregateAttributeGenerator0%   (0/1)0%   (0/6)0%   (0/59)0%   (0/14)
MinAggregateAttributeGenerator (): void 0%   (0/1)0%   (0/3)0%   (0/2)
MinAggregateAttributeGenerator (Aggregator, ExpressionExecutor): void 0%   (0/1)0%   (0/9)0%   (0/4)
assignExpressions (Expression [], List): void 0%   (0/1)0%   (0/15)0%   (0/3)
createNewInstance (): AbstractAggregateAttributeGenerator 0%   (0/1)0%   (0/9)0%   (0/1)
getType (): Attribute$Type 0%   (0/1)0%   (0/4)0%   (0/1)
process (AtomicEvent): Object 0%   (0/1)0%   (0/19)0%   (0/3)

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.projector.attibute.generator;
19 
20import org.wso2.siddhi.core.event.AtomicEvent;
21import org.wso2.siddhi.core.event.remove.RemoveStream;
22import org.wso2.siddhi.core.executor.expression.ExpressionExecutor;
23import org.wso2.siddhi.core.projector.attibute.aggregator.Aggregator;
24import org.wso2.siddhi.core.util.parser.AggregatorParser;
25import org.wso2.siddhi.core.util.parser.ExecutorParser;
26import org.wso2.siddhi.query.api.definition.Attribute;
27import org.wso2.siddhi.query.api.expression.Expression;
28import org.wso2.siddhi.query.api.query.QueryEventStream;
29 
30import java.util.List;
31 
32public class MinAggregateAttributeGenerator extends AbstractAggregateAttributeGenerator {
33    private ExpressionExecutor expressionExecutor;
34    private Aggregator aggregator;
35 
36    public MinAggregateAttributeGenerator() {
37    }
38 
39    private MinAggregateAttributeGenerator(Aggregator aggregator,
40                                           ExpressionExecutor expressionExecutor) {
41        this.aggregator = aggregator;
42        this.expressionExecutor = expressionExecutor;
43    }
44 
45    @Override
46    public void assignExpressions(Expression[] expressions,
47                                  List<QueryEventStream> queryEventStreamList) {
48        expressionExecutor = ExecutorParser.parseExpression(expressions[0], queryEventStreamList, null);
49        aggregator = AggregatorParser.createMinAggregator(expressionExecutor.getType());
50    }
51 
52    @Override
53    public AbstractAggregateAttributeGenerator createNewInstance() {
54        return new MinAggregateAttributeGenerator(aggregator.createNewInstance(),expressionExecutor);
55    }
56 
57    @Override
58    public Attribute.Type getType() {
59        return aggregator.getType();
60    }
61 
62    @Override
63    public Object process(AtomicEvent event) {
64        if (event instanceof RemoveStream) {
65            return aggregator.remove(expressionExecutor.execute(event));
66        } else {
67            return aggregator.add(expressionExecutor.execute(event));
68        }
69    }
70}

[all classes][org.wso2.siddhi.core.projector.attibute.generator]
EMMA 2.1.5320 (stable) (C) Vladimir Roubtsov