EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.sensorframework.filter]

COVERAGE SUMMARY FOR SOURCE FILE [FilteredCollectionsManager.java]

nameclass, %method, %block, %line, %
FilteredCollectionsManager.java0%   (0/1)0%   (0/10)0%   (0/111)0%   (0/27)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class FilteredCollectionsManager0%   (0/1)0%   (0/10)0%   (0/111)0%   (0/27)
<static initializer> 0%   (0/1)0%   (0/3)0%   (0/2)
FilteredCollectionsManager (): void 0%   (0/1)0%   (0/8)0%   (0/2)
addFactory (IFilteredCollectionFactory): void 0%   (0/1)0%   (0/6)0%   (0/2)
filteringTheMeasurements (Collection): Collection 0%   (0/1)0%   (0/58)0%   (0/11)
getFactories (): ArrayList 0%   (0/1)0%   (0/3)0%   (0/1)
getFilteredMeasurements (SensorAndMeasurements): Object 0%   (0/1)0%   (0/10)0%   (0/2)
getProperty (Properties): Number 0%   (0/1)0%   (0/10)0%   (0/2)
removeFactory (IFilteredCollectionFactory): void 0%   (0/1)0%   (0/6)0%   (0/2)
resetCount (): void 0%   (0/1)0%   (0/3)0%   (0/2)
setFactories (ArrayList): void 0%   (0/1)0%   (0/4)0%   (0/2)

1package de.uka.ipd.sdq.sensorframework.filter;
2 
3import java.util.ArrayList;
4import java.util.Collection;
5import java.util.Properties;
6 
7import de.uka.ipd.sdq.sensorframework.entities.Measurement;
8import de.uka.ipd.sdq.sensorframework.entities.SensorAndMeasurements;
9 
10/**
11 * The class creates the filtered collection from measurements collection.
12 * 
13 * @author Roman Andrej
14 */
15public class FilteredCollectionsManager {
16 
17        private ArrayList<IFilteredCollectionFactory> factories = new ArrayList<IFilteredCollectionFactory>();
18        
19        IFilteredCollectionFactory factory;
20 
21        /** Filters count value. */
22        private static int count = 0;
23 
24        /** Get the filtered measurements as new SensorAndMeasurements instance. */
25        public Object getFilteredMeasurements(SensorAndMeasurements sam) {
26                return new SensorAndMeasurements(sam.getSensor(),
27                                filteringTheMeasurements(sam.getMeasurements()));
28        }
29 
30        /** Set the filter sequence. */
31        private Collection<Measurement> filteringTheMeasurements(
32                        Collection<Measurement> measuremts) {
33 
34                // Exit constraint.
35                if (factories.isEmpty() || count == factories.size()) {
36                        // set counter of 0
37                        resetCount();
38                        return measuremts;
39                }
40                factory = factories.get(count++);
41 
42                AbstractMeasurementsCollection filteredCollection;
43 
44                if (factory.canFilter(measuremts,
45                                getProperty(factory.getProperties()))) {
46                        filteredCollection = factory.getFilteredCollection(measuremts,
47                                        getProperty(factory.getProperties()));
48                } else {
49                        // set the minimal value for filtering attribute
50                        filteredCollection = factory.getFilteredCollection(measuremts,
51                                        factory.convertToType("0"));
52                }
53 
54                // call it self with another filtered collection
55                return filteringTheMeasurements(filteredCollection);
56        }
57 
58        /** Get the value of first property. */
59        private Number getProperty(Properties properties) {
60                // get the attribute description
61                String desc = properties.propertyNames().nextElement().toString();
62                // get attribute
63                return (Number) properties.get(desc);
64        }
65        
66        public void addFactory(IFilteredCollectionFactory factory) {
67                factories.add(factory);
68        }
69        
70        public void removeFactory(IFilteredCollectionFactory factory){
71                factories.remove(factory);
72        }
73 
74        /**
75         * @return the factories
76         */
77        public ArrayList<IFilteredCollectionFactory> getFactories() {
78                return factories;
79        }
80 
81        /**
82         * @param factories the factories to set
83         */
84        public void setFactories(ArrayList<IFilteredCollectionFactory> factories) {
85                this.factories = factories;
86        }
87 
88        /** The method is used for control of the filtered collection sequence. */
89        public void resetCount() {
90                count = 0;
91        }
92}

[all classes][de.uka.ipd.sdq.sensorframework.filter]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov