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

COVERAGE SUMMARY FOR SOURCE FILE [ProbeStrategyRegistry.java]

nameclass, %method, %block, %line, %
ProbeStrategyRegistry.java0%   (0/2)0%   (0/7)0%   (0/169)0%   (0/47)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ProbeStrategyRegistry0%   (0/1)0%   (0/3)0%   (0/57)0%   (0/16)
ProbeStrategyRegistry (): void 0%   (0/1)0%   (0/8)0%   (0/3)
getProbeStrategy (ProbeType, Object): IProbeStrategy 0%   (0/1)0%   (0/35)0%   (0/9)
registerProbeStrategy (IProbeStrategy, ProbeType, Object): void 0%   (0/1)0%   (0/14)0%   (0/4)
     
class ProbeStrategyRegistry$ProbeTypeEntityPair0%   (0/1)0%   (0/4)0%   (0/112)0%   (0/31)
ProbeStrategyRegistry$ProbeTypeEntityPair (ProbeStrategyRegistry, ProbeType, ... 0%   (0/1)0%   (0/12)0%   (0/4)
equals (Object): boolean 0%   (0/1)0%   (0/59)0%   (0/20)
getOuterType (): ProbeStrategyRegistry 0%   (0/1)0%   (0/3)0%   (0/1)
hashCode (): int 0%   (0/1)0%   (0/38)0%   (0/6)

1package de.uka.ipd.sdq.probespec.framework.probes;
2 
3import java.util.HashMap;
4import java.util.Map;
5 
6import de.uka.ipd.sdq.probespec.framework.ProbeType;
7import de.uka.ipd.sdq.probespec.framework.exceptions.ProbeStrategyNotFoundException;
8 
9/**
10 * Basic implementation of the {@link IProbeStrategyRegistry} interface.
11 * 
12 * @author Philipp Merkle
13 *
14 */
15public class ProbeStrategyRegistry implements IProbeStrategyRegistry {
16 
17        private Map<ProbeTypeEntityPair, IProbeStrategy> strategiesMap;
18 
19        public ProbeStrategyRegistry() {
20                strategiesMap = new HashMap<ProbeTypeEntityPair, IProbeStrategy>();
21        }
22 
23        @Override
24        public IProbeStrategy getProbeStrategy(ProbeType type,
25                        Object measurableEntity) {
26                ProbeTypeEntityPair pair = new ProbeTypeEntityPair(type,
27                                measurableEntity);
28                IProbeStrategy strategy = strategiesMap.get(pair); 
29                if (strategy == null)
30                        throw new ProbeStrategyNotFoundException(
31                                        "Could not find a ProbeStrategy for probe type "
32                                                        + type.name() + " that is able to measure a "
33                                                        + measurableEntity.getClass().getSimpleName());
34                return strategy;
35        }
36 
37        @Override
38        public void registerProbeStrategy(IProbeStrategy strategy, ProbeType type,
39                        Object measurableEntity) {
40                ProbeTypeEntityPair pair = new ProbeTypeEntityPair(type,
41                                measurableEntity);
42                strategiesMap.put(pair, strategy);
43        }
44 
45        private class ProbeTypeEntityPair {
46 
47                private ProbeType type;
48 
49                private Object entity;
50 
51                public ProbeTypeEntityPair(ProbeType type, Object entity) {
52                        this.type = type;
53                        this.entity = entity;
54                }
55 
56                @Override
57                public int hashCode() {
58                        final int prime = 31;
59                        int result = 1;
60                        result = prime * result + getOuterType().hashCode();
61                        result = prime * result
62                                        + ((entity == null) ? 0 : entity.hashCode());
63                        result = prime * result + ((type == null) ? 0 : type.hashCode());
64                        return result;
65                }
66 
67                @Override
68                public boolean equals(Object obj) {
69                        if (this == obj) {
70                                return true;
71                        }
72                        if (obj == null) {
73                                return false;
74                        }
75                        if (!(obj instanceof ProbeTypeEntityPair)) {
76                                return false;
77                        }
78                        ProbeTypeEntityPair other = (ProbeTypeEntityPair) obj;
79                        if (!getOuterType().equals(other.getOuterType())) {
80                                return false;
81                        }
82                        if (entity == null) {
83                                if (other.entity != null) {
84                                        return false;
85                                }
86                        } else if (!entity.equals(other.entity)) {
87                                return false;
88                        }
89                        if (type == null) {
90                                if (other.type != null) {
91                                        return false;
92                                }
93                        } else if (!type.equals(other.type)) {
94                                return false;
95                        }
96                        return true;
97                }
98 
99                private ProbeStrategyRegistry getOuterType() {
100                        return ProbeStrategyRegistry.this;
101                }
102 
103        }
104 
105}

[all classes][de.uka.ipd.sdq.probespec.framework.probes]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov