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

COVERAGE SUMMARY FOR SOURCE FILE [StoExPrettyPrintVisitor.java]

nameclass, %method, %block, %line, %
StoExPrettyPrintVisitor.java0%   (0/1)0%   (0/23)0%   (0/487)0%   (0/58)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class StoExPrettyPrintVisitor0%   (0/1)0%   (0/23)0%   (0/487)0%   (0/58)
$SWITCH_TABLE$de$uka$ipd$sdq$stoex$CompareOperations (): int [] 0%   (0/1)0%   (0/55)0%   (0/1)
$SWITCH_TABLE$de$uka$ipd$sdq$stoex$ProductOperations (): int [] 0%   (0/1)0%   (0/34)0%   (0/1)
$SWITCH_TABLE$de$uka$ipd$sdq$stoex$TermOperations (): int [] 0%   (0/1)0%   (0/27)0%   (0/1)
StoExPrettyPrintVisitor (): void 0%   (0/1)0%   (0/3)0%   (0/1)
caseBoolLiteral (BoolLiteral): String 0%   (0/1)0%   (0/7)0%   (0/1)
caseBooleanOperatorExpression (BooleanOperatorExpression): String 0%   (0/1)0%   (0/34)0%   (0/3)
caseCompareExpression (CompareExpression): String 0%   (0/1)0%   (0/44)0%   (0/15)
caseDoubleLiteral (DoubleLiteral): String 0%   (0/1)0%   (0/14)0%   (0/2)
caseFunctionLiteral (FunctionLiteral): String 0%   (0/1)0%   (0/63)0%   (0/5)
caseIfElseExpression (IfElseExpression): String 0%   (0/1)0%   (0/27)0%   (0/3)
caseIntLiteral (IntLiteral): String 0%   (0/1)0%   (0/4)0%   (0/1)
caseNamespaceReference (NamespaceReference): String 0%   (0/1)0%   (0/16)0%   (0/1)
caseNegativeExpression (NegativeExpression): String 0%   (0/1)0%   (0/12)0%   (0/1)
caseNotExpression (NotExpression): String 0%   (0/1)0%   (0/12)0%   (0/1)
caseParenthesis (Parenthesis): String 0%   (0/1)0%   (0/14)0%   (0/1)
casePowerExpression (PowerExpression): String 0%   (0/1)0%   (0/19)0%   (0/1)
caseProbabilityFunctionLiteral (ProbabilityFunctionLiteral): String 0%   (0/1)0%   (0/8)0%   (0/1)
caseProductExpression (ProductExpression): String 0%   (0/1)0%   (0/35)0%   (0/9)
caseStringLiteral (StringLiteral): String 0%   (0/1)0%   (0/11)0%   (0/1)
caseTermExpression (TermExpression): String 0%   (0/1)0%   (0/32)0%   (0/7)
caseVariable (Variable): String 0%   (0/1)0%   (0/8)0%   (0/2)
caseVariableReference (VariableReference): String 0%   (0/1)0%   (0/3)0%   (0/1)
prettyPrint (EObject): String 0%   (0/1)0%   (0/5)0%   (0/1)

1package de.uka.ipd.sdq.stoex.analyser.visitors;
2 
3import java.text.DecimalFormat;
4import java.text.DecimalFormatSymbols;
5import java.util.Locale;
6 
7import org.eclipse.emf.ecore.EObject;
8 
9import de.uka.ipd.sdq.probfunction.print.ProbFunctionPrettyPrint;
10import de.uka.ipd.sdq.stoex.BoolLiteral;
11import de.uka.ipd.sdq.stoex.BooleanOperatorExpression;
12import de.uka.ipd.sdq.stoex.CompareExpression;
13import de.uka.ipd.sdq.stoex.DoubleLiteral;
14import de.uka.ipd.sdq.stoex.FunctionLiteral;
15import de.uka.ipd.sdq.stoex.IfElseExpression;
16import de.uka.ipd.sdq.stoex.IntLiteral;
17import de.uka.ipd.sdq.stoex.NamespaceReference;
18import de.uka.ipd.sdq.stoex.NegativeExpression;
19import de.uka.ipd.sdq.stoex.NotExpression;
20import de.uka.ipd.sdq.stoex.Parenthesis;
21import de.uka.ipd.sdq.stoex.PowerExpression;
22import de.uka.ipd.sdq.stoex.ProbabilityFunctionLiteral;
23import de.uka.ipd.sdq.stoex.ProductExpression;
24import de.uka.ipd.sdq.stoex.StringLiteral;
25import de.uka.ipd.sdq.stoex.TermExpression;
26import de.uka.ipd.sdq.stoex.Variable;
27import de.uka.ipd.sdq.stoex.VariableReference;
28import de.uka.ipd.sdq.stoex.util.StoexSwitch;
29 
30public class StoExPrettyPrintVisitor extends StoexSwitch<String> {
31        @Override
32        public String caseBoolLiteral(BoolLiteral object) {
33                return object.isValue() ? "true" : "false";
34        }
35 
36        @Override
37        public String casePowerExpression(PowerExpression object) {
38                return ((String)doSwitch(object.getBase()))+" ^ "+((String)doSwitch(object.getExponent()));
39        }
40 
41        @Override
42        public String caseStringLiteral(StringLiteral object) {
43                return "\""+object.getValue()+"\"";
44        }
45 
46        /* (non-Javadoc)
47         * @see de.uka.ipd.sdq.pcm.core.stochastics.util.StochasticsSwitch#caseCompareExpression(de.uka.ipd.sdq.pcm.core.stochastics.CompareExpression)
48         */
49        @Override
50        public String caseCompareExpression(CompareExpression object) {
51                String op = "";
52                switch(object.getOperation())
53                {
54                case EQUALS:
55                        op = " == ";
56                        break;
57                case GREATER:
58                        op = " > ";
59                        break;
60                case GREATEREQUAL:
61                        op = " >= ";
62                        break;
63                case LESS: 
64                        op = " < ";
65                        break;
66                case LESSEQUAL:
67                        op = " <= ";
68                        break;
69                case NOTEQUAL:
70                        op = " <> ";
71                        break;
72                }
73                return ((String)doSwitch(object.getLeft()))+op+((String)doSwitch(object.getRight()));
74        }
75 
76        /* (non-Javadoc)
77         * @see de.uka.ipd.sdq.pcm.core.stochastics.util.StochasticsSwitch#caseDoubleLiteral(de.uka.ipd.sdq.pcm.core.stochastics.DoubleLiteral)
78         */
79        @Override
80        public String caseDoubleLiteral(DoubleLiteral object) {
81                DecimalFormat df = new DecimalFormat("#0.0###########", new DecimalFormatSymbols(Locale.US));
82                //DecimalFormat df = new DecimalFormat("#0.0#", new DecimalFormatSymbols(Locale.US));
83                return df.format(object.getValue());
84        }
85 
86        /* (non-Javadoc)
87         * @see de.uka.ipd.sdq.pcm.core.stochastics.util.StochasticsSwitch#caseIntLiteral(de.uka.ipd.sdq.pcm.core.stochastics.IntLiteral)
88         */
89        @Override
90        public String caseIntLiteral(IntLiteral object) {
91                return Integer.toString(object.getValue());
92        }
93 
94        /* (non-Javadoc)
95         * @see de.uka.ipd.sdq.pcm.core.stochastics.util.StochasticsSwitch#caseParantesis(de.uka.ipd.sdq.pcm.core.stochastics.Parantesis)
96         */
97        @Override
98        public String caseParenthesis(Parenthesis object) {
99                return "( " + (String)doSwitch(object.getInnerExpression())+" )";
100        }
101 
102        /* (non-Javadoc)
103         * @see de.uka.ipd.sdq.pcm.core.stochastics.util.StochasticsSwitch#caseProbabilityFunctionLiteral(de.uka.ipd.sdq.pcm.core.stochastics.ProbabilityFunctionLiteral)
104         */
105        @Override
106        public String caseProbabilityFunctionLiteral(ProbabilityFunctionLiteral object) {
107                return new ProbFunctionPrettyPrint().doSwitch(object.getFunction_ProbabilityFunctionLiteral());
108        }
109 
110        /* (non-Javadoc)
111         * @see de.uka.ipd.sdq.pcm.core.stochastics.util.StochasticsSwitch#caseProductExpression(de.uka.ipd.sdq.pcm.core.stochastics.ProductExpression)
112         */
113        @Override
114        public String caseProductExpression(ProductExpression object) {
115                String op = "";
116                switch(object.getOperation())
117                {
118                case MULT:
119                        op = " * ";
120                        break;
121                case MOD:
122                        op = " % ";
123                        break;
124                case DIV:
125                        op = " / ";
126                        break;
127                }
128                return ((String)doSwitch(object.getLeft()))+op+((String)doSwitch(object.getRight()));        }
129 
130        /* (non-Javadoc)
131         * @see de.uka.ipd.sdq.pcm.core.stochastics.util.StochasticsSwitch#caseTermExpression(de.uka.ipd.sdq.pcm.core.stochastics.TermExpression)
132         */
133        @Override
134        public String caseTermExpression(TermExpression object) {
135                String op = "";
136                switch(object.getOperation())
137                {
138                case ADD:
139                        op = " + ";
140                        break;
141                case SUB:
142                        op = " - ";
143                        break;
144                }
145                return ((String)doSwitch(object.getLeft()))+op+((String)doSwitch(object.getRight()));
146        }
147 
148        /* (non-Javadoc)
149         * @see de.uka.ipd.sdq.pcm.parameter.util.ParameterSwitch#caseNamespaceReference(de.uka.ipd.sdq.pcm.parameter.NamespaceReference)
150         */
151        @Override
152        public String caseNamespaceReference(NamespaceReference object) {
153                return object.getReferenceName()+"."+(String)doSwitch(object.getInnerReference_NamespaceReference());
154        }
155 
156        /* (non-Javadoc)
157         * @see de.uka.ipd.sdq.pcm.parameter.util.ParameterSwitch#caseVariableReference(de.uka.ipd.sdq.pcm.parameter.VariableReference)
158         */
159        @Override
160        public String caseVariableReference(VariableReference object) {
161                return object.getReferenceName();
162        }
163 
164        /* (non-Javadoc)
165         * @see de.uka.ipd.sdq.pcm.core.stochastics.util.StochasticsSwitch#caseVariable(de.uka.ipd.sdq.pcm.core.stochastics.Variable)
166         */
167        @Override
168        public String caseVariable(Variable object) {
169                String result = (String)doSwitch(object.getId_Variable());
170                // TODO: Move this part: result += "." + object.getCharacterisationType().getLiteral();
171                return result;
172        }
173 
174        public String prettyPrint(EObject theObject)
175        {
176                return (String)doSwitch(theObject);
177        }
178 
179        @Override
180        public String caseBooleanOperatorExpression(BooleanOperatorExpression object) {
181                String result = this.doSwitch(object.getLeft());
182                result += " "+object.getOperation().getLiteral()+" ";
183                return result + this.doSwitch(object.getRight());
184        }
185 
186        @Override
187        public String caseNegativeExpression(NegativeExpression object) {
188                return "-"+this.doSwitch(object.getInner());
189        }
190 
191        @Override
192        public String caseNotExpression(NotExpression object) {
193                return "NOT "+this.doSwitch(object.getInner())+"";
194        }
195 
196        @Override
197        public String caseFunctionLiteral(FunctionLiteral object) {
198                String result = object.getId() + "(";
199                for (int i=0; i < object.getParameters_FunctionLiteral().size()-1; i++)
200                        result += this.doSwitch(object.getParameters_FunctionLiteral().get(i)) + ", ";
201                result += this.doSwitch(object.getParameters_FunctionLiteral().get(object.getParameters_FunctionLiteral().size()-1)) + ")";
202                return result;
203        }
204 
205        @Override
206        public String caseIfElseExpression(IfElseExpression object) {
207                return this.doSwitch(object.getConditionExpression()) + " ? " +
208                                this.doSwitch(object.getIfExpression()) + " : " +
209                                this.doSwitch(object.getElseExpression());
210        }
211        
212}

[all classes][de.uka.ipd.sdq.stoex.analyser.visitors]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov