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

nameclass, %method, %block, %line, %
AbstractMeasurementsCollection.java0%   (0/2)0%   (0/11)0%   (0/143)0%   (0/29)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AbstractMeasurementsCollection0%   (0/1)0%   (0/7)0%   (0/76)0%   (0/20)
AbstractMeasurementsCollection (): void 0%   (0/1)0%   (0/9)0%   (0/4)
AbstractMeasurementsCollection (Collection): void 0%   (0/1)0%   (0/12)0%   (0/5)
access$0 (AbstractMeasurementsCollection): ArrayList 0%   (0/1)0%   (0/3)0%   (0/1)
getOriginalMeasurements (): Collection 0%   (0/1)0%   (0/11)0%   (0/3)
iterator (): Iterator 0%   (0/1)0%   (0/17)0%   (0/4)
resetFilteredItems (): void 0%   (0/1)0%   (0/4)0%   (0/2)
size (): int 0%   (0/1)0%   (0/20)0%   (0/4)
     
class AbstractMeasurementsCollection$10%   (0/1)0%   (0/4)0%   (0/67)0%   (0/10)
AbstractMeasurementsCollection$1 (AbstractMeasurementsCollection): void 0%   (0/1)0%   (0/17)0%   (0/4)
hasNext (): boolean 0%   (0/1)0%   (0/17)0%   (0/1)
next (): Measurement 0%   (0/1)0%   (0/32)0%   (0/4)
remove (): void 0%   (0/1)0%   (0/1)0%   (0/1)

1package de.uka.ipd.sdq.sensorframework.filter;
2 
3import java.util.AbstractCollection;
4import java.util.ArrayList;
5import java.util.Collection;
6import java.util.Iterator;
7 
8import de.uka.ipd.sdq.sensorframework.entities.Measurement;
9 
10/**
11 * Superclass for all filtered collection in the SensorFramework.
12 * @author Roman Andrej
13 */
14public abstract class AbstractMeasurementsCollection extends
15                AbstractCollection<Measurement> {
16 
17        /** Original collection. */
18        protected Collection<Measurement> originalMeasurements = null;
19        
20        /** Filtered collection. 
21         * TODO clarify whether it contains items filtered AWAY 
22         * rather than items left AFTER filtering. 
23         * TODO why is this private, not protected?
24         */
25        private ArrayList<Measurement> filteredItems = null;//why not a Collection, too?
26 
27        /**
28         * Initializes a new AbstractMeasurementsCollection.
29         */
30        public AbstractMeasurementsCollection(){
31        }
32        
33        /**
34         * Initializes a new AbstractMeasurementsCollection.
35         * 
36         * @param originalMeasurements
37         *            The associated measurements.
38         */
39        public AbstractMeasurementsCollection(
40                        Collection<Measurement> originalMeasurements) {
41                this.originalMeasurements = originalMeasurements;
42        }
43        
44        /** {@inheritDoc}
45         */
46        @Override
47        public Iterator<Measurement> iterator() {
48                if (filteredItems == null) {
49                        filteredItems = new ArrayList<Measurement>();
50                        applyFilter(filteredItems);
51                }
52                return new Iterator<Measurement>(){
53                        Iterator<Measurement> it = originalMeasurements.iterator();
54                        int currentOriginal = 0, alreadyReturned = 0;
55                        
56                        public boolean hasNext() {
57                                return currentOriginal < originalMeasurements.size() && alreadyReturned < size();
58                        }
59        
60                        public Measurement next() {
61                                Measurement next;
62                                while ( filteredItems.contains(next = it.next()) ){
63                                        currentOriginal++;
64                                }
65                                currentOriginal++; alreadyReturned++;
66                                return next;
67                        }
68        
69                        public void remove() {//TODO add logging here
70                                
71                        }
72                };
73        }
74 
75        /** The Method filtered the measurements. 
76         * TODO explain what filtering actually means. 
77         * @param filteredItemsList seems to be used as return parameter, 
78         * which contains the elements that are filtered away. 
79         */
80        protected abstract void applyFilter(Collection<Measurement> filteredItemsList);
81 
82        
83        /* (non-Javadoc)
84         * @see java.util.AbstractCollection#size()
85         */
86        @Override
87        public int size() {
88                if (filteredItems == null) {
89                        filteredItems = new ArrayList<Measurement>();
90                        applyFilter(filteredItems);
91                }
92                return originalMeasurements.size() - filteredItems.size();//TODO does it make sense? or does "filteredItems" contain items filtered AWAY, not items remaining AFTER filtering?
93        }
94 
95        /**
96         * Get the original collection.
97         */
98        public Collection<Measurement> getOriginalMeasurements()
99                        throws InstantiationException {//TODO is this really an instantiation problem? Or rather a NullPointerException?
100                if (originalMeasurements == null)
101                        throw new InstantiationException("No original measurements saved!");
102                return originalMeasurements;
103        }
104 
105        /**
106         * Resets internally stored filtered items to <code>null</code>
107         */
108        public void resetFilteredItems(){
109                filteredItems = null;
110        }
111}

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