EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.fzi.se.accuracy.transformation]

COVERAGE SUMMARY FOR SOURCE FILE [ValidationPrecisionToMinimumLongValue.java]

nameclass, %method, %block, %line, %
ValidationPrecisionToMinimumLongValue.java0%   (0/1)0%   (0/7)0%   (0/78)0%   (0/21)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ValidationPrecisionToMinimumLongValue0%   (0/1)0%   (0/7)0%   (0/78)0%   (0/21)
<static initializer> 0%   (0/1)0%   (0/4)0%   (0/2)
ValidationPrecisionToMinimumLongValue (): void 0%   (0/1)0%   (0/3)0%   (0/1)
caseExactlyAsSpecifiedPrecision (ExactlyAsSpecifiedPrecision): Long 0%   (0/1)0%   (0/12)0%   (0/4)
caseLimitedDeviationPrecision (LimitedDeviationPrecision): Long 0%   (0/1)0%   (0/33)0%   (0/5)
caseNoPrecision (NoPrecision): Long 0%   (0/1)0%   (0/8)0%   (0/3)
checkAbsoluteValue (): void 0%   (0/1)0%   (0/14)0%   (0/5)
setAbsoluteValue (Long): void 0%   (0/1)0%   (0/4)0%   (0/2)

1/**
2 *
3 */
4package de.fzi.se.accuracy.transformation;
5 
6import org.apache.log4j.Logger;
7 
8import de.fzi.se.quality.qualityannotation.ExactlyAsSpecifiedPrecision;
9import de.fzi.se.quality.qualityannotation.LimitedDeviationPrecision;
10import de.fzi.se.quality.qualityannotation.NoPrecision;
11import de.fzi.se.quality.qualityannotation.util.QualityAnnotationSwitch;
12 
13import static java.lang.Math.*;
14 
15/**Provides the minimum long value for a given absolute long value and validation precision.
16 * @author groenda
17 *
18 */
19public class ValidationPrecisionToMinimumLongValue extends
20                QualityAnnotationSwitch<Long> {
21        /** Logger for this class. */
22        private static final Logger logger = Logger.getLogger(PCMRandomVariableSpecificationAccuracyMinimumTrafo.class);
23 
24        /** Absolute value used to calculate the minimum value. */
25        private Long absoluteValue;
26 
27        /**Sets the absolute value.
28         * Value must be set prior to calling {@link #doSwitch(org.eclipse.emf.ecore.EObject)}.
29         * Value is reset after an invocation of {@link #doSwitch(org.eclipse.emf.ecore.EObject)}.
30         * @param absoluteValue Absolute value.
31         */
32        public void setAbsoluteValue(Long absoluteValue) {
33                this.absoluteValue = absoluteValue;
34        }
35 
36        @Override
37        public Long caseNoPrecision(NoPrecision object) {
38                checkAbsoluteValue();
39                absoluteValue = null;
40                return Long.MIN_VALUE;
41        }
42 
43        @Override
44        public Long caseExactlyAsSpecifiedPrecision(
45                        ExactlyAsSpecifiedPrecision object) {
46                checkAbsoluteValue();
47                long abs = absoluteValue;
48                absoluteValue = null;
49                return abs;
50        }
51 
52        @Override
53        public Long caseLimitedDeviationPrecision(LimitedDeviationPrecision object) {
54                checkAbsoluteValue();
55                long min = min((long) (absoluteValue-ceil(object.getAbsolute())),
56                                                (long) (absoluteValue-ceil(((double)absoluteValue*object.getRelative()))));
57                absoluteValue = null;
58                return min;
59        }
60 
61        /**Ensure that the absolute value is not null.
62         */
63        private void checkAbsoluteValue() {
64                if (absoluteValue == null) {
65                        String msg = "You have to set the absolute value before invoking doSwitch(). Note: The absolute value is reset after an execution of doSwitch() to prevent accidental re-use.";
66                        logger.error(msg);
67                        throw new IllegalArgumentException(msg);
68                }
69        }
70}

[all classes][de.fzi.se.accuracy.transformation]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov