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

nameclass, %method, %block, %line, %
OutlierFilteredCollection.java0%   (0/2)0%   (0/4)0%   (0/75)0%   (0/18)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class OutlierFilteredCollection0%   (0/1)0%   (0/2)0%   (0/63)0%   (0/15)
OutlierFilteredCollection (Collection, double): void 0%   (0/1)0%   (0/7)0%   (0/3)
applyFilter (Collection): void 0%   (0/1)0%   (0/56)0%   (0/12)
     
class OutlierFilteredCollection$10%   (0/1)0%   (0/2)0%   (0/12)0%   (0/4)
OutlierFilteredCollection$1 (OutlierFilteredCollection): void 0%   (0/1)0%   (0/6)0%   (0/2)
compare (TimeSpanMeasurement, TimeSpanMeasurement): int 0%   (0/1)0%   (0/6)0%   (0/2)

1package de.uka.ipd.sdq.sensorframework.filter;
2 
3import java.util.ArrayList;
4import java.util.Collection;
5import java.util.Collections;
6import java.util.Comparator;
7import java.util.Iterator;
8 
9import de.uka.ipd.sdq.sensorframework.entities.Measurement;
10import de.uka.ipd.sdq.sensorframework.entities.TimeSpanMeasurement;
11import de.uka.ipd.sdq.sensorframework.filter.AbstractMeasurementsCollection;
12 
13public class OutlierFilteredCollection extends AbstractMeasurementsCollection {
14 
15        /** The configurations parameter. */
16        private double parameter;
17 
18        /**
19         * Initializes a new OutlierFilteredCollection with the given measurements and filter parameter.
20         * 
21         * @param originalMeasurements
22         *            The associated measurements.
23         * @param parameter The associated parameter
24         */
25        public OutlierFilteredCollection(
26                        Collection<Measurement> originalMeasurements, double parameter) {
27                super(originalMeasurements);
28                this.parameter = parameter;
29        }
30 
31        /** {@inheritDoc}
32         */
33        @Override
34        protected void applyFilter(Collection<Measurement> filteredItemsList) {
35                int outlierNumber = 0;
36                outlierNumber = (int) (parameter * originalMeasurements.size());
37                ArrayList<TimeSpanMeasurement> sortedMeasurements = (ArrayList<TimeSpanMeasurement>) new ArrayList<TimeSpanMeasurement>();
38                for (Iterator<?> it = originalMeasurements.iterator(); it.hasNext();)
39                        sortedMeasurements.add((TimeSpanMeasurement) it.next());
40                Collections.sort(sortedMeasurements,
41                                new Comparator<TimeSpanMeasurement>() {
42 
43                                        public int compare(TimeSpanMeasurement o1,
44                                                        TimeSpanMeasurement o2) {
45                                                return Double.compare(o1.getTimeSpan(), o2
46                                                                .getTimeSpan());
47                                        }
48 
49                                });
50                for (int i = sortedMeasurements.size() - 1; i >= sortedMeasurements
51                                .size()
52                                - outlierNumber; i--) {
53                        filteredItemsList.add(sortedMeasurements.get(i));
54                }
55        }
56}

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