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

COVERAGE SUMMARY FOR SOURCE FILE [AggregatorParser.java]

nameclass, %method, %block, %line, %
AggregatorParser.java100% (2/2)43%  (3/7)29%  (71/243)8%   (2.9/34)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AggregatorParser100% (1/1)33%  (2/6)15%  (30/196)9%   (3/34)
AggregatorParser (): void 0%   (0/1)0%   (0/3)0%   (0/2)
createAvgAggregator (Attribute$Type): Aggregator 0%   (0/1)0%   (0/43)0%   (0/8)
createMaxAggregator (Attribute$Type): Aggregator 0%   (0/1)0%   (0/43)0%   (0/8)
createMinAggregator (Attribute$Type): Aggregator 0%   (0/1)0%   (0/43)0%   (0/8)
createSumAggregator (Attribute$Type): Aggregator 100% (1/1)21%  (9/43)25%  (2/8)
loadAggregatorClass (String): AbstractAggregateAttributeGenerator 100% (1/1)100% (21/21)100% (1/1)
     
class AggregatorParser$1100% (1/1)100% (1/1)87%  (41/47)87%  (0.9/1)
<static initializer> 100% (1/1)87%  (41/47)87%  (0.9/1)

1/*
2*  Copyright (c) 2005-2012, 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.util.parser;
19 
20import org.wso2.siddhi.core.exception.OperationNotSupportedException;
21import org.wso2.siddhi.core.projector.attibute.aggregator.Aggregator;
22import org.wso2.siddhi.core.projector.attibute.aggregator.max.MaxAggregatorDouble;
23import org.wso2.siddhi.core.projector.attibute.aggregator.max.MaxAggregatorFloat;
24import org.wso2.siddhi.core.projector.attibute.aggregator.max.MaxAggregatorInt;
25import org.wso2.siddhi.core.projector.attibute.aggregator.max.MaxAggregatorLong;
26import org.wso2.siddhi.core.projector.attibute.aggregator.min.MinAggregatorDouble;
27import org.wso2.siddhi.core.projector.attibute.aggregator.min.MinAggregatorFloat;
28import org.wso2.siddhi.core.projector.attibute.aggregator.min.MinAggregatorInt;
29import org.wso2.siddhi.core.projector.attibute.aggregator.min.MinAggregatorLong;
30import org.wso2.siddhi.core.projector.attibute.aggregator.sum.SumAggregatorDouble;
31import org.wso2.siddhi.core.projector.attibute.aggregator.sum.SumAggregatorFloat;
32import org.wso2.siddhi.core.projector.attibute.aggregator.sum.SumAggregatorInt;
33import org.wso2.siddhi.core.projector.attibute.aggregator.sum.SumAggregatorLong;
34import org.wso2.siddhi.core.projector.attibute.generator.AbstractAggregateAttributeGenerator;
35import org.wso2.siddhi.core.util.*;
36import org.wso2.siddhi.query.api.definition.Attribute;
37 
38public class AggregatorParser {
39 
40 
41    public static AbstractAggregateAttributeGenerator loadAggregatorClass(String aggregationName) {
42        return (AbstractAggregateAttributeGenerator) org.wso2.siddhi.core.util.ClassLoader.loadClass("org.wso2.siddhi.core.projector.attibute.generator." + aggregationName.substring(0, 1).toUpperCase() + aggregationName.substring(1) + "AggregateAttributeGenerator");
43    }
44 
45    public static Aggregator createSumAggregator(Attribute.Type type) {
46        switch (type) {
47            case STRING:
48                throw new OperationNotSupportedException("Sum not supported for string");
49            case INT:
50                return new SumAggregatorInt();
51            case LONG:
52                return new SumAggregatorLong();
53            case FLOAT:
54                return new SumAggregatorFloat();
55            case DOUBLE:
56                return new SumAggregatorDouble();
57            case BOOL:
58                throw new OperationNotSupportedException("Sum not supported for bool");
59        }
60        throw new OperationNotSupportedException("Sum not supported for " + type);
61    }
62 
63    public static Aggregator createAvgAggregator(Attribute.Type type) {
64        switch (type) {
65            case STRING:
66                throw new OperationNotSupportedException("Avg not supported for string");
67            case INT:
68                return new SumAggregatorInt();
69            case LONG:
70                return new SumAggregatorLong();
71            case FLOAT:
72                return new SumAggregatorFloat();
73            case DOUBLE:
74                return new SumAggregatorDouble();
75            case BOOL:
76                throw new OperationNotSupportedException("Avg not supported for bool");
77        }
78        throw new OperationNotSupportedException("Avg not supported for " + type);
79    }
80 
81    public static Aggregator createMaxAggregator(Attribute.Type type) {
82        switch (type) {
83            case STRING:
84                throw new OperationNotSupportedException("Max not supported for string");
85            case INT:
86                return new MaxAggregatorInt();
87            case LONG:
88                return new MaxAggregatorLong();
89            case FLOAT:
90                return new MaxAggregatorFloat();
91            case DOUBLE:
92                return new MaxAggregatorDouble();
93            case BOOL:
94                throw new OperationNotSupportedException("Max not supported for bool");
95        }
96        throw new OperationNotSupportedException("Max not supported for " + type);
97    }
98 
99 
100    public static Aggregator createMinAggregator(Attribute.Type type) {
101        switch (type) {
102            case STRING:
103                throw new OperationNotSupportedException("Min not supported for string");
104            case INT:
105                return new MinAggregatorInt();
106            case LONG:
107                return new MinAggregatorLong();
108            case FLOAT:
109                return new MinAggregatorFloat();
110            case DOUBLE:
111                return new MinAggregatorDouble();
112            case BOOL:
113                throw new OperationNotSupportedException("Min not supported for bool");
114        }
115        throw new OperationNotSupportedException("Min not supported for " + type);
116    }
117}

[all classes][org.wso2.siddhi.core.util.parser]
EMMA 2.1.5320 (stable) (C) Vladimir Roubtsov