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

COVERAGE SUMMARY FOR SOURCE FILE [ProbFunctionPrettyPrint.java]

nameclass, %method, %block, %line, %
ProbFunctionPrettyPrint.java0%   (0/1)0%   (0/8)0%   (0/243)0%   (0/37)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ProbFunctionPrettyPrint0%   (0/1)0%   (0/8)0%   (0/243)0%   (0/37)
ProbFunctionPrettyPrint (): void 0%   (0/1)0%   (0/3)0%   (0/1)
caseBoxedPDF (BoxedPDF): String 0%   (0/1)0%   (0/72)0%   (0/11)
caseExponentialDistribution (ExponentialDistribution): String 0%   (0/1)0%   (0/11)0%   (0/1)
caseGammaDistribution (GammaDistribution): String 0%   (0/1)0%   (0/16)0%   (0/1)
caseLognormalDistribution (LognormalDistribution): String 0%   (0/1)0%   (0/16)0%   (0/1)
caseNormalDistribution (NormalDistribution): String 0%   (0/1)0%   (0/16)0%   (0/1)
caseProbabilityMassFunction (ProbabilityMassFunction): String 0%   (0/1)0%   (0/70)0%   (0/12)
detectType (Sample): String 0%   (0/1)0%   (0/39)0%   (0/9)

1package de.uka.ipd.sdq.probfunction.print;
2 
3import java.text.DecimalFormat;
4import java.text.DecimalFormatSymbols;
5import java.util.List;
6import java.util.Locale;
7 
8import de.uka.ipd.sdq.probfunction.BoxedPDF;
9import de.uka.ipd.sdq.probfunction.ContinuousSample;
10import de.uka.ipd.sdq.probfunction.ExponentialDistribution;
11import de.uka.ipd.sdq.probfunction.GammaDistribution;
12import de.uka.ipd.sdq.probfunction.LognormalDistribution;
13import de.uka.ipd.sdq.probfunction.NormalDistribution;
14import de.uka.ipd.sdq.probfunction.ProbabilityMassFunction;
15import de.uka.ipd.sdq.probfunction.Sample;
16import de.uka.ipd.sdq.probfunction.util.ProbfunctionSwitch;
17 
18public class ProbFunctionPrettyPrint extends ProbfunctionSwitch<String> {
19 
20        /*
21         * (non-Javadoc)
22         * 
23         * @see de.uka.ipd.sdq.probfunction.util.ProbfunctionSwitch#caseBoxedPDF(de.uka.ipd.sdq.probfunction.BoxedPDF)
24         */
25        @Override
26        public String caseBoxedPDF(BoxedPDF object) {
27                String sampleString = "";
28                for (ContinuousSample s : (List<ContinuousSample>) object.getSamples()) {
29                        double value = s.getProbability();
30                        //double precision = 0.00001;
31                        double precision = 0.00000001;
32                        
33                        value *= 1 / precision;
34                        long temp = Math.round(value);
35                        double prob = temp * precision;
36                        DecimalFormat df = new DecimalFormat("0.00000000", new DecimalFormatSymbols(Locale.US));
37                        
38                        sampleString += " (" + s.getValue() + "; " + df.format(prob)
39                                        + ")";
40                }
41                
42                return "DoublePDF[" + sampleString + " ]";
43        }
44 
45        /*
46         * (non-Javadoc)
47         * 
48         * @see de.uka.ipd.sdq.probfunction.util.ProbfunctionSwitch#caseProbabilityMassFunction(de.uka.ipd.sdq.probfunction.ProbabilityMassFunction)
49         */
50        @Override
51        public String caseProbabilityMassFunction(ProbabilityMassFunction object) {
52                Sample sample = (Sample)object.getSamples().get(0);
53                
54                String pmfType = detectType(sample);
55                String sampleString = "";
56                String leftSeparator = "";
57                String rightSeparator = ";";
58 
59                if (pmfType.equals("EnumPMF")) {
60                        leftSeparator = "\"";
61                        rightSeparator = "\";";
62                }
63                
64                for (Sample s : (List<Sample>) object.getSamples()) {
65                        sampleString += " (" + leftSeparator + s.getValue() 
66                        + rightSeparator + s.getProbability() + ")";
67                }
68                return pmfType + "[" + sampleString + " ]";
69        }
70        
71        @Override
72        public String caseExponentialDistribution(ExponentialDistribution object) {
73                return "Exp("+object.getRate()+")";
74        }
75        
76 
77 
78        @Override
79        public String caseGammaDistribution(GammaDistribution object) {
80                return "Gamma("+object.getAlpha()+", "+object.getTheta()+")";
81        }
82 
83        @Override
84        public String caseLognormalDistribution(LognormalDistribution object) {
85                return "Lognorm("+object.getMu()+", "+object.getSigma()+")";
86        }
87 
88        @Override
89        public String caseNormalDistribution(NormalDistribution object) {
90                return "Norm("+object.getMu()+", "+object.getSigma()+")";
91        }
92 
93        private String detectType(Sample object) {
94                if (object.getValue() instanceof Integer)
95                        return "IntPMF";
96                if (object.getValue() instanceof Double)
97                        return "DoublePMF";
98                if (object.getValue().equals("true") || object.getValue().equals("false") || object.getValue() instanceof Boolean)
99                        return "BoolPMF";
100                if (object.getValue() instanceof String)
101                        return "EnumPMF";
102                throw new UnsupportedOperationException("Unknown PMF found!");
103        }
104 
105}

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